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. Troubleshooting
  3. Sleep() doesn't "power down" the controller

Sleep() doesn't "power down" the controller

Scheduled Pinned Locked Moved Troubleshooting
3 Posts 3 Posters 1.9k Views 1 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
    RoBra81
    wrote on last edited by
    #1

    Hello,

    I'm creating my first sensor which shall be a sensor monitoring multiple window sash. For that I want't to configure multiple pins as interrupt and set the arduino sleeping until one sash changes its state. Interrupts are working fine but since I'd like to power the sensor using batteries I measured the current and stated that even when thinking the sensor shall sleep it needs about 2mA (cut off power LED) :disappointed:
    Since I read that it should be within µA-area I'm asking what I'm doing wrong?

    Here my sketch:

    /**
     * The MySensors Arduino library handles the wireless radio link and protocol
     * between your home built sensors/actuators and HA controller of choice.
     * The sensors forms a self healing radio network with optional repeaters. Each
     * repeater and gateway builds a routing tables in EEPROM which keeps track of the
     * network topology allowing messages to be routed to nodes.
     *
     * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
     * Copyright (C) 2013-2015 Sensnology AB
     * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
     *
     * Documentation: http://www.mysensors.org
     * Support Forum: http://forum.mysensors.org
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License
     * version 2 as published by the Free Software Foundation.
     *
     *******************************
     *
     * DESCRIPTION
     *
     * Interrupt driven binary switch example with dual interrupts
     * Author: Patrick 'Anticimex' Fallberg
     * Connect one button or door/window reed switch between 
     * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
     * one in similar fashion on digital I/O pin 2.
     * This example is designed to fit Arduino Nano/Pro Mini
     * 
     */
    #include <MySensor.h>
    #include <SPI.h>
    
    #include <EnableInterrupt.h>
    
    #define SKETCH_NAME "Multiple Window Sensor"
    #define SKETCH_MAJOR_VER "1"
    #define SKETCH_MINOR_VER "0"
    
    #define FIRST_WINDOW_ID 1
    #define SECOND_WINDOW_ID 2
    #define THIRD_WINDOW_ID 3
    #define FORTH_WINDOW_ID 4
    
    #define FIRST_WINDOW_PIN 4   // Arduino Digital I/O pin for button/reed switch
    #define SECOND_WINDOW_PIN 5 // Arduino Digital I/O pin for button/reed switch
    #define THIRD_WINDOW_PIN 6   // Arduino Digital I/O pin for button/reed switch
    #define FORTH_WINDOW_PIN 7 // Arduino Digital I/O pin for button/reed switch
    
    MySensor sensor_node;
    
    // Change to V_LIGHT if you use S_LIGHT in presentation below
    MyMessage first_window_msg(FIRST_WINDOW_ID, V_TRIPPED);
    MyMessage second_window_msg(SECOND_WINDOW_ID, V_TRIPPED);
    MyMessage third_window_msg(THIRD_WINDOW_ID, V_TRIPPED);
    MyMessage forth_window_msg(FORTH_WINDOW_ID, V_TRIPPED);
    
    void interruptFunctionFirstWindow() {
      sensor_node.sleep(5);
      sensor_node.send(first_window_msg.set(digitalRead(FIRST_WINDOW_PIN)));
    }
    
    void interruptFunctionSecondWindow() {
      sensor_node.sleep(5);
      sensor_node.send(second_window_msg.set(digitalRead(SECOND_WINDOW_PIN)));
    }
    
    void interruptFunctionThirdWindow() {
      sensor_node.sleep(5);
      sensor_node.send(third_window_msg.set(digitalRead(THIRD_WINDOW_PIN)));
    }
    
    void interruptFunctionForthWindow() {
      sensor_node.sleep(5);
      sensor_node.send(forth_window_msg.set(digitalRead(FORTH_WINDOW_PIN)));
    }
    
    void setup()  
    {  
      sensor_node.begin();
    
      // Setup the buttons
      pinMode(FIRST_WINDOW_PIN, INPUT_PULLUP);
      pinMode(SECOND_WINDOW_PIN, INPUT_PULLUP);
      pinMode(THIRD_WINDOW_PIN, INPUT_PULLUP);
      pinMode(FORTH_WINDOW_PIN, INPUT_PULLUP);
    
      // Send the sketch version information to the gateway and Controller
      sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
    
      // Register binary input sensor to sensor_node (they will be created as child devices)
      // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
      // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
      sensor_node.present(FIRST_WINDOW_ID, S_DOOR);  
      sensor_node.present(SECOND_WINDOW_ID, S_DOOR);  
      sensor_node.present(THIRD_WINDOW_ID, S_DOOR);  
      sensor_node.present(FORTH_WINDOW_ID, S_DOOR);  
    
      enableInterrupt(FIRST_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
      enableInterrupt(SECOND_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
      enableInterrupt(THIRD_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
      enableInterrupt(FORTH_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
    }
    
    // Loop will iterate on changes on the BUTTON_PINs
    void loop() 
    {
      sensor_node.sleep(0, CHANGE, 1, CHANGE, 0);
    } 
    

    Could anybody help me finding the problem?

    Thanks in advance
    Ronny

    D A 2 Replies Last reply
    0
    • R RoBra81

      Hello,

      I'm creating my first sensor which shall be a sensor monitoring multiple window sash. For that I want't to configure multiple pins as interrupt and set the arduino sleeping until one sash changes its state. Interrupts are working fine but since I'd like to power the sensor using batteries I measured the current and stated that even when thinking the sensor shall sleep it needs about 2mA (cut off power LED) :disappointed:
      Since I read that it should be within µA-area I'm asking what I'm doing wrong?

      Here my sketch:

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * DESCRIPTION
       *
       * Interrupt driven binary switch example with dual interrupts
       * Author: Patrick 'Anticimex' Fallberg
       * Connect one button or door/window reed switch between 
       * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
       * one in similar fashion on digital I/O pin 2.
       * This example is designed to fit Arduino Nano/Pro Mini
       * 
       */
      #include <MySensor.h>
      #include <SPI.h>
      
      #include <EnableInterrupt.h>
      
      #define SKETCH_NAME "Multiple Window Sensor"
      #define SKETCH_MAJOR_VER "1"
      #define SKETCH_MINOR_VER "0"
      
      #define FIRST_WINDOW_ID 1
      #define SECOND_WINDOW_ID 2
      #define THIRD_WINDOW_ID 3
      #define FORTH_WINDOW_ID 4
      
      #define FIRST_WINDOW_PIN 4   // Arduino Digital I/O pin for button/reed switch
      #define SECOND_WINDOW_PIN 5 // Arduino Digital I/O pin for button/reed switch
      #define THIRD_WINDOW_PIN 6   // Arduino Digital I/O pin for button/reed switch
      #define FORTH_WINDOW_PIN 7 // Arduino Digital I/O pin for button/reed switch
      
      MySensor sensor_node;
      
      // Change to V_LIGHT if you use S_LIGHT in presentation below
      MyMessage first_window_msg(FIRST_WINDOW_ID, V_TRIPPED);
      MyMessage second_window_msg(SECOND_WINDOW_ID, V_TRIPPED);
      MyMessage third_window_msg(THIRD_WINDOW_ID, V_TRIPPED);
      MyMessage forth_window_msg(FORTH_WINDOW_ID, V_TRIPPED);
      
      void interruptFunctionFirstWindow() {
        sensor_node.sleep(5);
        sensor_node.send(first_window_msg.set(digitalRead(FIRST_WINDOW_PIN)));
      }
      
      void interruptFunctionSecondWindow() {
        sensor_node.sleep(5);
        sensor_node.send(second_window_msg.set(digitalRead(SECOND_WINDOW_PIN)));
      }
      
      void interruptFunctionThirdWindow() {
        sensor_node.sleep(5);
        sensor_node.send(third_window_msg.set(digitalRead(THIRD_WINDOW_PIN)));
      }
      
      void interruptFunctionForthWindow() {
        sensor_node.sleep(5);
        sensor_node.send(forth_window_msg.set(digitalRead(FORTH_WINDOW_PIN)));
      }
      
      void setup()  
      {  
        sensor_node.begin();
      
        // Setup the buttons
        pinMode(FIRST_WINDOW_PIN, INPUT_PULLUP);
        pinMode(SECOND_WINDOW_PIN, INPUT_PULLUP);
        pinMode(THIRD_WINDOW_PIN, INPUT_PULLUP);
        pinMode(FORTH_WINDOW_PIN, INPUT_PULLUP);
      
        // Send the sketch version information to the gateway and Controller
        sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
      
        // Register binary input sensor to sensor_node (they will be created as child devices)
        // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
        // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
        sensor_node.present(FIRST_WINDOW_ID, S_DOOR);  
        sensor_node.present(SECOND_WINDOW_ID, S_DOOR);  
        sensor_node.present(THIRD_WINDOW_ID, S_DOOR);  
        sensor_node.present(FORTH_WINDOW_ID, S_DOOR);  
      
        enableInterrupt(FIRST_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
        enableInterrupt(SECOND_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
        enableInterrupt(THIRD_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
        enableInterrupt(FORTH_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
      }
      
      // Loop will iterate on changes on the BUTTON_PINs
      void loop() 
      {
        sensor_node.sleep(0, CHANGE, 1, CHANGE, 0);
      } 
      

      Could anybody help me finding the problem?

      Thanks in advance
      Ronny

      D Offline
      D Offline
      Dwalt
      wrote on last edited by
      #2

      @RoBra81

      Which Arduino model are you using? Pro-mini? You mentioned cutting the LED, did you also remove the power regulator?

      Veralite UI5 :: IBoard Ethernet GW :: MyS 1.5

      1 Reply Last reply
      0
      • R RoBra81

        Hello,

        I'm creating my first sensor which shall be a sensor monitoring multiple window sash. For that I want't to configure multiple pins as interrupt and set the arduino sleeping until one sash changes its state. Interrupts are working fine but since I'd like to power the sensor using batteries I measured the current and stated that even when thinking the sensor shall sleep it needs about 2mA (cut off power LED) :disappointed:
        Since I read that it should be within µA-area I'm asking what I'm doing wrong?

        Here my sketch:

        /**
         * The MySensors Arduino library handles the wireless radio link and protocol
         * between your home built sensors/actuators and HA controller of choice.
         * The sensors forms a self healing radio network with optional repeaters. Each
         * repeater and gateway builds a routing tables in EEPROM which keeps track of the
         * network topology allowing messages to be routed to nodes.
         *
         * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
         * Copyright (C) 2013-2015 Sensnology AB
         * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
         *
         * Documentation: http://www.mysensors.org
         * Support Forum: http://forum.mysensors.org
         *
         * This program is free software; you can redistribute it and/or
         * modify it under the terms of the GNU General Public License
         * version 2 as published by the Free Software Foundation.
         *
         *******************************
         *
         * DESCRIPTION
         *
         * Interrupt driven binary switch example with dual interrupts
         * Author: Patrick 'Anticimex' Fallberg
         * Connect one button or door/window reed switch between 
         * digitial I/O pin 3 (BUTTON_PIN below) and GND and the other
         * one in similar fashion on digital I/O pin 2.
         * This example is designed to fit Arduino Nano/Pro Mini
         * 
         */
        #include <MySensor.h>
        #include <SPI.h>
        
        #include <EnableInterrupt.h>
        
        #define SKETCH_NAME "Multiple Window Sensor"
        #define SKETCH_MAJOR_VER "1"
        #define SKETCH_MINOR_VER "0"
        
        #define FIRST_WINDOW_ID 1
        #define SECOND_WINDOW_ID 2
        #define THIRD_WINDOW_ID 3
        #define FORTH_WINDOW_ID 4
        
        #define FIRST_WINDOW_PIN 4   // Arduino Digital I/O pin for button/reed switch
        #define SECOND_WINDOW_PIN 5 // Arduino Digital I/O pin for button/reed switch
        #define THIRD_WINDOW_PIN 6   // Arduino Digital I/O pin for button/reed switch
        #define FORTH_WINDOW_PIN 7 // Arduino Digital I/O pin for button/reed switch
        
        MySensor sensor_node;
        
        // Change to V_LIGHT if you use S_LIGHT in presentation below
        MyMessage first_window_msg(FIRST_WINDOW_ID, V_TRIPPED);
        MyMessage second_window_msg(SECOND_WINDOW_ID, V_TRIPPED);
        MyMessage third_window_msg(THIRD_WINDOW_ID, V_TRIPPED);
        MyMessage forth_window_msg(FORTH_WINDOW_ID, V_TRIPPED);
        
        void interruptFunctionFirstWindow() {
          sensor_node.sleep(5);
          sensor_node.send(first_window_msg.set(digitalRead(FIRST_WINDOW_PIN)));
        }
        
        void interruptFunctionSecondWindow() {
          sensor_node.sleep(5);
          sensor_node.send(second_window_msg.set(digitalRead(SECOND_WINDOW_PIN)));
        }
        
        void interruptFunctionThirdWindow() {
          sensor_node.sleep(5);
          sensor_node.send(third_window_msg.set(digitalRead(THIRD_WINDOW_PIN)));
        }
        
        void interruptFunctionForthWindow() {
          sensor_node.sleep(5);
          sensor_node.send(forth_window_msg.set(digitalRead(FORTH_WINDOW_PIN)));
        }
        
        void setup()  
        {  
          sensor_node.begin();
        
          // Setup the buttons
          pinMode(FIRST_WINDOW_PIN, INPUT_PULLUP);
          pinMode(SECOND_WINDOW_PIN, INPUT_PULLUP);
          pinMode(THIRD_WINDOW_PIN, INPUT_PULLUP);
          pinMode(FORTH_WINDOW_PIN, INPUT_PULLUP);
        
          // Send the sketch version information to the gateway and Controller
          sensor_node.sendSketchInfo(SKETCH_NAME, SKETCH_MAJOR_VER"."SKETCH_MINOR_VER);
        
          // Register binary input sensor to sensor_node (they will be created as child devices)
          // You can use S_DOOR, S_MOTION or S_LIGHT here depending on your usage. 
          // If S_LIGHT is used, remember to update variable type you send in. See "msg" above.
          sensor_node.present(FIRST_WINDOW_ID, S_DOOR);  
          sensor_node.present(SECOND_WINDOW_ID, S_DOOR);  
          sensor_node.present(THIRD_WINDOW_ID, S_DOOR);  
          sensor_node.present(FORTH_WINDOW_ID, S_DOOR);  
        
          enableInterrupt(FIRST_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
          enableInterrupt(SECOND_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
          enableInterrupt(THIRD_WINDOW_PIN, interruptFunctionFirstWindow, CHANGE);
          enableInterrupt(FORTH_WINDOW_PIN, interruptFunctionSecondWindow, CHANGE);
        }
        
        // Loop will iterate on changes on the BUTTON_PINs
        void loop() 
        {
          sensor_node.sleep(0, CHANGE, 1, CHANGE, 0);
        } 
        

        Could anybody help me finding the problem?

        Thanks in advance
        Ronny

        A Offline
        A Offline
        AWI
        Hero Member
        wrote on last edited by
        #3

        @RoBra81 When (one of) your contacts is closed there will be a current flowing through the (internal) pull-up's of the Arduino. This is around 0.25 mA per active switch! depending on the type of Arduino and supply voltage. AVR has 20k-50k pull-up resistors.

        1 Reply Last reply
        0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        9

        Online

        12.1k

        Users

        11.2k

        Topics

        113.4k

        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