Shop OBEX P1 Docs P2 Docs Learn Events
Bosch BME280 — Parallax Forums

Bosch BME280

I'm trying to write an object or code for a BME280. I've searched the OBEX and Google for something already written but haven't found anything.

Although I learn more when I do it myself and sometimes have more fun, I'd rather not reinvent the wheel if there's one out there.

Anyone know of anything in SPIN?

Comments

  • I loved the Bosch BNO055, so I wondered what the BME280 was. A copy of the description follows for others wondering the same thing. It looks like a worthwhile interface project;

    BME280

    The BME280 is an integrated environmental sensor developed specifically for mobile applications where size and low power consumption are key design constraints. The unit combines individual high linearity, high accuracy sensors for pressure, humidity and temperature in an 8-pin metal-lid 2.5 x 2.5 x 0.93 mm³ LGA package, designed for low current consumption (3.6 μA @1Hz), long term stability and high EMC robustness.

    The humidity sensor features an extremely fast response time which supports performance requirements for emerging applications such as context awareness, and high accuracy over a wide temperature range. The pressure sensor is an absolute barometric pressure sensor with features exceptionally high accuracy and resolution at very low noise. The integrated temperature sensor has been optimized for very low noise and high resolution. It is primarily used for temperature compensation of the pressure and humidity sensors, and can also be used for estimating ambient temperature.

    The BME280 supports a full suite of operating modes which provides the flexibility to optimize the device for power consumption, resolution and filter performance."

    Applications

    - Context awareness, e.g. skin detection, room change detection

    - Fitness monitoring / well-being

    - Warning regarding dryness or high temperatures

    - Measurement of volume and air flow

    - Home automation control

    - Control heating, ventilation, air conditioning (HVAC)

    - Internet of things

    - GPS enhancement (e.g. time-to-first-fix improvement, dead reckoning, slope detection)

    - Indoor navigation (change of floor detection, elevator detection)

    - Outdoor navigation, leisure and sports applications

    - Weather forecast

    - Vertical velocity indication (rise/sink speed)
  • Here's my 1st attempt.
    CON       
      _clkmode = xtal1 + pll16x      '80 MHz system clock
      _xinfreq = 5_000_000
    
      BME = $77            '$77 for BME280 w/ SDO tied to Vcc (Bosch hum, bar, temp)
    
      SCL = 20
      SDA = 21
      bitrate = 100000
    
      'BME registers
      hum_lsb = $FE
      hum_msb = $FD
      temp_xlsb = $FC
      temp_lsb = $FB
      temp_msb = $FA
      pres_xlsb = $F9
      pres_lsb = $F8
      pres_msb = $F7
       
    
    OBJ
      tv   :   "tv_text" 
      I2C  :   "I2C PASM driver v1.8od"
       
    VAR
      byte BMEbuf[8]
      long sum
       
    PUB init
      TV.start(0)
      I2C.start(SCL,SDA,Bitrate)
      dira[16]~~
      main
    
    PUB main
    
      
      I2C.writeByte(BME,$F2,%00000000)  ' set ctrl_hum    no oversampling 
      I2C.writeByte(BME,$F5,%00000000)   '  default
      I2C.writeByte(BME,$F4,%00000011)  'set ctrl_meas register no temp & pres oversampling,select normal mode
      repeat
        
         
        I2C.readBytes(BME,$F7,@BMEbuf[0],8)  'read BME registers $F7-$FE, store in BMEbuf
        waitcnt(clkfreq/10+cnt)
        TV.move(1,0)
        TV.bin(BMEbuf[2],8)         'see if anything shows up
        TV.cr
        TV.bin(BMEbuf[5],8)
        tv.cr
        tv.bin(BMEbuf[8],8)
        waitcnt(clkfreq*5+cnt)     '5 seconds between measurments
        outa[16]~~              'flash a LED to know it's running
        waitcnt(clkfreq/2+cnt)
        outa[16]~
        
    
    
    
        {
        sum:= BMEbuf[temp_xlsb] | BMEbuf[temp_lsb] << 8 | BMEbuf[temp_msb] << 16  'sum of temp bufs           
        TV.move (8,8)
        TV.dec(sum)
        waitcnt(clkfreq*5+cnt)     '5 seconds between measurments
        outa[16]~~
        waitcnt(clkfreq/2+cnt)
        outa[16]~
        }
    
  • I am using the BME280 in my weather station that I built.

    Unfortunately all my code and library is in C.

    Mike
  • If it's commented it still may help me.
    Thanks
    Aaron
  • Ok, I put the library on the OBEX.

    After looking at this library I remember what a hell of a time I had to get the math to work.
    Not the easiest device to read the data from.

    http://obex.parallax.com/object/872

    Mike
  • iseries/AGCB,
    Hi. I have a BME280 and I can configure it and read all the registers using Prop1.
    However, I am stumped by the calculations to apply the trimming parameters.
    The datasheet explanation and code is not very helpful.
    Searching the internet reveals lots of code in various languages, but not much simple explanation.
    Do you know of anywhere which provides a simple explanation for applying these trimming parameters?
    iseries, I tried to download your obex object, but came up with "page not found".
  • iseries, I tried to download your obex object, but came up with "page not found".

    I have sent an email to the webmaster and we will try to rectify the situation.

  • Not to derail this thread, I noticed that Adafruit sells a BME680 module, which adds some sort of gas sensor. Since I was considering buying a dht22 module maybe this BME680 might be a better fit.

    Since I find it much easier to work with SimpleIDE and GCC, there was a mention of some C code. Is that, perhaps, available for perusal and maybe trying to make it work within SimpleIDE?

    Ray
  • The 680 requires you to compile and run a library from Bosch, which Adafruit does in their library: https://github.com/adafruit/Adafruit_BME680

    As far as the 280, the python library is probably the easiest to read: https://github.com/adafruit/Adafruit_Python_BME280
  • geo,
    geo_leeman wrote: »
    As far as the 280, the python library is probably the easiest to read: https://github.com/adafruit/Adafruit_Python_BME280

    Yup, you are correct, thanks. I have looked at several code snippets and this one has the best structure to understand the trimming maths.
  • I put the code up on GitHub and added a link in the OBEX.

    BME280 on Github

    Mike
Sign In or Register to comment.