BME280 on the LoPy
-
Hello,
I'm currently trying to get the Adafruit BME280 sensor running with my LoPy.
And I came across pretty much the same issue as michal in this post Wipy 2.0 and BME280 sensor.However my issue is looking a little different:
Traceback (most recent call last): File "<stdin>", line 9, 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 OSError: I2C bus errorI'm very new to the LoPy and as far as I read from the specs he has pretty much the same hardware as the WiPy. So I ask myself what could cause this issue. The original library: https://bitbucket.org/oscarBravo/wipy_bme280
I initialized my BME like this:
>>> from machine import I2C >>> import bme280 >>> i2c = I2C(0, I2C.MASTER, baudrate=100000) >>> bme = bme280.BME280(i2c=i2c)Do you have any suggestions how to solve this?
Thanks already in advance!
-
@binux
if your firmwareos.uname()is 1.6.8.b1
then it not work at all - you must wait for new firmware or downgrade it to 1.6.7 or 1.6.6 -
This post is deleted! -
@livius Okay, tell me why - I'm running the latest firmware. Which was i think 1.6.8b1 - just updated today...
Anyhow, would this library work with the fix propsed on the other thread or would I still have to change something?
-
@binux
As i say - current firmware (1.6.8.b1) introduce some bug with I2C or bring it more visible then previously.
You must downgrade firmware to 1.6.7 or wait for new firmware release. -
Hi Livius,
Can you give an example of the minimum code to reproduce this issue (preferably on GitHub)?
-
-
@sakis
I see that I2C work back in 1.6.9 :) -
@binux I am seeing exactly the same problem with 1.6.10b1. I have Vin on the BME280 tied to 3.3v on the LoPy, I have ground on the BME280 tied to gnd on the LoPy, I have SDA on the BME280 tied to pin P9 on the LoPy, and I have SCL on the BME280 tied to pin P10 on the LoPy.
>>> from machine import I2C >>> import bme280 >>> i2c = I2C(0, I2C.MASTER, baudrate=100000) >>> i2c.scan() [118] >>> bme = bme280.BME280(i2c=i2c) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "bme280.py", line 186, in __init__ File "bme280.py", line 192, in _load_calibration File "bme280.py", line 152, in readU16LE File "bme280.py", line 135, in readU16 OSError: I2C bus errorAs you can see, the I2C bus has something on it at hex address 0x76 (118 decimal). However, initializing the BME280 fails.
Any help, anyone? Please?
Thanks!
-
You have to specifiy the address when creating the sensor object:
def __init__(self, address, i2c):. I don't see the address getting the default address assigned here, maybe that's your issue?edit:
I was looking at the wrong class
address=BME280_I2CADDRIt gets the default address from there
self._device = Device(address, i2c) -
I am trying to use the same library with a BME280 and am experienceing the exact same issue with firmware version 1.7.4.b1
same error:Traceback (most recent call last):
File "main.py", line 9, in <module>
File "bme280.py", line 198, in init
File "bme280.py", line 204, in _load_calibration
File "bme280.py", line 164, in readU16LE
File "bme280.py", line 147, in readU16Did anyone get this to work?
-
@ledbelly2142 said in BME280 on the LoPy:
I am trying to use the same library with a BME280 and am experienceing the exact same issue with firmware version 1.7.4.b1
same error:Traceback (most recent call last):
File "main.py", line 9, in <module>
File "bme280.py", line 198, in init
File "bme280.py", line 204, in _load_calibration
File "bme280.py", line 164, in readU16LE
File "bme280.py", line 147, in readU16Did anyone get this to work?
Try my fork of the library: https://github.com/ButchAnton/LoPy_BME280
-
@Butch
yup, thats what I'm using. I forked it. Why the init.py file? -
@ledbelly2142 That makes it into a package: https://docs.python.org/2/tutorial/modules.html#packages
-
@Butch
I still have the same issue, just updated to the latest firmware 1.7.5.b2
In the main.py I'm just trying to print out values in the console, I have:import pycom from machine import I2C import time import bme280 # from bme280 i2c = I2C(0, I2C.MASTER, baudrate=100000) i2c.scan() #i2c = machine.I2C(0, pins=('GP11', 'GP10')) bme = bme280.BME280(i2c=i2c) pycom.heartbeat(False) temp = BME280.temperature() humid = BME280.humidity() press = BME280.pressure() alti = BME280.altitude() #for cycles in range(10): # stop after 10 cycles while(true): print(temp) # read temperature time.sleep(2) print(humid) # read humidity time.sleep(2) print(press) # read Pressure time.sleep(2) print(alti) # read altitude time.sleep(2) -
@ledbelly2142 Try following the line of logic I tried in the python REPL: import, instantiate, and initialize:
>>> from machine import I2C >>> import bme280 >>> i2c = I2C(0, I2C.MASTER, baudrate=100000) >>> bme = bme280.BME280(i2c=i2c)See where that takes you.
The original problem I ran into and ultimate fixed was that the 8- and 16-bit writes needed the value to be written to be a bytearray, not the raw value. Beyond that, all I added was a wrapper for altitude.
-
For me, the issue comes up from :
bme = bme280.BME280(i2c=i2c)Thats where I get the errors indicating an I2C bus error.
I SDA on pin 9 and SCL on pin 10.
Could it be a bad sensor?
So I unplugged the BME280 sensor and got the same error.
-
@ledbelly2142 It's possible that it's a bad sensor. Do you have another one to try? You might also check to make sure that i2c.scan() is returning the same address that is used in the BME280 library. If it isn't, you'll have to change the address in the library.
-
@Butch
That looks to be it. The I2C address was 77, not 76... weird. I did not think to check the I2C address.Thanks!
-
Hello Everyone,
I'm using LoPy and I've got the similar type of error as @binux got.I'm getting the following error:

This is my code:

Please guide me solving this!
Thank You.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login