Page 5 of 5

Re: Bosch BME280 driver

Posted: Mon Sep 18, 2017 3:12 pm
by pythoncoder
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.

Re: Bosch BME280 driver

Posted: Wed Oct 11, 2017 3:20 pm
by xwct
[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.

Re: Bosch BME280 driver

Posted: Wed Oct 11, 2017 7:40 pm
by Roberthh
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.