Welcome to EnviroDIY, a community for do-it-yourself environmental science and monitoring. EnviroDIY is part of WikiWatershed, a web toolkit designed to help citizens, conservation practitioners, municipal decision-makers, researchers, educators, and students advance knowledge and stewardship of fresh water. New to EnviroDIY? Start here

Testing power consumption

Home Forums Mayfly Data Logger Testing power consumption

Viewing 13 reply threads
  • Author
    Posts
    • #15247
      Matt Barney
      Participant

      Hi all,

      I’ve been doing some testing to measure the amount of power consumed by my Mayfly during various modes, and thought I’d share my results here. I’m interested in any and all feedback from the community.
      I’m using the SparkFun coulomb counter that I’ve plugged into a spare Mayfly, which reports via USB to my laptop. Its set up to sample the current flow between a LiPo and my subject Mayfly with LTE modem and a sensor attached. These are the numbers I’ve come up with so far:

      Turner Turbidity Plus sensor – due to the demands of its wiper, this was my motivation for pursuing power measurements. I wanted to know how often I could run the wiper without draining the battery too quickly. Each wiper cycle takes about 8 seconds, during which it averages 109 mA.

      During sleep, the Mayfly is consuming 6.7mA.

      During LTE modem usage, I’m seeing 35 mA average during each modem-on, transmit data, modem-off cycle, which takes about 50 seconds per sampling interval.

      Putting all of these together, and with a hypothetical 15-minute sampling interval, I’ve calculated that my circuit should consume 224 milliamp-hours per day. I need to do a bit more integration testing to try to confirm this number.

      -Matt

    • #15248
      Shannon Hicks
      Moderator

      It sounds like your Mayfly is not actually going to sleep.  An idle Mayfly will use around 6.5mA, and a sleeping Mayfly will use between 0.25mA and 0.5mA, depending on whether you’ve got a microSD card in the slot and the type of card.  Here’s the power consumption results from Mayfly current tests:

      Mayfly current when board is powered and idle: 6.5 mA
      Mayfly current when MCU put to sleep and no microSD card in socket: 0.27 mA (or 270 uA)
      Mayfly current when asleep with microSD card in the socket: 0.43 mA (or 430 uA)

    • #15252
      neilh
      Participant

      Gosh @shicks that is great to hear.  I wonder would you share how you made the sleep measurements with the microSD present. Any sketches for putting the mega1284 to sleep. Getting to 0.5mA would be fantastic!

      Matt Interesting real data with a coulomb counter. Great stuff.

      My current measurements on 0.28.01 for sleep are 2.5mA . I haven’t got a test setup for other modes at this point, but probably will have in the next couple of weeks.

      For my current measurements I run it only from the battery and put a Adafruit INA219 in series, with a simple driver polling once a second, running on a separate Mayfly and then visually monitor current.

      I’ve put together a spreadsheet for how  power is used. I tend to calculate in mAseconds and then of course 3600mAseconds = 1mAhr.

      Since I’m also wanting to tweak production code, I need debugging. I modified the FTDI cable so that only the processor Tx and the Gnd are connected, and debug output will advertise what state the processor is in. For an FTDI connector –  male to male pins and just snip all pins except critical ones.

      So from the spread sheet, for sampling period 900sec, using Readings 6.5mA@10secs, LTE 35mA@50secs,

      Then for 24 hrs, 96*15minutes

      sleep at 6mAs the calculation is 182mAHrs  close to yours

      sleep at 2.5mA then   104mAhrs

      sleep at 0.5mA  59.6mAhrs   ~ (I want it!)

       

       

    • #15259
      Matt Barney
      Participant

      @shicks Thanks for those details. I wonder whether it could be the turbidity sensor, rather than the Mayfly, that’s actually drawing power, but I wouldn’t have thought it could do that while (or if) the Mayfly is sleeping. A bit more about my circuit:

      I’m powering the Turner from Mayfly’s switched 3V3. The Turner’s analog output is 0-5V, which I’ve connected to an external ADS1115 ADC. The Mayfly’s communicates to the ADC over I2C via a logic level shifter. The Turner also has a digital input to trigger its wiper, and a digital output that signals when the wiper is in its home position.

      I’ve attached a wiring schematic. Does anything jump out that could be leaking current during sleep?


      @neilh20
      Thanks for the feedback, and I’ve got a very similar spreadsheet! I’ve also just received the parts for a FTDI cable to get serial output without supplying power – thanks for your work with this!

      Matt

      Trout Unlimited

    • #15261
      Shannon Hicks
      Moderator

      If the “Switched 3v3” or “Switched 5v” is turned off, then nothing connected to those pins will be drawing power.  But if your Mayfly board is not actually going into deep sleep, then it’s sitting in idle mode instead of actually sleeping, and that’s why it’s drawing 6ma.  Wasn’t there some recent threads about how the I2C device was keeping the board from sleeping properly?

      What’s the reason for having a separate ADC board?  Are you just worried about reading a voltage greater than 3.3v with your Mayfly onboard ADC?  Because if that’s the only reason, then it would be easier to just put a resistor divider on the sensor output and connect the center of it to your Mayfly ‘sADS1115.  If you pick 2 perfectly matched resistors (like 10k) then you simply double the ADS reading to give you the actual sensor voltage.

    • #15264
      neilh
      Participant

      @mbarney an observation, the power is being turned off on the off board ADS1115, but not for the Turner. The ADS1115 Analog inputs are only specified for Vdd+0.3V. If either of the Turners outputs are above this, then it will feed through to the ADS1115 Vdd  Sw5V.  Probably won’t account for what your are seeing.

      I found a I needed to know when in sleep v current consumption, so used the Ttty to know when its in sleep mode, and  to measure the current at that time. (I have Adafruits INA219)

    • #15268
      Matt Barney
      Participant

      @shicks The previous thread about I2C power that I’m aware of was when I learned that the jumper on the I2C grove port needs to remain in the constantly-powered position, otherwise the Wire library crashes, at least with certain sensors, including the Turner.

      I *think* my Mayfly is sleeping: All LEDs switch off, if that means anything. If I connect to USB for serial output (all other testing has been lipo-powered, with no USB connection) and turn on debugging in LoggerBase.h, the traces indicate that it sleeps at the end of sampling:

      On the external ADC: Yes, I used it to accommodate the 5v max from the Turner. I was thinking that this would be more accurate than using a 2/3 voltage divider to drop 5V to ~3.3V. But it sounds like you’re suggesting a 1/1 divider that would simply halve the output voltage, which you would then double in code. FYI, I’m using differential signaling to sense the Turner’s output, to hopefully make it less susceptible to noise.

      @neilh10 Note that the Turner is powered by switched 3V3 from the D10-11 Grove connector, so it should be getting powered off during sleep. Also, since the ADC is powered by 5V, the Turner’s 0-5V outputs will be within Vdd+0.3V.

      -Matt

    • #15269
      neilh
      Participant

      @mbarney the trace looks good for the waking portion. What I see on  my system is that it wakes every minute and then sleeps inbetween.  So if you have it on a 15minute setting it will do above, then sleep/wake 14times. The current can be read when it goes to sleep.

      For the differential case I would think you would have two sets of dividers.  BTW total error is additive. So you can probably match the R, but whatever the error is eg 0.1% then the final error that gets introduced is 0.4% . It may not matter if you are looking for dynamic changes rather than absolute numbers.?

    • #15294
      Matt Barney
      Participant

      Trying to track down and eliminate my my Mayfly’s excessive power draw during sleep, I rebuilt my circuit to use the Mayfly’s onboard ADS1115 via voltage dividers, but got the same results; my sleep current is still around 6 mA. However, I discovered that if I disconnect the Turner’s wiper trigger wire from D10, sleep current drops to around 0.5mA.

      To initiate the Turner’s wiper cycle, you pulse its trigger line low for 50 milliseconds. My TurnerTurbidityPlus class (code below) derives from Sensor, and its setup() method sets the D10 pin high; then when it’s time for a measurement, its wake() function sets D10 low, delays 50 milliseconds, and sets it back to high. Is this code causing the current drain, and how can I eliminate it?

      -Matt

       

    • #15300
      neilh
      Participant

      @mbarney  its a common problem with low power, sleep circuits.

      Just to be clear/restate what the issue is. When in “sleep” mode and powered off, all instrument pins (and actually all other processor pins) need to be set to output low, or input with preferably pull down.

      On power-up, the pins are activated output and set high within 50mS so as to not trigger the wipe.

      On power-down, its a race condition which to do first, and the global control of the power, but with a min 50mS pulse I would think you are safe to make the wiper pin low and hope that the power is turned off within 50mS.

      KellerParent.cpp has ::powerUp() and ::powerDown() which is where I change the pins.

      You are using ::setup() for setting the port direction, which is I think is run only once, so I would think you move the wiper setup to ::powerUp

      Sounds like its coming along, and I’m fascinated that you are getting 0.5mA.

      BTW with my FTDI cable setup, I just found the hardway that the Ftdi Rx pin (tx pin from processor) hadn’t been clipped off and on my stability test station; the 4.4Ah battery mysteriously suddenly drained down in about 3days and then recharged from he solar. It turns out my monitoring PC Win10 did some form of automatic update and then powered down. The FTDI cable  also powered down, including this unclipped Rx pin, that then drained off the battery current.  I only noticed after I had restarted the PC, and the monitoring, and then two days later was checking the results and saw the battery had mysteriously drained down and come back. So the purpose of stability monitoring is check for anomalous behaviour in a secure setting, so I needed to find out what had happened.

    • #15303
      Sara Damiano
      Moderator

      I would do as Neil suggested and make sure the trigger pin for the Turner is set low before sleep.

      We’ve had the same problem with RS485 adapters that pull power through the Tx/Rx lines.  Because the stop bit is high those lines will stay high if you don’t force them low at the end.  It’s kind-of a PITA with the Tx/Rx bits; you have to actually write it setting those low into your loop because ModularSensors doesn’t know anything about the Tx and Rx pins, only the serial stream.

      It could also be that the wiper is causing a whole lot of noise on the line which is keeping the Mayfly awake (acting as a pin-change interrupt).  But I think if that were the case you’d see the going to sleep/waking up lines continuously, not just once a minute.  The once a minute thing is because the alarm on the DS3231 doesn’t allow for every x minutes, just at one exact time or every second, every minute, every hour, etc.  To get it to wake only in 5 minutes (or 15 or whatever your logging interval is) you’d get the current time and then calculate and reset the alarm for 5 minutes in the future each time.  Since the board should only wake for a few ms every minute, it seemed safer to use the every minute alarm than to reset it to a new time each time.

    • #15304
      Matt Barney
      Participant

      Thanks to both of you for your responses! I think I had just figured out the cause of my problem right about the time you were posting them, but needed to continue refining and testing my code before replying.

      What’s working now is:

      1. In the sensor’s setup() function, set trigger pin to an output
      2. at powerUp(), set pin HIGH
      3. at wake(), run the wiper (set pin LOW, wait 50ms, set pin HIGH)
      4. at powerDown(), set pin LOW

      The wiper cycles as expected and sleep current is <0.7mA. The only exception seems to be that when the Mayfly wakes up at the first measurement cycle (not at startup), the wiper doesn’t run as expected. At all subsequent measurement cycles that I’ve watched, the wiper cycles properly.


      @srgdamiano
      Sara, which of the following functions would you recommend as a best practice for where to change the pin value described above, at powerUp and powerDown, or at wake and sleep?


      @neilh20
      That’s funny on the FTDI cable (well, funny in hindsight) – ouch! 🙂

      Best,
      Matt

    • #15345
      Matt Barney
      Participant

      @srgdamiano
      Hi Sara, any advice on the question above, about powerUp/powerDown vs. wake/sleep?

      Matt

    • #15354
      Sara Damiano
      Moderator

      I’d put it in the power up, since it’s supposed to happen right away and setting the pin is nearly instant and won’t slow down other things powering up.

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