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. Interrupt and sleep

Interrupt and sleep

Scheduled Pinned Locked Moved Development
26 Posts 7 Posters 10.6k Views 6 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.
  • gohanG Offline
    gohanG Offline
    gohan
    Mod
    wrote on last edited by
    #21

    My mega goes to sleep for the time specified, but it doesn't wake up when pir is triggered

    1 Reply Last reply
    0
    • J JoergP

      @Efflon I'm not sure what exactly you mean - do you refer to my code? In that case this is a quick and dirty try - I'll send at every pin change and at timeout the input values ...

      EfflonE Offline
      EfflonE Offline
      Efflon
      wrote on last edited by Efflon
      #22

      @JoergP Sorry, what I meant was regarding the versions you were using to get your sensor to work. I've been fighting to get interrupts to work for a day and your suggestion helped.
      Now it's just that going out of sleep triggers the PIR, then it goes for sleep and wakes up immediately and then finally goes to sleep ... gahh

      Tripped: 0
      13207 MCO:SLP:MS=30000,SMS=0,I1=1,M1=3,I2=255,M2=255
      13213 MCO:SLP:TPD
      13217 MCO:SLP:WUP=-1
      interrupt: -1
      Tripped: 0
      Tripped: 1
      Tripped: 1
      Tripped: 1
      Tripped: 1
      interrupt: -1
      Tripped: 1
      Tripped: 0
      Tripped: 0
      Tripped: 0
      Tripped: 0
      14024 MCO:SLP:MS=30000,SMS=0,I1=1,M1=3,I2=255,M2=255
      14032 MCO:SLP:TPD
      14034 MCO:SLP:WUP=1
      interrupt: 1
      Tripped: 0
      Tripped: 0
      Tripped: 0
      Tripped: 0
      Tripped: 0
      14440 MCO:SLP:MS=30000,SMS=0,I1=1,M1=3,I2=255,M2=255
      14446 MCO:SLP:TPD```
      1 Reply Last reply
      0
      • J Offline
        J Offline
        JoergP
        wrote on last edited by
        #23

        hmmmm .... I'm not so familiar with the arduino build process - I guess that Interrupt Request registers are not reset correctly, but never did that manual with Arduino

        I use following board setting

        AAnode1.name=AA sensor node (1MHz int)
        
        AAnode1.upload.tool=avrdude
        AAnode1.upload.protocol=arduino
        AAnode1.upload.maximum_size=32256
        AAnode1.upload.speed=9600
        AAnode1.bootloader.tool=avrdude
        AAnode1.bootloader.low_fuses=0x62
        AAnode1.bootloader.high_fuses=0xde
        AAnode1.bootloader.extended_fuses=0x07
        AAnode1.bootloader.path=optiboot_v50
        AAnode1.bootloader.unlock_bits=0x3F
        AAnode1.bootloader.lock_bits=0x2F
        AAnode1.build.mcu=atmega328p
        AAnode1.build.f_cpu=1000000L
        AAnode1.build.core=arduino
        AAnode1.build.variant=standard
        AAnode1.build.board=AVR_AANODE_1MHz
        

        I guess the xxx.build.xxx settings are of interest - do you use the same or do you have different?

        EfflonE 1 Reply Last reply
        0
        • J JoergP

          hmmmm .... I'm not so familiar with the arduino build process - I guess that Interrupt Request registers are not reset correctly, but never did that manual with Arduino

          I use following board setting

          AAnode1.name=AA sensor node (1MHz int)
          
          AAnode1.upload.tool=avrdude
          AAnode1.upload.protocol=arduino
          AAnode1.upload.maximum_size=32256
          AAnode1.upload.speed=9600
          AAnode1.bootloader.tool=avrdude
          AAnode1.bootloader.low_fuses=0x62
          AAnode1.bootloader.high_fuses=0xde
          AAnode1.bootloader.extended_fuses=0x07
          AAnode1.bootloader.path=optiboot_v50
          AAnode1.bootloader.unlock_bits=0x3F
          AAnode1.bootloader.lock_bits=0x2F
          AAnode1.build.mcu=atmega328p
          AAnode1.build.f_cpu=1000000L
          AAnode1.build.core=arduino
          AAnode1.build.variant=standard
          AAnode1.build.board=AVR_AANODE_1MHz
          

          I guess the xxx.build.xxx settings are of interest - do you use the same or do you have different?

          EfflonE Offline
          EfflonE Offline
          Efflon
          wrote on last edited by
          #24

          @JoergP Don't know. I just select "mini pro" from within Arduino IDE.
          I'll create a new trouble shooting topic with my problem since this is going out of topic.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giovaFr
            wrote on last edited by giovaFr
            #25

            my 2 cents :

            Why are you doing a sleep into setup method?
            why not using wait method instead?

            I understand that you'd like switch in sleep mode after a loop, but this doesnt sounds natural to do this during "initializing" step.

            if you remove sleep from setup, do you still have your issues?

            moreover, i've read somewhere that smartsleep methode gives messages time to be sent before sleeping (i'm not absolutly sure about this, i cannot find anymore the place where i've read that).

            bool smartSleep(uint8_t interrupt, uint8_t mode, unsigned long ms=0)
            @params:
            • interrupt: Pin that should trigger the wakeup
            • mode: RISING, FALLING, CHANGE
            • ms: Number of milliseconds to sleep or 0 to sleep forever
            @return: True if wake up was triggered by pin change and false means timer woke it up.

            at last : you can wait for an aknownledge, it'll be slower but you'll be sure that message is sent before going to the next line of code...

            i did not test it yet, but it would be something like this :

            bool ack = true;
            send(myMsg.set(avalue), ack );
            if(!wait(2000,V_TEMP , mymsg.getType());)
                 Serial.println("timeout after 2 secs");
            
            gohanG 1 Reply Last reply
            0
            • G giovaFr

              my 2 cents :

              Why are you doing a sleep into setup method?
              why not using wait method instead?

              I understand that you'd like switch in sleep mode after a loop, but this doesnt sounds natural to do this during "initializing" step.

              if you remove sleep from setup, do you still have your issues?

              moreover, i've read somewhere that smartsleep methode gives messages time to be sent before sleeping (i'm not absolutly sure about this, i cannot find anymore the place where i've read that).

              bool smartSleep(uint8_t interrupt, uint8_t mode, unsigned long ms=0)
              @params:
              • interrupt: Pin that should trigger the wakeup
              • mode: RISING, FALLING, CHANGE
              • ms: Number of milliseconds to sleep or 0 to sleep forever
              @return: True if wake up was triggered by pin change and false means timer woke it up.

              at last : you can wait for an aknownledge, it'll be slower but you'll be sure that message is sent before going to the next line of code...

              i did not test it yet, but it would be something like this :

              bool ack = true;
              send(myMsg.set(avalue), ack );
              if(!wait(2000,V_TEMP , mymsg.getType());)
                   Serial.println("timeout after 2 secs");
              
              gohanG Offline
              gohanG Offline
              gohan
              Mod
              wrote on last edited by
              #26

              @giovaFr
              if you are referring to

              sleep(dht.getMinimumSamplingPeriod());

              that was straight from the example of the DHT11 sensor.

              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.1k

              Posts


              Copyright 2025 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