Wipy 2.0 and BME280 sensor
-
Hello!
Was anybody able to use I2C BME280 sensor? It works flawlessly on Wipy 1.0 using a driver from Paul Cunnane (https://bitbucket.org/oscarBravo/wipy_bme280), but I get strange errors on Wipy 2.0:
>>> from machine import I2C >>> import bme280 >>> i2c = I2C(0, I2C.MASTER, baudrate=100000) >>> bme = bme280.BME280(i2c=i2c) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/flash/lib/bme280.py", line 186, in __init__ File "/flash/lib/bme280.py", line 106, in write8 TypeError: object with buffer protocol required
It looks like this operation fails:
i2c.writeto_mem(0x76, 0xF4, 0x3F)
I can see the device on I2C bus, so the wiring should be OK. I also have a HD44780 display with PCF8574 backpack connected to I2C bus and it works.
I am using the latest firmware 0.9.4b1.
One last thing - I am connected to Wipy via telnet (Putty) and the REPL is almost unusable. After few lines of code it hangs or key presses start to generate weird characters.
Michal
-
Hi, It works with my Wipy 2.0, i think the only change i made was:
def write8(self, register, value):
"""Write an 8-bit value to the specified register."""
value = value & 0xFF
self._i2c.writeto_mem(self._address, register, bytes([value]))
-
Hi michal,
Also try to use the bme280 sensor ( working with the wipy1 ok! ) but have the same errors with the wipy 2!
Had you resolve this ? If yes could you tell me how ?Best regards
Jiemde
-
@Baruch1966
Hi!Here is the repository with driver from Dave Hylands:
https://github.com/dhylands/python_lcdHere is the sample code:
from machine import I2C from i2c_lcd import I2cLcd i2c = I2C(0, I2C.MASTER, baudrate=100000) lcd = I2cLcd(i2c, 0x27, 4, 20) lcd.putstr("It Works!")
I use this display: http://www.santy.cz/zobrazovace-c7/lcd-2004-blue-i2c-i9/
and this level converter: http://www.santy.cz/moduly-omezovacu-a-prevodniku-c34/i2c-uart-level-konvertor-3v-5v-4way-i223/Michal
-
@michal said in Wipy 2.0 and BME280 sensor:
I can see the device on I2C bus, so the wiring should be OK. I also have a HD44780 display with PCF8574 backpack connected to I2C bus and it works.
I am using the latest firmware 0.9.4b1.Can you share a example code with PCF8574?
-
Hi Michal,
Thanks for the quick feedback, glad that it works now :-)
I got confused with I2C Quick Reference (https://docs.pycom.io/wipy2/2wipy/quickref.html#i2c-bus) which is the same for both versions of Wipy.
It's our fault, we need to make the API accept an integer as well. Will be fixed shortly.
Cheers,
Daniel
-
Hi Daniel!
I can confirm, that it works with bytes object:-)
>>> from machine import I2C >>> import bme280 >>> i2c = I2C(0, I2C.MASTER, baudrate=100000) >>> bme = bme280.BME280(i2c=i2c) >>> print(bme.temperature, bme.pressure, bme.humidity) 24.07C 967.63hPa 64.16%
I got confused with I2C Quick Reference (https://docs.pycom.io/wipy2/2wipy/quickref.html#i2c-bus) which is the same for both versions of Wipy.
Thanks a lot for your help!
Michal
-
@michal when you do the
i2c.scan()
are you able to see the sensor connected?TypeError: object with buffer protocol required
This error occurs because the function expects a
bytes
object and you are trying to send an integer. Could you try with:i2c.writeto_mem(0x76, 0xF4, bytes([0x3F]))
?
Obviously we should make the drivers fully compatible with the old ones. We'll definitely fix it, but please try the workaround above to confirm the problem. Thanks.
Cheers,
Daniel