sleep mode not working as expected...



  • Hi all

    I have a solar powered node counting pulses on a water meter. Hardware is a ceech board (=pro-mini) which takes care of pv and charging, a RFM69 radio, and a RC+schmitt inverter circuit to do hardware debounce.

    Sketch is a cut down and modified version of the WaterMeterPulseSensor example with flow removed because I have SLEEP_MODE true

    According to the standard wiring diagram, the D100 pin of the RFM69 radio goes to pin 2 of the arduino, so I've set the other interrupt pin 3 for the pulse counting #define DIGITAL_INPUT_SENSOR 3

    And it all works as expected - Except:

    If there is no pulse during the sleep period then it sleeps more-or-less the time I expect, however, if there are pulses, (which it seems to be counting correctly), it seems to wake up at approx 20 sec intervals, totally ignoring whatever I put as the sleep period, eg sleep(90000); or smartSleep(90000);

    This leads me to think there's something going on with my interrupts which is waking it unexpectedly, but because I don't really understand how the mySensors sleep thing works I have no idea how to fix it....

    Thanks

    Richard


  • Mod

    Welcome to the MySensors forum @rmh

    The debug log will show details on what is happening. You can also check the return value from the sleep function to see the reason for waking up.

    Documentation for the sleep function: https://www.mysensors.org/download/sensor_api_20#sleeping



  • @mfalkvidd thanks for the welcome and your prompt reply.

    The log is always showing
    2101803 MCO:SLP:WUP=-1 Node woke-up, reason/IRQ=-1 (-2=not possible, -1=timer, >=0 IRQ)

    So it would appear the 'timer' is doing the waking as I would expect, but since the millis timer is frozen in sleep mode, what timer is this? I kind of imagine it is firing interrupt 1 (pin 3) to wake it up, but my use of the same pin for the counter is interfering with this somehow?

    Thanks

    Richard


  • Mod

    @rmh yes millis is frozen during sleep.
    On the atmega328 (which pro mini is based on), sleep uses the watchdog to keep time. No interrupt is involved.



Suggested Topics

  • 3
  • 2
  • 7
  • 1
  • 6
  • 10

9
Online

11.4k
Users

11.1k
Topics

112.7k
Posts