Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, an initiative of Stroud Water Research Center designed to help people advance knowledge and stewardship of fresh water.
New to EnviroDIY? Start here

I2C and power management

Home Forums Mayfly Data Logger I2C and power management

Viewing 6 reply threads
  • Author
    • #15152
      Matt Barney

        If I understand correctly, you cannot set the Mayfly’s I2C Grove port jumper to “switched 3V3” if you’re using it to communicate with a connected I2C device. According to the datasheets and other documentation I’ve read, most (all?) I2C devices have pullup resistors on their SDA and SCL lines, which these two posts suggest that having the Mayfly switch off I2C power during sleep causes the Wire library to enter an infinite loop. Do I have that correct?
        In my circuit, my Mayfly is talking to an external ADC over I2C. With the jumper set for continuous power, it works properly. With it set to switched, the Mayfly locks up when it calls rtc.begin(), immediately after this trace:

        My goal is to minimize power consumption. If I set the jumper to continuous 3V3, I’m measuring 0.08mA draw on each of the SCL and SDA lines while the Mayfly is in sleep mode. That may or may not be tolerable on my power budget; I’ll know more when I acquire a coulomb counter to monitor overall power usage. I may also try this I2C isolator between the Mayfly and ADC. This page in the ModularSensors manual suggests it might help.

        I’m interested in anyone’s experience with I2C and power management, as well as any helpful links.

        Trout Unlimited

      • #15155

          Hi @mbarney  I have come across the I2C issue, and trying to remember what I did, or solution. There was an update that  could fix it, but of course that is a fork.

          It might have been that a wrongly soldered I2C for a humidity device caused the problem for me. Arduino paradigm is typically normal use cases.

          The Mayfly 0.5b has pullups R8 & 10 of 2K.  The ADS1115 board has its own pulls up of 10K.


          The ADS1115 digital inputs are specified for 0-5.5V, which I think means they won’t take any current when turned off V=0. However the  boards pull down Rs would likely interfere with the operation of the pull ups R8&10

          So I wonder if desoldering the  ADS115 boards I2C pull-ups would make a difference. Just a thought.

          I recently used an LTC2942 directly connected on  the Mayfly I2C no pullups, it is similarly specified on inputs 0-6V.  I had no problem communicating on the I2C.


        • #15158
          Matt Barney

            Hi Neil,

            Thanks for sharing your experience. It’s unclear to me the intent of the Switched 3V3 jumper on the Mayfly I2C port; it appears that it cannot be used in the Switched position with peripherals that pull up the I2C lines (which most seem to do) because the Wire library locks up.

            I’m also doing some testing with power consumption and hope to share those results here soon.


          • #15159
            Shannon Hicks

              The jumper for selecting whether the I2C grove port is constantly powered or switched powered was not intended to allow the user to turn off I2C devices on that Grove port.  I designed the board that way because I wanted to give users at 2 separate Grove ports that could be powered either continuously or switched, because the other 4 Grove ports only give you the option of 3v-switched or 5v-switched.  To avoid confusion, I probably should have only allowed people to choose switched power on the D4-5 Grove port and made the I2C Grove port be always on, but on earlier versions of the board, I was using a sketch that turned on and off the power to the I2C Grove jack because of a certain peripheral I was using on that jack.   So the jumper is basically a relic from an earlier iteration of the Mayfly that has limited functionality to most people, but it’s there if you need it for a specific reason.  Almost all users will leave it in the default 3.3v constant position.

            • #15160
              Matt Barney

                Ah, got it! That makes total sense to me know. Thanks @shicks !


              • #15161

                  Be interested to hear about the power measurements you make and tradeoffs in power management.

                  I’m including a Vbat/Coloumb counter monitor with an RS485 wingboard and optionally routing power from the LionBat. It uses the switched 3V3 and the switched 5V – but paying attention to having compatible Ioff when switched off.. https://github.com/neilh10/SensorModbusMaster/blob/release1/hardware/knh002-MayflyWingShield/rev4/knh002r4_rs485schematic.pdf

                • #15165
                  Sara Damiano

                    I’m sorry I’m late to this.  But @mbarney the problem with turning off power to I2C devices isn’t universal.  It depends on how your external I2C device is wired.  If the SCL and SDA of your external device are directly pulled up to the incoming Vcc, then when you turn off the switched power, suddenly the system SCL and SDA will be pulled *down* to ground.  I2C lines are supposed to be pulled up, per protocol.  And there’s a bug in the Arduino Wire library that causes an infinite loop if wires are pulled down.  So everything freezes.

                    I think a lot of (especially inexpensive) sensors do connect the SCL/SDA to incoming voltage without any isolation.  I know the Atlas circuits all do and it seems like your ADC does as well.  But I’ve seen other I2C devices that work fine with the Mayfly switched power going off – I think the Bosch BME280 and INA291’s I played with, but I’m not positive which others.  I’m not sure if in those cases the breakouts I had were actually isolated or if it was just luck and resistor magic that the let the internal pull ups on the Mayfly’s I2C lines overpower the pull down when power went out.  I suspect the latter.

                    In theory, the I2C isolation should work.  But I haven’t ever actually bought an isolator myself to test.

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.