SiPy and BME280



  • I'm trying to get some value from my BME280 sensor, but, using 2 different libraries, I have problems at startup:

    With https://github.com/catdog2/mpy_bme280_esp8266/blob/master/bme280.py
    I have:

    Traceback (most recent call last):
    File "main.py", line 7, in <module>
    File "/flash/lib/bme280.py", line 74, in __init__
    OSError: I2C bus error
    

    which matches with the following code in the library;

    dig_88_a1 = self.i2c.readfrom_mem(self.address, 0x88, 26)
    

    In an other way, with https://bitbucket.org/oscarBravo/wipy_bme280/src/7c03d16f48154a55a9c09af65049b0f03ef6c005/bme280.py library, I have:

    Traceback (most recent call last):
    File "main.py", line 7, in <module>
    File "/flash/lib/bme280.py", line 185, in __init__
    File "/flash/lib/bme280.py", line 191, in _load_calibration
    File "/flash/lib/bme280.py", line 151, in readU16LE
    File "/fl.MicroPython v1.8.6-607-g9c8a0e9e on 2017-05-01; SiPy with ESP32
    

    Any ideas on how to fix one of these two problems, to get my BME280 up and running?



  • @robert-hh said in SiPy and BME280:

    i2c = I2C(0, I2C.MASTER, pins=(Pin("G9"), Pin("G10")))

    Thank you soooo much, correct syntax for me is:

    i2c = I2C(0, I2C.MASTER, pins=("G9", "G10"))
    

    and thanks @bucknall for the library ;)



  • @adrien3d Try fully specifying the I2C, like:

    i2c = I2C(0, I2C.MASTER, pins=(Pin("G9"), Pin("G10")))

    at least at my LoPy i then see data & clock at G9 and G10



  • I've tried with 2 different BME280 modules, and also with the new library, always the same error at readU16.
    Now at the line 103 with the library provided by @bucknall
    These modules are working well on an Arduino Micro.
    When I'm trying an I2C scan, nothing is returned with the print.

    When I'm putting my Saleae Logic analyser, nothing is happening on both SDA and SCL lines.

    I'm trying to run the followning code:

    import machine
    from machine import Timer
    from machine import I2C
    import bme280
    
    i2c = I2C()
    print(i2c.scan())
    bme = bme280.BME280(i2c=i2c)
    
    print(bme.temperature, bme.pressure, bme.humidity)
    

    And my BME280 is hooked up to G9 (SDA) and G10 (SCL), as said in the documentation.
    I've also tried an other I2C device with the same pin connection, and same result, nothing with the print(i2c.scan), nothing on the Saleae.

    Is there's anything else I can try ?
    Thanks


  • administrators

    You might also have better luck with this library as it's already been written for Pycom devices, https://github.com/ButchAnton/LoPy_BME280.



  • @adrien3d That looks like a connection error. Please check the connection to the device, especially

    • whether you have pull-up resistors in place,
    • the right GPIO's connected (SCL & SDA swapped?)
    • the right supply voltage of 3.3 V
    • CS high (for I2C) connected to VDD
    • right I2c address. What do you see if you just issue an i2c.scan(), once the i2c object is created?

Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.