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. Bug Reports
  3. MySensor collides with LowPower's SLEEP_ enum

MySensor collides with LowPower's SLEEP_ enum

Scheduled Pinned Locked Moved Bug Reports
lowpower
10 Posts 5 Posters 4.8k Views 3 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.
  • S Offline
    S Offline
    SiLeX
    wrote on last edited by
    #1

    I am trying to PowerDown my node and I want the nRF24L01+ to wake up my Arduino when data comes in (INTR goes LOW).
    As I could not find any way to use a MySensors function to sleep on the Arduino, I wanted to use LowPower lib's functionality for this.

    MyHwATMega328.h:82:6: error: multiple definition of 'enum period_t'
    LowPower.h:4:6: error: previous definition here
    

    Both of your header files contain the exact same enum:

    enum period_t
    {
    	SLEEP_15Ms,
    	SLEEP_30MS,
    	SLEEP_60MS,
    	SLEEP_120MS,
    	SLEEP_250MS,
    	SLEEP_500MS,
    	SLEEP_1S,
    	SLEEP_2S,
    	SLEEP_4S,
    	SLEEP_8S,
    	SLEEP_FOREVER
    };
    

    My simple code is:

    	attachInterrupt(digitalPinToInterrupt(2), interrupt, LOW);
    	LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    	detachInterrupt(digitalPinToInterrupt(2));
    
    	gw.process();
    

    This opens up two questions for me:

    • Is there a MySensors function to PowerDown the node without powering down the radio?
    • Is there a way to force to use the LowPower enum. Tried it with (LowPower::period_t)SLEEP_FOREVER cast but it was not accepted as namespace.

    Thanks in advance

    BulldogLowellB 1 Reply Last reply
    0
    • S SiLeX

      I am trying to PowerDown my node and I want the nRF24L01+ to wake up my Arduino when data comes in (INTR goes LOW).
      As I could not find any way to use a MySensors function to sleep on the Arduino, I wanted to use LowPower lib's functionality for this.

      MyHwATMega328.h:82:6: error: multiple definition of 'enum period_t'
      LowPower.h:4:6: error: previous definition here
      

      Both of your header files contain the exact same enum:

      enum period_t
      {
      	SLEEP_15Ms,
      	SLEEP_30MS,
      	SLEEP_60MS,
      	SLEEP_120MS,
      	SLEEP_250MS,
      	SLEEP_500MS,
      	SLEEP_1S,
      	SLEEP_2S,
      	SLEEP_4S,
      	SLEEP_8S,
      	SLEEP_FOREVER
      };
      

      My simple code is:

      	attachInterrupt(digitalPinToInterrupt(2), interrupt, LOW);
      	LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
      	detachInterrupt(digitalPinToInterrupt(2));
      
      	gw.process();
      

      This opens up two questions for me:

      • Is there a MySensors function to PowerDown the node without powering down the radio?
      • Is there a way to force to use the LowPower enum. Tried it with (LowPower::period_t)SLEEP_FOREVER cast but it was not accepted as namespace.

      Thanks in advance

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #2

      @SiLeX

      have you checked out the API?

      S 1 Reply Last reply
      0
      • BulldogLowellB BulldogLowell

        @SiLeX

        have you checked out the API?

        S Offline
        S Offline
        SiLeX
        wrote on last edited by
        #3

        @BulldogLowell Of course.

        sleep() including all overloads always put the Arduino and the radio to sleep, which is not desired. I only want to sleep the Arduino and have it wake up when INTR goes LOW.

        1 Reply Last reply
        0
        • rvendrameR Offline
          rvendrameR Offline
          rvendrame
          Hero Member
          wrote on last edited by
          #4

          Adding my two cents, if you keep radio always on and only sleep arduino, at the end of day you didn't save too much, as the radio is usually the most power consuming in the equation...

          If you plan to run on batteries definitely sleep radio if you want to extend runtime. You might wake up both arduino+radio from time to time and use gw.request() to retrieve the latest status of anything you might need.

          Home Assistant / Vera Plus UI7
          ESP8266 GW + mySensors 2.3.2
          Alexa / Google Home

          S 1 Reply Last reply
          0
          • rvendrameR rvendrame

            Adding my two cents, if you keep radio always on and only sleep arduino, at the end of day you didn't save too much, as the radio is usually the most power consuming in the equation...

            If you plan to run on batteries definitely sleep radio if you want to extend runtime. You might wake up both arduino+radio from time to time and use gw.request() to retrieve the latest status of anything you might need.

            S Offline
            S Offline
            SiLeX
            wrote on last edited by
            #5

            @rvendrame said:

            Adding my two cents, if you keep radio always on and only sleep arduino, at the end of day you didn't save too much, as the radio is usually the most power consuming in the equation...

            Thanks for you answer. I am receiving IR commands over MySensors and need to react on them (with IRLib) in realtime. This is a big, 5V Arduino Uno. Interestingly it saves a lot of power if I PowerDown the Arduino. I did this with the RF24Network library in the past and it saved a lot.

            Maybe the temporary way could be waking up and requesting every 2 seconds or so. But I would really like to use the LowPower lib again.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              Lemme
              wrote on last edited by
              #6

              I do not know if this is related, but I get the same error - "error: multiple definition of 'enum period_t'" when I try to compile the LowPower and MySensor library.

              I have not yet been able to get a sensor going using the sleep mode. Is this a known problem? Is there a fix to this problem?

              Br
              Lemme

              1 Reply Last reply
              0
              • OitzuO Offline
                OitzuO Offline
                Oitzu
                wrote on last edited by
                #7

                Hm.. How much Power actually Safe this? Numbers would bei interesting.
                My 2cents: afaik the low Power lib is included in the mysensors lib. This results in the Double decleration of the enum. Try to Use the already included low Power lib.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  Lemme
                  wrote on last edited by
                  #8

                  Arhh - that explains it, thanks. I will try to play with it when I come home.
                  Wondering if it is still limited to 8 seconds. Or if I have to do some sort of loop/counting to make it sleep for several minutes or more.

                  S 1 Reply Last reply
                  0
                  • L Lemme

                    Arhh - that explains it, thanks. I will try to play with it when I come home.
                    Wondering if it is still limited to 8 seconds. Or if I have to do some sort of loop/counting to make it sleep for several minutes or more.

                    S Offline
                    S Offline
                    SiLeX
                    wrote on last edited by
                    #9

                    @Lemme said:

                    Wondering if it is still limited to 8 seconds. Or if I have to do some sort of loop/counting to make it sleep for several minutes or more

                    If you need longer intervals, you should use SLEEP_FOREVER and attach a Timer interrupt beforehand. Pseudocode would look like this:

                    loop(){
                    ...
                    attachInterrupt(Timer1, 600000, dummy_function) // wake up every 10 minutes
                    gw.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF)
                    detachInterrupt(Timer1) // disable so we don't interrupt ourselves
                    
                    .... do things, send data, and so on ......
                    
                    }
                    
                    void dummy_function(){
                    // this does nothing, but interrupt need something to call, so we make a dummy function
                    // this will return immediately to the loop() again
                    }
                    

                    This is best-practise for things that are not real-time-based (like encoder wheels). Using the normal loop makes it possible to use all the millis() and other time-based functions you wouldn't be able to use withing interrupt calls.

                    By the way - in YOUR case, when you don't want to receive anything on the sensor node while sleeping, using the MySensors Sleep function is perfectly fine. This thread focuses on using it with other interrupts than Timers.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      Lemme
                      wrote on last edited by
                      #10

                      Just what I need - many thanks!

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


                      14

                      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