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. [SOLVED] Sleep dont run

[SOLVED] Sleep dont run

Scheduled Pinned Locked Moved Troubleshooting
51 Posts 8 Posters 11.4k Views 7 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 gohan

    @mar.conte remember to set node ID

    mar.conteM Offline
    mar.conteM Offline
    mar.conte
    wrote on last edited by
    #18

    @gohan
    one example to set node id in motion sketch?

    M.C.

    1 Reply Last reply
    0
    • mar.conteM Offline
      mar.conteM Offline
      mar.conte
      wrote on last edited by mar.conte
      #19

      RESOLVED

      I HAVE JUST ONE GATEWAY CONFIGURED WITH RFM69 ON BOARD, THEN I HAVE CONNECTED TO NODE ID MCU WITH PIR AND EVERYTHING WORKS, WHEN THE PIR IS HIGH CURRENT CONSUMED is 2.25 MAH, WHEN IN SLEEP MODE ONLY 30 microamps.
      THANKS TO ALL THAT I HAVE HELPED

      NODE

      /**
       * 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.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * Motion Sensor example using HC-SR501
       * http://www.mysensors.org/build/motion
       *
       */
      
      // Enable debug prints
       #define MY_DEBUG
      #define MY_NODE_ID 1
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      
      #include <MySensors.h>
      
      unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
      #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
      #define CHILD_ID 1   // Id of the sensor child
      
      // Initialize motion message
      MyMessage msg(CHILD_ID, V_TRIPPED);
      
      void setup()
      {
      	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
      }
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo("Motion Sensor", "1.0");
      
      	// Register all sensors to gw (they will be created as child devices)
      	present(CHILD_ID, S_MOTION);
      }
      
      void loop()
      {
      	// Read digital motion value
      	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
      
      	Serial.println(tripped);
      	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
      
      	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
      	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
      }
      
      

      GATEWAY

      /**
      * 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
      * The ArduinoGateway prints data received from sensors on the serial link.
      * The gateway accepts input on seral which will be sent out on radio network.
      *
      * The GW code is designed for Arduino Nano 328p / 16MHz
      *
      * Wire connections (OPTIONAL):
      * - Inclusion button should be connected between digital pin 3 and GND
      * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
      *
      * LEDs (OPTIONAL):
      * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
      * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
      * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
      * - ERR (red) - fast blink on error during transmission error or recieve crc error
      *
      */
      
      // Enable debug prints to serial monitor
      #define MY_DEBUG
      
      
      // Enable and select radio type attached
      //#define MY_RADIO_NRF24
      #define MY_RADIO_RFM69
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level.
      #define MY_RF24_PA_LEVEL RF24_PA_LOW
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL
      
      // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
      #if F_CPU == 8000000L
      #define MY_BAUD_RATE 38400
      #endif
      
      // Enable inclusion mode
      #define MY_INCLUSION_MODE_FEATURE
      // Enable Inclusion mode button on gateway
      //#define MY_INCLUSION_BUTTON_FEATURE
      
      // Inverses behavior of inclusion button (if using external pullup)
      //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
      
      // Set inclusion mode duration (in seconds)
      #define MY_INCLUSION_MODE_DURATION 60
      // Digital pin used for inclusion mode button
      //#define MY_INCLUSION_MODE_BUTTON_PIN  3
      
      // Set blinking period
      #define MY_DEFAULT_LED_BLINK_PERIOD 300
      
      // Inverses the behavior of leds
      //#define MY_WITH_LEDS_BLINKING_INVERSE
      
      // Flash leds on rx/tx/err
      // Uncomment to override default HW configurations
      //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
      //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
      //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
      
      #include <MySensors.h>
      
      void setup()
      {
      	// Setup locally attached sensors
      }
      
      void presentation()
      {
      	// Present locally attached sensors
      }
      
      void loop()
      {
      	// Send locally attached sensor data here
      }
      
      

      SERIAL OUTPUT NODE

      0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
      4 TSM:INIT
      4 TSF:WUR:MS=0
      8 TSM:INIT:TSP OK
      10 TSM:INIT:STATID=1
      12 TSF:SID:OK,ID=1
      14 TSM:FPAR
      145 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
      1044 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
      1050 TSF:MSG:FPAR OK,ID=0,D=1
      2152 TSM:FPAR:OK
      2152 TSM:ID
      2154 TSM:ID:OK
      2156 TSM:UPL
      2164 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
      2199 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
      2205 TSF:MSG:PONG RECV,HP=1
      2207 TSM:UPL:OK
      2209 TSM:READY:ID=1,PAR=0,DIS=1
      2263 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
      2287 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
      2344 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
      2404 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
      4421 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=OK:Motion Sensor
      4483 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
      4542 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
      4548 MCO:REG:REQ
      4601 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
      4626 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
      4630 MCO:PIM:NODE REG=1
      4634 MCO:BGN:STP
      4636 MCO:BGN:INIT OK,TSP=1
      1
      4689 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      4698 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
      4702 MCO:SLP:TPD
      4704 MCO:SLP:WUP=1
      0
      4714 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
      4722 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
      4726 MCO:SLP:TPD
      4728 MCO:SLP:WUP=1
      1
      4739 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
      4747 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
      4751 MCO:SLP:TPD
      4753 MCO:SLP:WUP=1
      0
      4763 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
      4771 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
      4775 MCO:SLP:TPD
      

      SERIAL OUTPUT GATEWAY

      0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
      0;255;3;0;9;TSM:INIT
      0;255;3;0;9;TSF:WUR:MS=0
      0;255;3;0;9;TSM:INIT:TSP OK
      0;255;3;0;9;TSM:INIT:GW MODE
      0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
      0;255;3;0;9;MCO:REG:NOT NEEDED
      0;255;3;0;14;Gateway startup complete.
      0;255;0;0;18;2.1.1
      0;255;3;0;9;MCO:BGN:STP
      0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
      0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
      1;1;1;0;16;1
      

      TANKS VERY VERY VERY TO ALL

      M.C.

      YveauxY 1 Reply Last reply
      0
      • mar.conteM mar.conte

        RESOLVED

        I HAVE JUST ONE GATEWAY CONFIGURED WITH RFM69 ON BOARD, THEN I HAVE CONNECTED TO NODE ID MCU WITH PIR AND EVERYTHING WORKS, WHEN THE PIR IS HIGH CURRENT CONSUMED is 2.25 MAH, WHEN IN SLEEP MODE ONLY 30 microamps.
        THANKS TO ALL THAT I HAVE HELPED

        NODE

        /**
         * 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.
         *
         *******************************
         *
         * REVISION HISTORY
         * Version 1.0 - Henrik Ekblad
         *
         * DESCRIPTION
         * Motion Sensor example using HC-SR501
         * http://www.mysensors.org/build/motion
         *
         */
        
        // Enable debug prints
         #define MY_DEBUG
        #define MY_NODE_ID 1
        // Enable and select radio type attached
        //#define MY_RADIO_NRF24
        #define MY_RADIO_RFM69
        
        #include <MySensors.h>
        
        unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
        #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
        #define CHILD_ID 1   // Id of the sensor child
        
        // Initialize motion message
        MyMessage msg(CHILD_ID, V_TRIPPED);
        
        void setup()
        {
        	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
        }
        
        void presentation()
        {
        	// Send the sketch version information to the gateway and Controller
        	sendSketchInfo("Motion Sensor", "1.0");
        
        	// Register all sensors to gw (they will be created as child devices)
        	present(CHILD_ID, S_MOTION);
        }
        
        void loop()
        {
        	// Read digital motion value
        	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
        
        	Serial.println(tripped);
        	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
        
        	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
        	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), CHANGE, SLEEP_TIME);
        }
        
        

        GATEWAY

        /**
        * 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
        * The ArduinoGateway prints data received from sensors on the serial link.
        * The gateway accepts input on seral which will be sent out on radio network.
        *
        * The GW code is designed for Arduino Nano 328p / 16MHz
        *
        * Wire connections (OPTIONAL):
        * - Inclusion button should be connected between digital pin 3 and GND
        * - RX/TX/ERR leds need to be connected between +5V (anode) and digital pin 6/5/4 with resistor 270-330R in a series
        *
        * LEDs (OPTIONAL):
        * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs
        * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
        * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
        * - ERR (red) - fast blink on error during transmission error or recieve crc error
        *
        */
        
        // Enable debug prints to serial monitor
        #define MY_DEBUG
        
        
        // Enable and select radio type attached
        //#define MY_RADIO_NRF24
        #define MY_RADIO_RFM69
        
        // Set LOW transmit power level as default, if you have an amplified NRF-module and
        // power your radio separately with a good regulator you can turn up PA level.
        #define MY_RF24_PA_LEVEL RF24_PA_LOW
        
        // Enable serial gateway
        #define MY_GATEWAY_SERIAL
        
        // Define a lower baud rate for Arduino's running on 8 MHz (Arduino Pro Mini 3.3V & SenseBender)
        #if F_CPU == 8000000L
        #define MY_BAUD_RATE 38400
        #endif
        
        // Enable inclusion mode
        #define MY_INCLUSION_MODE_FEATURE
        // Enable Inclusion mode button on gateway
        //#define MY_INCLUSION_BUTTON_FEATURE
        
        // Inverses behavior of inclusion button (if using external pullup)
        //#define MY_INCLUSION_BUTTON_EXTERNAL_PULLUP
        
        // Set inclusion mode duration (in seconds)
        #define MY_INCLUSION_MODE_DURATION 60
        // Digital pin used for inclusion mode button
        //#define MY_INCLUSION_MODE_BUTTON_PIN  3
        
        // Set blinking period
        #define MY_DEFAULT_LED_BLINK_PERIOD 300
        
        // Inverses the behavior of leds
        //#define MY_WITH_LEDS_BLINKING_INVERSE
        
        // Flash leds on rx/tx/err
        // Uncomment to override default HW configurations
        //#define MY_DEFAULT_ERR_LED_PIN 4  // Error led pin
        //#define MY_DEFAULT_RX_LED_PIN  6  // Receive led pin
        //#define MY_DEFAULT_TX_LED_PIN  5  // the PCB, on board LED
        
        #include <MySensors.h>
        
        void setup()
        {
        	// Setup locally attached sensors
        }
        
        void presentation()
        {
        	// Present locally attached sensors
        }
        
        void loop()
        {
        	// Send locally attached sensor data here
        }
        
        

        SERIAL OUTPUT NODE

        0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
        4 TSM:INIT
        4 TSF:WUR:MS=0
        8 TSM:INIT:TSP OK
        10 TSM:INIT:STATID=1
        12 TSF:SID:OK,ID=1
        14 TSM:FPAR
        145 TSF:MSG:SEND,1-1-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
        1044 TSF:MSG:READ,0-0-1,s=255,c=3,t=8,pt=1,l=1,sg=0:0
        1050 TSF:MSG:FPAR OK,ID=0,D=1
        2152 TSM:FPAR:OK
        2152 TSM:ID
        2154 TSM:ID:OK
        2156 TSM:UPL
        2164 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
        2199 TSF:MSG:READ,0-0-1,s=255,c=3,t=25,pt=1,l=1,sg=0:1
        2205 TSF:MSG:PONG RECV,HP=1
        2207 TSM:UPL:OK
        2209 TSM:READY:ID=1,PAR=0,DIS=1
        2263 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
        2287 TSF:MSG:READ,0-0-1,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
        2344 TSF:MSG:SEND,1-1-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
        2404 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
        4421 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=11,pt=0,l=13,sg=0,ft=0,st=OK:Motion Sensor
        4483 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
        4542 TSF:MSG:SEND,1-1-0-0,s=1,c=0,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
        4548 MCO:REG:REQ
        4601 TSF:MSG:SEND,1-1-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
        4626 TSF:MSG:READ,0-0-1,s=255,c=3,t=27,pt=1,l=1,sg=0:1
        4630 MCO:PIM:NODE REG=1
        4634 MCO:BGN:STP
        4636 MCO:BGN:INIT OK,TSP=1
        1
        4689 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
        4698 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
        4702 MCO:SLP:TPD
        4704 MCO:SLP:WUP=1
        0
        4714 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
        4722 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
        4726 MCO:SLP:TPD
        4728 MCO:SLP:WUP=1
        1
        4739 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:1
        4747 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
        4751 MCO:SLP:TPD
        4753 MCO:SLP:WUP=1
        0
        4763 TSF:MSG:SEND,1-1-0-0,s=1,c=1,t=16,pt=0,l=1,sg=0,ft=0,st=OK:0
        4771 MCO:SLP:MS=0,SMS=0,I1=1,M1=1,I2=255,M2=255
        4775 MCO:SLP:TPD
        

        SERIAL OUTPUT GATEWAY

        0;255;3;0;9;MCO:BGN:INIT GW,CP=RRNGA--,VER=2.1.1
        0;255;3;0;9;TSM:INIT
        0;255;3;0;9;TSF:WUR:MS=0
        0;255;3;0;9;TSM:INIT:TSP OK
        0;255;3;0;9;TSM:INIT:GW MODE
        0;255;3;0;9;TSM:READY:ID=0,PAR=0,DIS=0
        0;255;3;0;9;MCO:REG:NOT NEEDED
        0;255;3;0;14;Gateway startup complete.
        0;255;0;0;18;2.1.1
        0;255;3;0;9;MCO:BGN:STP
        0;255;3;0;9;MCO:BGN:INIT OK,TSP=1
        0;255;3;0;9;TSF:MSG:READ,1-1-0,s=1,c=1,t=16,pt=0,l=1,sg=0:1
        1;1;1;0;16;1
        

        TANKS VERY VERY VERY TO ALL

        YveauxY Offline
        YveauxY Offline
        Yveaux
        Mod
        wrote on last edited by
        #20

        @mar.conte Great to hear you nailed it!
        For others to learn: what did you change to make things work?

        http://yveaux.blogspot.nl

        gohanG 1 Reply Last reply
        0
        • YveauxY Yveaux

          @mar.conte Great to hear you nailed it!
          For others to learn: what did you change to make things work?

          gohanG Offline
          gohanG Offline
          gohan
          Mod
          wrote on last edited by
          #21

          @Yveaux I think he added the gateway as he wasn't using one

          mar.conteM 1 Reply Last reply
          0
          • gohanG gohan

            @Yveaux I think he added the gateway as he wasn't using one

            mar.conteM Offline
            mar.conteM Offline
            mar.conte
            wrote on last edited by
            #22

            @gohan
            Yes of course, add gateway and the loop end , the node attachinterrupt with pir go to sleep when gateway receive
            Tanks

            M.C.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              torfinn
              wrote on last edited by
              #23

              Hi ! Just wanted to add that this also solved it for me. I had problem with properly registering on the gateway ( due to chips was used on old version earlier ). After finding this post I tried the https://www.mysensors.org/build/debug#clearing-eeprom and it fixed problem. Looking at 40uA sleeping now :-)

              1 Reply Last reply
              0
              • YveauxY Yveaux

                @AWI See @tekka post here

                "For indefinite sleeping, only level IRQ triggers are permitted (see AVR datasheet)."

                Could you give that a try?

                AWIA Offline
                AWIA Offline
                AWI
                Hero Member
                wrote on last edited by
                #24

                @Yveaux said in [SOLVED] Sleep dont run:

                "For indefinite sleeping, only level IRQ triggers are permitted (see AVR datasheet)."

                Thanks @Yveaux I thought I was losing it...:relaxed: Tried different options:
                sleep(INTERRUPT1, LOW, 0 ); // sleep and wait for motion :+1:
                sleep(INTERRUPT1, LOW, 5000 ); // sleep and wait for 5 secs :+1:
                sleep(INTERRUPT1, CHANGE, 0 ); // sleep and wait for motion :-1:
                but for the last op tion @mar-conte reported succes :confused: how come?

                My understanding is:

                • deep sleep: only LOW
                • timed sleep: LOW, CHANGE, RISING, FALLING
                  or...?
                YveauxY 1 Reply Last reply
                0
                • mar.conteM Offline
                  mar.conteM Offline
                  mar.conte
                  wrote on last edited by
                  #25

                  Hello everyone, I do not understand why ATmega328 powered with an Arduino board without MCU with 3v3 volts when ba consumes 30 microamps in sleep imvece atmega if the power is two batteries 1,5 knows when he goes to sleep consumes 420 microamps, I'm not understanding nothing seemed that just consumed my project with pir and ATMEga

                  M.C.

                  AWIA 1 Reply Last reply
                  0
                  • mar.conteM mar.conte

                    Hello everyone, I do not understand why ATmega328 powered with an Arduino board without MCU with 3v3 volts when ba consumes 30 microamps in sleep imvece atmega if the power is two batteries 1,5 knows when he goes to sleep consumes 420 microamps, I'm not understanding nothing seemed that just consumed my project with pir and ATMEga

                    AWIA Offline
                    AWIA Offline
                    AWI
                    Hero Member
                    wrote on last edited by
                    #26

                    @mar.conte I'm sorry but can you try to rephrase your question?

                    1 Reply Last reply
                    0
                    • mar.conteM Offline
                      mar.conteM Offline
                      mar.conte
                      wrote on last edited by
                      #27

                      Why the same configuration atmega+pir+rfm69 with ftdi power consumption is 30 microampere and with 2 1,5 AA is 420 microampere?

                      M.C.

                      gohanG 1 Reply Last reply
                      0
                      • mar.conteM mar.conte

                        Why the same configuration atmega+pir+rfm69 with ftdi power consumption is 30 microampere and with 2 1,5 AA is 420 microampere?

                        gohanG Offline
                        gohanG Offline
                        gohan
                        Mod
                        wrote on last edited by
                        #28

                        @mar.conte how did you made the measurements?

                        mar.conteM 1 Reply Last reply
                        0
                        • gohanG gohan

                          @mar.conte how did you made the measurements?

                          mar.conteM Offline
                          mar.conteM Offline
                          mar.conte
                          wrote on last edited by mar.conte
                          #29

                          @gohan
                          one thing I did not say that I have changed the gateway before it was all right (30 microah) when the gateway
                          was a esp Olimex evb, now I
                          downloaded the same sketch "gateway" on
                          esp8266 nodemecu dev kit and the node consumes me 420 microah !!

                          GATEWAY

                          /**
                           * 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.
                           *
                           *******************************
                           *
                           * REVISION HISTORY
                           * Version 1.0 - Henrik Ekblad
                           *
                           * DESCRIPTION
                           * The ESP8266 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
                           * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
                           *
                           * LED purposes:
                           * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch
                           * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
                           * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                           * - ERR (red) - fast blink on error during transmission error or recieve crc error
                           *
                           * See http://www.mysensors.org/build/esp8266_gateway for wiring instructions.
                           * nRF24L01+  ESP8266
                           * VCC        VCC
                           * CE         GPIO4
                           * CSN/CS     GPIO15
                           * SCK        GPIO14
                           * MISO       GPIO12
                           * MOSI       GPIO13
                           *
                           * Not all ESP8266 modules have all pins available on their external interface.
                           * This code has been tested on an ESP-12 module.
                           * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
                           * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
                           * - Connect GPIO15 via 10K pulldown resistor to GND
                           * - Connect CH_PD via 10K resistor to VCC
                           * - Connect GPIO2 via 10K resistor to VCC
                           * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
                           *
                            * Inclusion mode button:
                           * - Connect GPIO5 via switch to GND ('inclusion switch')
                           *
                           * Hardware SHA204 signing is currently not supported!
                           *
                           * Make sure to fill in your ssid and WiFi password below for ssid & pass.
                           */
                          
                          
                          // Enable debug prints to serial monitor
                          #define MY_DEBUG
                          
                          // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
                          #define MY_BAUD_RATE 9600
                          
                          // Enables and select radio type (if attached)
                          //#define MY_RADIO_NRF24
                          #define MY_RADIO_RFM69
                          // Enable repeater functionality for this node
                          //#define MY_REPEATER_FEATURE
                          #ifdef ESP8266
                          #define MY_RADIO_RFM69
                          #define MY_RFM69_FREQUENCY RF69_868MHZ // Set your frequency here
                          #define MY_IS_RFM69HW // Omit if your RFM is not "H"
                          #define MY_RF69_IRQ_PIN D1
                          #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
                          #define MY_RF69_SPI_CS D8 // NSS
                          #endif
                          #define MY_REPEATER_FEATURE
                          
                          
                          #define MY_GATEWAY_MQTT_CLIENT
                          #define MY_GATEWAY_ESP8266
                          
                          // Set this node's subscribe and publish topic prefix
                          //#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
                          //#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
                          
                          #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/MyMQTT"
                          #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/MyMQTT"
                          // Set MQTT client id
                          #define MY_MQTT_CLIENT_ID "mysensors-1"
                          
                          // Enable these if your MQTT broker requires usenrame/password
                          //#define MY_MQTT_USER "mosquitto"
                          //#define MY_MQTT_PASSWORD ""
                          
                          // Set WIFI SSID and password
                          #define MY_ESP8266_SSID "TP-LINK_B541"
                          #define MY_ESP8266_PASSWORD "xxxxxx"
                          
                          // Set the hostname for the WiFi Client. This is the hostname
                          // it will pass to the DHCP server if not static.
                          #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway"
                          
                          // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                          #define MY_IP_ADDRESS 192,168,1,77
                          
                          // If using static ip you need to define Gateway and Subnet address as well
                          #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                          #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                          
                          
                          // MQTT broker ip address.
                          #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1,200
                          
                          // The MQTT broker port to to open
                          #define MY_PORT 1883
                          
                          /*
                          // Enable inclusion mode
                          #define MY_INCLUSION_MODE_FEATURE
                          // Enable Inclusion mode button on gateway
                          #define MY_INCLUSION_BUTTON_FEATURE
                          // Set inclusion mode duration (in seconds)
                          #define MY_INCLUSION_MODE_DURATION 60
                          // Digital pin used for inclusion mode button
                          #define MY_INCLUSION_MODE_BUTTON_PIN  3
                          
                          // Set blinking period
                          #define MY_DEFAULT_LED_BLINK_PERIOD 300
                          
                          // Flash leds on rx/tx/err
                          #define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
                          #define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
                          #define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
                          */
                          
                          #include <ESP8266WiFi.h>
                          #include <MySensors.h>
                          
                          #define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                          #define NUMBER_OF_RELAYS 1 // Total number of attached relays
                          #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                          #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                          
                          void before()
                          {
                              for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                  // Then set relay pins in output mode
                                  pinMode(pin, OUTPUT);
                                  // Set relay to last known state (using eeprom storage)
                                  digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
                              }
                          }
                          
                          
                          void setup()
                          {
                          }
                          
                          void presentation()
                          {
                              // Send the sketch version information to the gateway and Controller
                              sendSketchInfo("Relay", "1.0");
                          
                              for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                  // Register all sensors to gw (they will be created as child devices)
                                  present(sensor, S_BINARY);
                              }
                          }
                          
                          void loop()
                          {
                          	// Send locally attech sensors data here
                          }
                          
                          void receive(const MyMessage &message)
                          {
                              // We only expect one type of message from controller. But we better check anyway.
                              if (message.type==V_STATUS) {
                                  // Change relay state
                                  digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                                  // Store state in eeprom
                                  saveState(message.sensor, message.getBool());
                                  // Write some debug info
                                  Serial.print("Incoming change for sensor:");
                                  Serial.print(message.sensor);
                                  Serial.print(", New status: ");
                                  Serial.println(message.getBool());
                              }
                          }
                          
                          

                          NODE

                          /**
                           * 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.
                           *
                           *******************************
                           *
                           * REVISION HISTORY
                           * Version 1.0 - Henrik Ekblad
                           *
                           * DESCRIPTION
                           * Motion Sensor example using HC-SR501
                           * http://www.mysensors.org/build/motion
                           *
                           */
                          
                          // Enable debug prints
                           #define MY_DEBUG
                          #define MY_NODE_ID 1
                          // Enable and select radio type attached
                          //#define MY_RADIO_NRF24
                          #define MY_RADIO_RFM69
                          
                          #include <MySensors.h>
                          
                          unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
                          #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                          #define CHILD_ID 1   // Id of the sensor child
                          
                          // Initialize motion message
                          MyMessage msg(CHILD_ID, V_TRIPPED);
                          
                          void setup()
                          {
                          	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                          
                          }
                          
                          void presentation()
                          {
                          	// Send the sketch version information to the gateway and Controller
                          	sendSketchInfo("Motion Sensor", "1.0");
                          
                          	// Register all sensors to gw (they will be created as child devices)
                          	present(CHILD_ID, S_MOTION);
                          }
                          
                          void loop()
                          {
                             
                          	// Read digital motion value
                          	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
                          
                          	Serial.println(tripped);
                          	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
                          
                          	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
                          	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR),CHANGE, SLEEP_TIME);
                          }
                          

                          M.C.

                          AWIA YveauxY 2 Replies Last reply
                          0
                          • mar.conteM mar.conte

                            @gohan
                            one thing I did not say that I have changed the gateway before it was all right (30 microah) when the gateway
                            was a esp Olimex evb, now I
                            downloaded the same sketch "gateway" on
                            esp8266 nodemecu dev kit and the node consumes me 420 microah !!

                            GATEWAY

                            /**
                             * 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.
                             *
                             *******************************
                             *
                             * REVISION HISTORY
                             * Version 1.0 - Henrik Ekblad
                             *
                             * DESCRIPTION
                             * The ESP8266 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
                             * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
                             *
                             * LED purposes:
                             * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch
                             * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
                             * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                             * - ERR (red) - fast blink on error during transmission error or recieve crc error
                             *
                             * See http://www.mysensors.org/build/esp8266_gateway for wiring instructions.
                             * nRF24L01+  ESP8266
                             * VCC        VCC
                             * CE         GPIO4
                             * CSN/CS     GPIO15
                             * SCK        GPIO14
                             * MISO       GPIO12
                             * MOSI       GPIO13
                             *
                             * Not all ESP8266 modules have all pins available on their external interface.
                             * This code has been tested on an ESP-12 module.
                             * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
                             * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
                             * - Connect GPIO15 via 10K pulldown resistor to GND
                             * - Connect CH_PD via 10K resistor to VCC
                             * - Connect GPIO2 via 10K resistor to VCC
                             * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
                             *
                              * Inclusion mode button:
                             * - Connect GPIO5 via switch to GND ('inclusion switch')
                             *
                             * Hardware SHA204 signing is currently not supported!
                             *
                             * Make sure to fill in your ssid and WiFi password below for ssid & pass.
                             */
                            
                            
                            // Enable debug prints to serial monitor
                            #define MY_DEBUG
                            
                            // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
                            #define MY_BAUD_RATE 9600
                            
                            // Enables and select radio type (if attached)
                            //#define MY_RADIO_NRF24
                            #define MY_RADIO_RFM69
                            // Enable repeater functionality for this node
                            //#define MY_REPEATER_FEATURE
                            #ifdef ESP8266
                            #define MY_RADIO_RFM69
                            #define MY_RFM69_FREQUENCY RF69_868MHZ // Set your frequency here
                            #define MY_IS_RFM69HW // Omit if your RFM is not "H"
                            #define MY_RF69_IRQ_PIN D1
                            #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
                            #define MY_RF69_SPI_CS D8 // NSS
                            #endif
                            #define MY_REPEATER_FEATURE
                            
                            
                            #define MY_GATEWAY_MQTT_CLIENT
                            #define MY_GATEWAY_ESP8266
                            
                            // Set this node's subscribe and publish topic prefix
                            //#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
                            //#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
                            
                            #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/MyMQTT"
                            #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/MyMQTT"
                            // Set MQTT client id
                            #define MY_MQTT_CLIENT_ID "mysensors-1"
                            
                            // Enable these if your MQTT broker requires usenrame/password
                            //#define MY_MQTT_USER "mosquitto"
                            //#define MY_MQTT_PASSWORD ""
                            
                            // Set WIFI SSID and password
                            #define MY_ESP8266_SSID "TP-LINK_B541"
                            #define MY_ESP8266_PASSWORD "xxxxxx"
                            
                            // Set the hostname for the WiFi Client. This is the hostname
                            // it will pass to the DHCP server if not static.
                            #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway"
                            
                            // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                            #define MY_IP_ADDRESS 192,168,1,77
                            
                            // If using static ip you need to define Gateway and Subnet address as well
                            #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                            #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                            
                            
                            // MQTT broker ip address.
                            #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1,200
                            
                            // The MQTT broker port to to open
                            #define MY_PORT 1883
                            
                            /*
                            // Enable inclusion mode
                            #define MY_INCLUSION_MODE_FEATURE
                            // Enable Inclusion mode button on gateway
                            #define MY_INCLUSION_BUTTON_FEATURE
                            // Set inclusion mode duration (in seconds)
                            #define MY_INCLUSION_MODE_DURATION 60
                            // Digital pin used for inclusion mode button
                            #define MY_INCLUSION_MODE_BUTTON_PIN  3
                            
                            // Set blinking period
                            #define MY_DEFAULT_LED_BLINK_PERIOD 300
                            
                            // Flash leds on rx/tx/err
                            #define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
                            #define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
                            #define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
                            */
                            
                            #include <ESP8266WiFi.h>
                            #include <MySensors.h>
                            
                            #define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                            #define NUMBER_OF_RELAYS 1 // Total number of attached relays
                            #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                            #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                            
                            void before()
                            {
                                for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                    // Then set relay pins in output mode
                                    pinMode(pin, OUTPUT);
                                    // Set relay to last known state (using eeprom storage)
                                    digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
                                }
                            }
                            
                            
                            void setup()
                            {
                            }
                            
                            void presentation()
                            {
                                // Send the sketch version information to the gateway and Controller
                                sendSketchInfo("Relay", "1.0");
                            
                                for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                    // Register all sensors to gw (they will be created as child devices)
                                    present(sensor, S_BINARY);
                                }
                            }
                            
                            void loop()
                            {
                            	// Send locally attech sensors data here
                            }
                            
                            void receive(const MyMessage &message)
                            {
                                // We only expect one type of message from controller. But we better check anyway.
                                if (message.type==V_STATUS) {
                                    // Change relay state
                                    digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                                    // Store state in eeprom
                                    saveState(message.sensor, message.getBool());
                                    // Write some debug info
                                    Serial.print("Incoming change for sensor:");
                                    Serial.print(message.sensor);
                                    Serial.print(", New status: ");
                                    Serial.println(message.getBool());
                                }
                            }
                            
                            

                            NODE

                            /**
                             * 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.
                             *
                             *******************************
                             *
                             * REVISION HISTORY
                             * Version 1.0 - Henrik Ekblad
                             *
                             * DESCRIPTION
                             * Motion Sensor example using HC-SR501
                             * http://www.mysensors.org/build/motion
                             *
                             */
                            
                            // Enable debug prints
                             #define MY_DEBUG
                            #define MY_NODE_ID 1
                            // Enable and select radio type attached
                            //#define MY_RADIO_NRF24
                            #define MY_RADIO_RFM69
                            
                            #include <MySensors.h>
                            
                            unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
                            #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                            #define CHILD_ID 1   // Id of the sensor child
                            
                            // Initialize motion message
                            MyMessage msg(CHILD_ID, V_TRIPPED);
                            
                            void setup()
                            {
                            	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                            
                            }
                            
                            void presentation()
                            {
                            	// Send the sketch version information to the gateway and Controller
                            	sendSketchInfo("Motion Sensor", "1.0");
                            
                            	// Register all sensors to gw (they will be created as child devices)
                            	present(CHILD_ID, S_MOTION);
                            }
                            
                            void loop()
                            {
                               
                            	// Read digital motion value
                            	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
                            
                            	Serial.println(tripped);
                            	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
                            
                            	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
                            	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR),CHANGE, SLEEP_TIME);
                            }
                            
                            AWIA Offline
                            AWIA Offline
                            AWI
                            Hero Member
                            wrote on last edited by AWI
                            #30

                            @mar.conte My best guess is that your node does not really "sleep" but that you are measuring an average current from the node (refer to my question to @Yveaux ). The power consumption during a "sleep" cannot be related to the gateway as there is no communication.

                            Differences between two gateways during transmission are probably related to communication issues (i.e. resends of information).

                            You can test the behaviour by putting your node in a "timed sleep": sleep(5000) // sleep 5 seconds and check power consumption.

                            mar.conteM 1 Reply Last reply
                            0
                            • mar.conteM mar.conte

                              @gohan
                              one thing I did not say that I have changed the gateway before it was all right (30 microah) when the gateway
                              was a esp Olimex evb, now I
                              downloaded the same sketch "gateway" on
                              esp8266 nodemecu dev kit and the node consumes me 420 microah !!

                              GATEWAY

                              /**
                               * 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.
                               *
                               *******************************
                               *
                               * REVISION HISTORY
                               * Version 1.0 - Henrik Ekblad
                               *
                               * DESCRIPTION
                               * The ESP8266 MQTT gateway sends radio network (or locally attached sensors) data to your MQTT broker.
                               * The node also listens to MY_MQTT_TOPIC_PREFIX and sends out those messages to the radio network
                               *
                               * LED purposes:
                               * - To use the feature, uncomment any of the MY_DEFAULT_xx_LED_PINs in your sketch
                               * - RX (green) - blink fast on radio message recieved. In inclusion mode will blink fast only on presentation recieved
                               * - TX (yellow) - blink fast on radio message transmitted. In inclusion mode will blink slowly
                               * - ERR (red) - fast blink on error during transmission error or recieve crc error
                               *
                               * See http://www.mysensors.org/build/esp8266_gateway for wiring instructions.
                               * nRF24L01+  ESP8266
                               * VCC        VCC
                               * CE         GPIO4
                               * CSN/CS     GPIO15
                               * SCK        GPIO14
                               * MISO       GPIO12
                               * MOSI       GPIO13
                               *
                               * Not all ESP8266 modules have all pins available on their external interface.
                               * This code has been tested on an ESP-12 module.
                               * The ESP8266 requires a certain pin configuration to download code, and another one to run code:
                               * - Connect REST (reset) via 10K pullup resistor to VCC, and via switch to GND ('reset switch')
                               * - Connect GPIO15 via 10K pulldown resistor to GND
                               * - Connect CH_PD via 10K resistor to VCC
                               * - Connect GPIO2 via 10K resistor to VCC
                               * - Connect GPIO0 via 10K resistor to VCC, and via switch to GND ('bootload switch')
                               *
                                * Inclusion mode button:
                               * - Connect GPIO5 via switch to GND ('inclusion switch')
                               *
                               * Hardware SHA204 signing is currently not supported!
                               *
                               * Make sure to fill in your ssid and WiFi password below for ssid & pass.
                               */
                              
                              
                              // Enable debug prints to serial monitor
                              #define MY_DEBUG
                              
                              // Use a bit lower baudrate for serial prints on ESP8266 than default in MyConfig.h
                              #define MY_BAUD_RATE 9600
                              
                              // Enables and select radio type (if attached)
                              //#define MY_RADIO_NRF24
                              #define MY_RADIO_RFM69
                              // Enable repeater functionality for this node
                              //#define MY_REPEATER_FEATURE
                              #ifdef ESP8266
                              #define MY_RADIO_RFM69
                              #define MY_RFM69_FREQUENCY RF69_868MHZ // Set your frequency here
                              #define MY_IS_RFM69HW // Omit if your RFM is not "H"
                              #define MY_RF69_IRQ_PIN D1
                              #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN
                              #define MY_RF69_SPI_CS D8 // NSS
                              #endif
                              #define MY_REPEATER_FEATURE
                              
                              
                              #define MY_GATEWAY_MQTT_CLIENT
                              #define MY_GATEWAY_ESP8266
                              
                              // Set this node's subscribe and publish topic prefix
                              //#define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway1-out"
                              //#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway1-in"
                              
                              #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/MyMQTT"
                              #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/MyMQTT"
                              // Set MQTT client id
                              #define MY_MQTT_CLIENT_ID "mysensors-1"
                              
                              // Enable these if your MQTT broker requires usenrame/password
                              //#define MY_MQTT_USER "mosquitto"
                              //#define MY_MQTT_PASSWORD ""
                              
                              // Set WIFI SSID and password
                              #define MY_ESP8266_SSID "TP-LINK_B541"
                              #define MY_ESP8266_PASSWORD "xxxxxx"
                              
                              // Set the hostname for the WiFi Client. This is the hostname
                              // it will pass to the DHCP server if not static.
                              #define MY_ESP8266_HOSTNAME "mqtt-sensor-gateway"
                              
                              // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP)
                              #define MY_IP_ADDRESS 192,168,1,77
                              
                              // If using static ip you need to define Gateway and Subnet address as well
                              #define MY_IP_GATEWAY_ADDRESS 192,168,1,1
                              #define MY_IP_SUBNET_ADDRESS 255,255,255,0
                              
                              
                              // MQTT broker ip address.
                              #define MY_CONTROLLER_IP_ADDRESS 192, 168, 1,200
                              
                              // The MQTT broker port to to open
                              #define MY_PORT 1883
                              
                              /*
                              // Enable inclusion mode
                              #define MY_INCLUSION_MODE_FEATURE
                              // Enable Inclusion mode button on gateway
                              #define MY_INCLUSION_BUTTON_FEATURE
                              // Set inclusion mode duration (in seconds)
                              #define MY_INCLUSION_MODE_DURATION 60
                              // Digital pin used for inclusion mode button
                              #define MY_INCLUSION_MODE_BUTTON_PIN  3
                              
                              // Set blinking period
                              #define MY_DEFAULT_LED_BLINK_PERIOD 300
                              
                              // Flash leds on rx/tx/err
                              #define MY_DEFAULT_ERR_LED_PIN 16  // Error led pin
                              #define MY_DEFAULT_RX_LED_PIN  16  // Receive led pin
                              #define MY_DEFAULT_TX_LED_PIN  16  // the PCB, on board LED
                              */
                              
                              #include <ESP8266WiFi.h>
                              #include <MySensors.h>
                              
                              #define RELAY_1  5  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
                              #define NUMBER_OF_RELAYS 1 // Total number of attached relays
                              #define RELAY_ON 1  // GPIO value to write to turn on attached relay
                              #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
                              
                              void before()
                              {
                                  for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                      // Then set relay pins in output mode
                                      pinMode(pin, OUTPUT);
                                      // Set relay to last known state (using eeprom storage)
                                      digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
                                  }
                              }
                              
                              
                              void setup()
                              {
                              }
                              
                              void presentation()
                              {
                                  // Send the sketch version information to the gateway and Controller
                                  sendSketchInfo("Relay", "1.0");
                              
                                  for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
                                      // Register all sensors to gw (they will be created as child devices)
                                      present(sensor, S_BINARY);
                                  }
                              }
                              
                              void loop()
                              {
                              	// Send locally attech sensors data here
                              }
                              
                              void receive(const MyMessage &message)
                              {
                                  // We only expect one type of message from controller. But we better check anyway.
                                  if (message.type==V_STATUS) {
                                      // Change relay state
                                      digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
                                      // Store state in eeprom
                                      saveState(message.sensor, message.getBool());
                                      // Write some debug info
                                      Serial.print("Incoming change for sensor:");
                                      Serial.print(message.sensor);
                                      Serial.print(", New status: ");
                                      Serial.println(message.getBool());
                                  }
                              }
                              
                              

                              NODE

                              /**
                               * 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.
                               *
                               *******************************
                               *
                               * REVISION HISTORY
                               * Version 1.0 - Henrik Ekblad
                               *
                               * DESCRIPTION
                               * Motion Sensor example using HC-SR501
                               * http://www.mysensors.org/build/motion
                               *
                               */
                              
                              // Enable debug prints
                               #define MY_DEBUG
                              #define MY_NODE_ID 1
                              // Enable and select radio type attached
                              //#define MY_RADIO_NRF24
                              #define MY_RADIO_RFM69
                              
                              #include <MySensors.h>
                              
                              unsigned long SLEEP_TIME = 0; // Sleep time between reports (in milliseconds)
                              #define DIGITAL_INPUT_SENSOR 3   // The digital input you attached your motion sensor.  (Only 2 and 3 generates interrupt!)
                              #define CHILD_ID 1   // Id of the sensor child
                              
                              // Initialize motion message
                              MyMessage msg(CHILD_ID, V_TRIPPED);
                              
                              void setup()
                              {
                              	pinMode(DIGITAL_INPUT_SENSOR, INPUT);      // sets the motion sensor digital pin as input
                              
                              }
                              
                              void presentation()
                              {
                              	// Send the sketch version information to the gateway and Controller
                              	sendSketchInfo("Motion Sensor", "1.0");
                              
                              	// Register all sensors to gw (they will be created as child devices)
                              	present(CHILD_ID, S_MOTION);
                              }
                              
                              void loop()
                              {
                                 
                              	// Read digital motion value
                              	bool tripped = digitalRead(DIGITAL_INPUT_SENSOR) == HIGH;
                              
                              	Serial.println(tripped);
                              	send(msg.set(tripped?"1":"0"));  // Send tripped value to gw
                              
                              	// Sleep until interrupt comes in on motion sensor. Send update every two minute.
                              	sleep(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR),CHANGE, SLEEP_TIME);
                              }
                              
                              YveauxY Offline
                              YveauxY Offline
                              Yveaux
                              Mod
                              wrote on last edited by
                              #31

                              @mar.conte I wouldn't worry about sub mA power consumption of a gateway, as it isn't supposed to sleep at all.
                              Furthermore you shouldn't blindly compare usage of different boards, as there are more components (e.g. power regulator) that influence the total consumption.

                              http://yveaux.blogspot.nl

                              AWIA 1 Reply Last reply
                              0
                              • YveauxY Yveaux

                                @mar.conte I wouldn't worry about sub mA power consumption of a gateway, as it isn't supposed to sleep at all.
                                Furthermore you shouldn't blindly compare usage of different boards, as there are more components (e.g. power regulator) that influence the total consumption.

                                AWIA Offline
                                AWIA Offline
                                AWI
                                Hero Member
                                wrote on last edited by AWI
                                #32

                                @Yveaux I think @mar-conte is talking about the consumption of the (battery powered) node, not the gateway..

                                YveauxY 1 Reply Last reply
                                0
                                • AWIA AWI

                                  @mar.conte My best guess is that your node does not really "sleep" but that you are measuring an average current from the node (refer to my question to @Yveaux ). The power consumption during a "sleep" cannot be related to the gateway as there is no communication.

                                  Differences between two gateways during transmission are probably related to communication issues (i.e. resends of information).

                                  You can test the behaviour by putting your node in a "timed sleep": sleep(5000) // sleep 5 seconds and check power consumption.

                                  mar.conteM Offline
                                  mar.conteM Offline
                                  mar.conte
                                  wrote on last edited by
                                  #33

                                  @AWI
                                  Ok i try with sleep(5000) this afternoon,
                                  One thing i dont say, the difference of consumption (30 micro or 420 micro) is if i power breadboard with atmega with arduino without mcu(usb 30micro); if I power same arduino mcu with jack 12 volt or I power breadboard with only 2 aa 1,5 the consumption is 420 micro

                                  M.C.

                                  AWIA 1 Reply Last reply
                                  0
                                  • mar.conteM mar.conte

                                    @AWI
                                    Ok i try with sleep(5000) this afternoon,
                                    One thing i dont say, the difference of consumption (30 micro or 420 micro) is if i power breadboard with atmega with arduino without mcu(usb 30micro); if I power same arduino mcu with jack 12 volt or I power breadboard with only 2 aa 1,5 the consumption is 420 micro

                                    AWIA Offline
                                    AWIA Offline
                                    AWI
                                    Hero Member
                                    wrote on last edited by
                                    #34

                                    @mar.conte Just to be sure... only if you remove the Arduino/ atmega328p/ mcu (e.g. no processor) the rest of components take 30 uA? :confused:

                                    mar.conteM 1 Reply Last reply
                                    0
                                    • AWIA AWI

                                      @Yveaux I think @mar-conte is talking about the consumption of the (battery powered) node, not the gateway..

                                      YveauxY Offline
                                      YveauxY Offline
                                      Yveaux
                                      Mod
                                      wrote on last edited by
                                      #35

                                      @AWI I think I'll stop responding to this thread...
                                      Too complicated for a simple guy like me :confused:

                                      http://yveaux.blogspot.nl

                                      1 Reply Last reply
                                      0
                                      • AWIA AWI

                                        @mar.conte Just to be sure... only if you remove the Arduino/ atmega328p/ mcu (e.g. no processor) the rest of components take 30 uA? :confused:

                                        mar.conteM Offline
                                        mar.conteM Offline
                                        mar.conte
                                        wrote on last edited by
                                        #36

                                        @AWI
                                        Configuration hardware is: arduino without mcu (with usb power) wire(3,3,gnd,reset,txrx)betwin this and breadboard (atmega+pir+rfm69): consumption 30micro; the same configuration with no usb power but with jack 12 volt consumption 420 micro.
                                        If i power breadboard without Arduino mculess but with 2 aa consumption 420 micro

                                        M.C.

                                        1 Reply Last reply
                                        0
                                        • AWIA AWI

                                          @Yveaux said in [SOLVED] Sleep dont run:

                                          "For indefinite sleeping, only level IRQ triggers are permitted (see AVR datasheet)."

                                          Thanks @Yveaux I thought I was losing it...:relaxed: Tried different options:
                                          sleep(INTERRUPT1, LOW, 0 ); // sleep and wait for motion :+1:
                                          sleep(INTERRUPT1, LOW, 5000 ); // sleep and wait for 5 secs :+1:
                                          sleep(INTERRUPT1, CHANGE, 0 ); // sleep and wait for motion :-1:
                                          but for the last op tion @mar-conte reported succes :confused: how come?

                                          My understanding is:

                                          • deep sleep: only LOW
                                          • timed sleep: LOW, CHANGE, RISING, FALLING
                                            or...?
                                          YveauxY Offline
                                          YveauxY Offline
                                          Yveaux
                                          Mod
                                          wrote on last edited by Yveaux
                                          #37

                                          This information is outdated. An error in the ATMega328P datasheet has been confirmed. See https://forum.mysensors.org/topic/6572/sleep-with-interrupt-only-works-with-level-low

                                          @AWI Ok, last reply :simple_smile:

                                          I'll have to dwell a little to explain how the AVR works and what its limitations are regarding sleeping, and how the MySensors library handles it.

                                          For AVR architecture, the MySensors library uses the 'Power-Down mode' when sleeping.
                                          I'll focus on ATMega328P here, for which the datasheet states the possible wake-up sources:

                                          0_1490722068118_upload-b2cbd80d-2c88-4e52-8bae-c46adb341c4f

                                          So in our case that's INT and WDT (TWI Address match is for i2c slave implementations).
                                          When a timeout parameter is passed to a sleep() function of the MySensors library the watchdog (WDT) will be used to wake after the specified timeout. If timeout is set to 0 (and wake-up from interrupts is specified) the watchdog will be completely disabled to save some more power.
                                          When an interrupt source is passed to a sleep() function of the library it will configure INT0 and/or INT1 to wake up the ATMega328.
                                          Note point 3, as only level interrupts (more precise LOW in case of ATMega328, thanks @AWI for reminding me) can be used as a wake-up source.
                                          Many posts here use RISING/FALLING/CHANGE as wake-up source for ATMega328 which is not supported by the ATMega328P and thus not supported by the MySensors library. Although people claim it is working for them you are on your own when using the chip out of spec and can expect strange behavior!

                                          The datasheet continues in detail on the power-down mode:

                                          0_1490721842267_upload-e4216667-02ab-4505-989f-e2b14c8edfaf

                                          The MySensors library disables brown-out to save some power. Serial interface address match and pin change interrupt are not used by the library.
                                          Pay special attention to the note: Waking the AVR from a INT0/INT1 interrupt will require the LOW level to remain for the startup-time, or the interrupt will not trigger. This means that only when the level is held long enough the library will be able to detect it woke from the external interrupt. If the level is not held at least the startup-time, it will assume it woke because of the total sleep time expired, and return MY_WAKE_UP_BY_TIMER (value -1).

                                          This start-up time depends on the clock frequency and fuse bits, which for e.g. an 8MHz Arduino Pro Mini comes down to 2ms.

                                          So just remember: In the MySensors library, only use LOW level interrupts to wake an ATMega328 from sleep and assure the interrupt level remains constant for at least the start-up time!

                                          @AWI Your third example is out-of spec (CHANGE interrupt) and behavior is therefore undefined. If it seems to work, you're lucky...

                                          This information is outdated. An error in the ATMega328P datasheet has been confirmed. See https://forum.mysensors.org/topic/6572/sleep-with-interrupt-only-works-with-level-low

                                          http://yveaux.blogspot.nl

                                          mar.conteM gohanG tonnerre33T 3 Replies Last reply
                                          5
                                          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