Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. sleep mode not working as expected...

sleep mode not working as expected...

Scheduled Pinned Locked Moved Development
sleep timepulsecountinterrupts
4 Posts 2 Posters 1.0k Views 2 Watching
  • 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.
  • R Offline
    R Offline
    rmh
    wrote on last edited by
    #1

    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

    mfalkviddM 1 Reply Last reply
    0
    • R rmh

      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

      mfalkviddM Offline
      mfalkviddM Offline
      mfalkvidd
      Mod
      wrote on last edited by mfalkvidd
      #2

      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

      R 1 Reply Last reply
      0
      • mfalkviddM mfalkvidd

        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

        R Offline
        R Offline
        rmh
        wrote on last edited by
        #3

        @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

        mfalkviddM 1 Reply Last reply
        0
        • R rmh

          @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

          mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          11

          Online

          11.7k

          Users

          11.2k

          Topics

          113.0k

          Posts


          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • MySensors
          • OpenHardware.io
          • Categories
          • Recent
          • Tags
          • Popular