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

Sleep Mode Low Power.

Home Forums Mayfly Data Logger Sleep Mode Low Power.


Viewing 1 reply thread
  • Author
    • #2056


        I was curious how power efficient that Mayfly sleep code was. Using it I noticed that it has to wake up every minute and update the current minute. So say if I was wanting it to wake up every 15 min like if I had a few mayflys running at the same time and wanted to update them on every 0, 15, 30, and 45 of the hour. My main question is how would I put these into deep sleep, uninterrupted for those 15 min and wake up and take its readings. If you or anyone on this forum has any suggestions I am open to suggestions. I played with the Mayfly sleep code provided and it does just that waking up for example 9:00, 9:15, 9:30… I’m just trying to figure out how to do it without waking up the Mayfly every minute.

        Thank you!

      • #2058
        Shannon Hicks

          There are several different methods you can use to wake a sleeping processor using a realtime clock. The example I posted uses the method of triggering an interrupt pin on the processor by using a quick pulse that the RTC puts out every minute. By doing this, the processor can wake up each minute and then it’s up to the user’s code to examine the current time and either do something or go back to sleep and wait another minute. I used this example since it’s the easiest for other people to choose whether they want to do something every minute or every 5 minutes or any other interval. You could certainly wake the processor only at select times by using the alarm feature of the RTC. It looks at the current time (3:30 for example), then adds a specific interval (15 minutes) to determine what time the next wakeup event should be (3:45), then puts the processor to sleep and it won’t wake up again until that interrupt at 3:45. There are some other Arduino libraries that you can use for interacting with the RTC and setting alarms instead of using the Sodaq_DS3231 library that I used in that example. Just search the web for example sketches for setting alarms on the DS3231. Keep in mind that the Mayfly board’s default pin is A7 for reading the square wave alarm output from the DS3231, which is why you also need the Sodaq_PcInt library (this library allows other pins to be used as interrupts besides the board’s regular hardware interrupts of D0, D1, and D10). If you really want to use a hardware interrupt instead of the pin change interrupt, you can modify the solder jumper SJ1 on the back of Mayfly boards version 0.4 and greater by cutting the trace to the A7 pad and solder jumpering to the D10 pad.

          But I prefer to just wake it up every minute since it’s simpler for my purposes. When using this method, the processor is really only awake for a few milliseconds each minute, and it’s so quick that you can’t see it when looking at the board’s current draw on an ammeter. So waking a Mayfly for a few milliseconds each minute really has no greater draw on the overall power consumption than than letting it sleep continuously and only waking at longer intervals.

      Viewing 1 reply thread
      • You must be logged in to reply to this topic.