zunoSendDeviceToSleep()

This function sends the device to sleep. This function notifies core that user code is ready to sleep. It doesn't send device to sleep immediately. This function is sultable only for ZUNO_SLEEPING_MODE_SLEEPING and ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE devices. When Z-Uno goes to sleep it switches off activity (green) LED. You are able to send wakeup notification from your code using zunoSendWakeUpNotification(). After the moment when the function was called you are able to check that it was called using zunoIsSleepLocked function and you can take the device back by means of zunoLockSleep. For ZUNO_SLEEPING_MODE_SLEEPING mode Z-Uno will wake up after wakeup period (set up via Wakeup Command Class) or on INT1 going LOW or Key Scanner detects press. For ZUNO_SLEEPING_MODE_SLEEPING mode Z-Uno will wake up after wakeup period (set up via Wakeup Command Class) or on external interrupt ( see zunoEM4EnablePinWakeup() for EM4 and attachInterrupt() for EM2)or on custom timer (see zunoSetCustomWUPTimer()) interval. For ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE mode Z-Uno will wake up on packet recieved, after a wake up period defined using zunoSetBeamCountWU() or on INT1 going LOW or Key Scanner detects press. For ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE mode Z-Uno will wake up on packet recieved, after a wake up period defined using zunoSetCustomWUPTimer() or on external interrupt (see attachInterrupt()) triggered. Look for code example inside ZUNO_SETUP_SLEEPING_MODE description. zunoSendDeviceToSleep(mode) mode: one of energy modes:
  • SLEEP_MODE_EM2 - RAM is retained, the most part of peripherals is on.
  • SLEEP_MODE_EM4 - RAM is cleaned when wakeup, only wakeup timer is avaliable, the most energy effective mode.
You can skip the parameter. By default is SLEEP_MODE_EM4. If you use FLiRS or device wasn't included to network the parameter is ignored by the system.
// LED pin number
// 13 pin - user LED of Z-Uno board
#define LED_PIN 13

// Last saved LED value
byte currentLEDValue;

ZUNO_SETUP_CHANNELS(ZUNO_SWITCH_BINARY(getter, setter));

// next macro sets up the sleeping mode
// device will wake up by user request and regulary listening for packets
ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);

// the setup routine runs once when you press reset:
void setup() {
  pinMode(LED_PIN, OUTPUT); // setup pin as output
}

// the loop routine runs over and over again forever:
void loop() { 
  // this function sends the device into sleep
  zunoSendDeviceToSleep();
}

void setter(byte value) {
  // value is a variable, holding a "new value"
  // which came from the controller or other Z-Wave device
  if (value > 0) {                // if greater then zero
    digitalWrite (LED_PIN, HIGH); //turn the LED on (HIGH is the voltage level)
  } else {                        // if equals zero
    digitalWrite(LED_PIN, LOW);   //turn the LED off by making the voltage LOW
  } 
  // we'll save our value for the situation, when the controller will ask us about it
  currentLEDValue = value;
}
 
byte getter() {
   return currentLEDValue;
}