Waking up 3.3v Pro Mini



  • Hello,
    Other than using an interrupt on a pin level change (ie: D2), what are the ways to wake up a 3.3v Pro Mini from "sleeping"?

    Or are using interrupts the only way?

    I would like to put the Pro Mini to sleep for 12 hours, then wake it up to transmit data, and put it back to sleep...

    Thanks.


  • Mod

    Yes, waking up by timer is supported. From the "Sleeping" section in the api documentation:

    void sleep(unsigned long ms);
    

    ms - Number of milliseconds to sleep.

    See the temperature example for a working example.

    For 12 hours you would set SLEEP_TIME to 1,000 * 60 * 60 * 12 = 43,200,000



  • Thanks.

    I do have another question on what happens when an interrupt occurs. In the below example sketch, what code gets executed when the interrupt occurs: Is it at the interrupt handler "wakeUP()", or is it after the "detachInterrupt(1); ??

    Typically when the interrupt happens, the interrupt handler code gets executed, and then it goes back to whatever code it was running when the interrupt happened.

    Since, in this case, the interrupt handler does nothing, will it then execute the line after the "detachInterrupt(1);" ?

    #include "LowPower.h";
    void wakeUp(){
    }
    void setup() {
    pinMode(3, INPUT_PULLUP);

    Serial.begin(115200);
    delay(1000);
    }

    void loop() {
    Serial.println("Sleep Mode Entered");
    delay(500);
    attachInterrupt(1, wakeUp, CHANGE);
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    detachInterrupt(1);

    Serial.println(F("woke up"));
    delay(500);

    }


  • Mod

    I have no experience with the LowPower library (MySensors has its own functions) but detachInterrupt should be executed after wakeup.

    Add some debug prints and try, that's usually the best way to learn. Or read the documentation for that library.



  • @y4CdW42Ol8

    Have a look at the examples as supplied with the mySensors library. Both ways are implemented extensively.
    The gw.sleep(...) function will be the way to go for the 12 hrs. you'd like to put the sensor asleep. This is used in many examples
    For waking up with interrupt have a look at the example for the power meter. It wakes up the sensor when an interrupt occurs.

    Be my guest to find your own way of programming this, but as @mfalkvidd already pointed out: MySensors has its own functions!

    Good luck,

    Boozz.


 

335
Online

7.9k
Users

8.8k
Topics

93.8k
Posts