Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    SiPy and BME280

    Scheduled Pinned Locked Moved SiPy
    bme280sipyi2ci2c bus error
    6 Posts 3 Posters 2.5k Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      adrien3d
      last edited by

      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-hhR 1 Reply Last reply Reply Quote 0
      • robert-hhR Offline
        robert-hh @adrien3d
        last edited by robert-hh

        @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?
        1 Reply Last reply Reply Quote 0
        • B Offline
          bucknall
          last edited by

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

          Developer Evangelist - Pycom

          1 Reply Last reply Reply Quote 0
          • A Offline
            adrien3d
            last edited by adrien3d

            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

            robert-hhR 1 Reply Last reply Reply Quote 0
            • robert-hhR Offline
              robert-hh @adrien3d
              last edited by robert-hh

              @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

              A 1 Reply Last reply Reply Quote 0
              • A Offline
                adrien3d @robert-hh
                last edited by adrien3d

                @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 ;)

                1 Reply Last reply Reply Quote 1

                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
                • 1 / 1
                • First post
                  Last post

                Pycom on Twitter

                Pycom