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

    I2C unstable

    Scheduled Pinned Locked Moved LoPy
    23 Posts 4 Posters 171 Views 4 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.
    • robert-hhR Offline
      robert-hh @Steven Boonstoppel
      last edited by

      @Steven-Boonstoppel That's strange. scan() is stateless. The only difference I see in the code is by the I2C ID, being <2 or >= 2. Which I2C device do you use?

      S 1 Reply Last reply Reply Quote 0
      • S Offline
        Steven Boonstoppel @robert-hh
        last edited by

        @robert-hh I am sorry - I don't understand what you mean by I2C ID being <2 or >=2.
        I am using LoPy4's default I2C(0) as master at 100 kHz, using pins 9 and 10.

        J robert-hhR 2 Replies Last reply Reply Quote 0
        • J Offline
          jcaron @Steven Boonstoppel
          last edited by

          @Steven-Boonstoppel Is there any other code running on the LoPy which could use I2C and change the I2C device configuration (pins, etc.)?

          For instance if you have code to handle stuff for the PySense/PyTrack/PyScan (to detect their presence for instance) it would use I2C device 0 with pins P22/P21 rather than the default 9 and 10.

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

            @Steven-Boonstoppel So the ID is 0.

            1 Reply Last reply Reply Quote 0
            • S Offline
              Steven Boonstoppel @jcaron
              last edited by

              @jcaron nope, nothing. Full code is available at https://github.com/StevenCellist/MJLO/tree/main/software.

              J 1 Reply Last reply Reply Quote 0
              • J Offline
                jcaron @Steven Boonstoppel
                last edited by

                @Steven-Boonstoppel Is Pybytes disabled? How are you powering the board? Maybe you have a current spike related to all the sensors starting up at the same time? Monitoring input current and voltage during the awake cycle may be interesting.

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  Steven Boonstoppel @jcaron
                  last edited by

                  @jcaron Pybytes is disabled, powering over USB (tried battery and both as well). Current spike happens when the voltage regulator to SDS011 and MQ135 is enabled which happens after all I2C sensors have been used. Until then the regulator is in shutdown mode.

                  J 1 Reply Last reply Reply Quote 0
                  • J Offline
                    jcaron @Steven Boonstoppel
                    last edited by

                    @Steven-Boonstoppel what’s the max total current used? What’s the USB power source? Is the USB cable adequate? What kind of battery?

                    Just trying to eliminate a possibility…

                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      Steven Boonstoppel @jcaron
                      last edited by Steven Boonstoppel

                      @jcaron during I2C activity below 150 mA, when enabling the voltage regulator after that there's a minimal peak up to 1A for a few milliseconds and then about 500 mA. USB cable is of great quality and has never been a cause for troubles. Power source is my laptop during these debug sessions. Battery is a 26650 Keeppower 5200mAh Li-ion.

                      J 1 Reply Last reply Reply Quote 0
                      • J Offline
                        jcaron @Steven Boonstoppel
                        last edited by

                        @Steven-Boonstoppel have you confirmed in your testing if the culprit is the LoPy or the expansion board (or the breadboard)?

                        Can you confirm the voltage at idle on the two lines? Possibly at different places along the bus (I.e. at each of the devices).

                        BTW, it the physical layout actually close to a bus or closer to a star?

                        Are all devices powered at the same voltage?

                        S 1 Reply Last reply Reply Quote 0
                        • S Offline
                          Steven Boonstoppel @jcaron
                          last edited by

                          @jcaron I have fiddled around more and more using your questions and came to this conclusion: one of the solder points on the SSD1306 was not completely right. This mostly manifested when cables were bent differently, but must have also thrown problems when the bus was being used for other sensors somehow. The exact reason as to why i2c.scan() had an extremely high correlation with the display working - I don't know. Electricity is weird.

                          Other nodes that had I2C problems also suffered mostly from badly soldered contact points, and it seems like all problems have been resolved now. Thanks for the patience and questions as it ultimately led me to the real culprit.

                          Case closed - lesson learned: always check your contact points even if it works.

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

                          Pycom on Twitter

                          Pycom