New Bosch BME280 temperature, humidity, pressure sensor library

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
triplepoint
Posts: 1
Joined: Fri Aug 03, 2018 10:35 pm

New Bosch BME280 temperature, humidity, pressure sensor library

Post by triplepoint » Fri Aug 03, 2018 10:42 pm

I wanted to share a new driver I wrote for the Bosch BME280.
https://github.com/triplepoint/micropython_bme280_i2c

Some of the work was heavily guided by the excellent prior work at:
https://github.com/catdog2/mpy_bme280_esp8266
but I wanted to expose more of the power mode and filtering functionality per the data sheet.

This driver is more or less a straight reading of the data sheet, combined with the reference C driver library at:
https://github.com/BoschSensortec/BME280_driver

If you've got some time and have a BME280 wired up with I2c, please give it a try and let me know how it works for you.

I recommend reading the data sheet sections 3.4, 3.5, and 3.6 to get an idea of what the extra configuration values can do.
https://ae-bst.resource.bosch.com/media ... 001-12.pdf

Thanks!

rhubarbdog
Posts: 166
Joined: Tue Nov 07, 2017 11:45 pm

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by rhubarbdog » Fri Nov 30, 2018 5:35 am

Subject: New Bosch BME280 temperature, humidity, pressure sensor library
triplepoint wrote:
Fri Aug 03, 2018 10:42 pm
I wanted to share a new driver I wrote for the Bosch BME280.
https://github.com/triplepoint/micropython_bme280_i2c

Some of the work was heavily guided by the excellent prior work at:
https://github.com/catdog2/mpy_bme280_esp8266
hi
i've just looked at your repository and there's a Licensing issue. i've got one of these and have written a class for raspberry pi. Bosch weren't happy i were porting their code to python and were *very* clear that the code has to have a copy of their license at the top and the repository is to be licensed by them. see my License.txt at https://github.com/rhubarbdog/bme280

User avatar
mcauser
Posts: 410
Joined: Mon Jun 15, 2015 8:03 am

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by mcauser » Wed Dec 12, 2018 11:57 pm

You rewrote some of their library from scratch in a different language an they claimed copyright?
Their licenses looks like a BSD-3-Clause with an extra paragraph.
I'm no lawyer or software license expert, but if your work is interpreted as derivative work, then you should comply with their license.
If your work is completely original, there's a big grey area there, as your code relies on the same hardware/datasheet, there's only so many ways you can write the code.

schorschi
Posts: 1
Joined: Sun Mar 03, 2019 8:31 am

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by schorschi » Sun Mar 03, 2019 8:34 am

How the heck do you use module? What directory do I put it in? Great library I guess, but you provide no instructions on how to install the module? Especially for users that are using Windows and uPyCraft to program ESP8266 devices, no clue how to get the module seen by the development environment.

kevinkk525
Posts: 502
Joined: Sat Feb 03, 2018 7:02 pm

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by kevinkk525 » Sun Mar 03, 2019 9:03 am

You just copy the file onto the device using for example rshell, mpfshell or similar.
Kevin Köck

User avatar
Hasenradball
Posts: 14
Joined: Tue May 21, 2019 12:52 pm
Location: Germany
Contact:

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by Hasenradball » Mon Jul 08, 2019 11:09 am

Hi together,

I am searching for an micropython driver for the Bosch BME280 Sensor.
Do you have an Hint for me which library I should use?

Frank

User avatar
jimmo
Posts: 791
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by jimmo » Mon Jul 08, 2019 12:13 pm

Hi Frank,

Have you tried using triplepoint's library linked at the start of the thread?

User avatar
Roberthh
Posts: 1697
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by Roberthh » Mon Jul 08, 2019 1:44 pm

I have one here https://github.com/robert-hh/BME280, which I adapted from the Adafruit driver. I tested them on a Pycom device and on a ESP32 with micropython.org v1.11 firmware. I mentioned every source I could find, Bosch too (Adafruit did not), especially since I used the data sheet to verify and fix the calculation for compensation data.
There are two variants, one using float calculation and one doing integer calculation, like in the original Bosch data sheet. The results are pretty much the same.

User avatar
Hasenradball
Posts: 14
Joined: Tue May 21, 2019 12:52 pm
Location: Germany
Contact:

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by Hasenradball » Mon Jul 08, 2019 8:17 pm

Hi Robert,

thank for your Post.
When I use your lib as:

Code: Select all

def measureTempHumPres_BME280():
    return BME.read_compensated_data()

# ### --- Main Schleife --- ###
while True:
    # turn on LED
    #LED.value(0)
    utime.sleep(1)
    vcc_voltage = measureVcc(adc)
    (temperature, pressure, humidity) = measureTempHumPres_BME280()
    print('Vcc-Voltage: {0:5.3f} V'.format(vcc_voltage))
    print('BME280 Data: Temperature: {0}, Humidity: {1}, Pressure: {2}'.format(temperature, humidity, pressure))
    #LED.value(1)
    utime.sleep(3)
I get the following result:

Code: Select all

MPY: soft reboot
Vcc-Voltage: 4.691 V
BME280 Data: Temperature: 22.5813, Humidity: 37.6937, Pressure: 98967.9
Do I have to divide the pressure by 100?

And how is this used?

Code: Select all

    @property
    def values(self):
        """ human readable values """

        t, p, h = self.read_compensated_data()

        return ("{:.2f}C".format(t), "{:.2f}hPa".format(p/100),
                "{:.2f}%".format(h))
best regards Frank

User avatar
Roberthh
Posts: 1697
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: New Bosch BME280 temperature, humidity, pressure sensor library

Post by Roberthh » Tue Jul 09, 2019 6:02 am

Yes, the pressure value returned by read_compensated_data is Pascals (Pa). It has to be divided by 100 to get a value in hPa (= hecto-Pascal = Pascal / 100), which is usually used in weather reports. Note, that the returned values differ for the int and the float version. The returned values for the int version are scaled up to retain the fractional digits.

Values is a property. It is used like this, e.g.

Code: Select all

from bme280_float import BME280
bme = BME280(...)
(temperature, pressure, humidity) = bme.values
So it is a function call that looks like a variable access. For both int and float version, bme.values returns the same ranges. The scaling required by the int version is done there.

Post Reply