Bosch BME280 driver

Discuss development of drivers for external hardware and components, such as LCD screens, sensors, motor drivers, etc.
Target audience: Users and developers of drivers.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Bosch BME280 driver

Post by pythoncoder » Mon Sep 18, 2017 3:12 pm

Given that those measurements were spread over ten hours it seems likely that the pressure might have changed by +0.43 -0.24 millibar over the period. My graphing barometer shows rates of change two orders of magnitude faster occurred in the last week.
Peter Hinch
Index to my micropython libraries.

xwct
Posts: 1
Joined: Wed Oct 11, 2017 3:13 pm

Re: Bosch BME280 driver

Post by xwct » Wed Oct 11, 2017 3:20 pm

[code]
MicroPython v1.9.2 on 2017-08-23; PYBv1.1 with STM32F405RG
Type "help()" for more information.
>>> import machine
>>> import bme280
>>> i2c = machine.I2C(2)
>>> bme = bme280.BME280(i2c = i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bme280.py", line 185, in __init__
File "bme280.py", line 191, in _load_calibration
File "bme280.py", line 151, in readU16LE
File "bme280.py", line 134, in readU16
TypeError: function missing 1 required positional arguments
>>> i2c = machine.I2C(scl='Y9',sda='Y10')
>>> bme = bme280.BME280(i2c = i2c)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bme280.py", line 185, in __init__
File "bme280.py", line 191, in _load_calibration
File "bme280.py", line 151, in readU16LE
File "bme280.py", line 134, in readU16
TypeError: function missing 1 required positional arguments
[/code]

keep getting this error when trying to use the driver, i2c.scan() reports the address is 118.

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

Re: Bosch BME280 driver

Post by Roberthh » Wed Oct 11, 2017 7:40 pm

The from_bytes() method is missing the second argument, which must be "little". So the two lines 133.134 should read:

Code: Select all

        result = int.from_bytes(
            self._i2c.readfrom_mem(self._address, register, 2), 'little' ) & 0xFFFF
Similar in the functions readRaw8() (line 115) and readU8() (line120). That was not required in earlier versions of MicroPython.

Post Reply