NodeManager, Domoticz, SmartSleep - how to use?



  • Hi, I have little experience with NodeManager (but like it) and I would like to use NodeManager with SmartSleep in Domoticz.
    I konw Domoticz does not support SmartSleep, it support HeartBeat however as far as I know.
    I have a NodeManager Thermistor sensor - it reports the temperature every 10 seconds for now, it works fine.
    What I need but don't know how to do is a NodeManager Relay sensor (Latching Relay later on) with SmartSleep - battery powered.
    I don't know how to send Relay OFF command from Domoticz when temperature is reported above 25 Celsius, immediately after Domoticz is receiving the Relay sensor HeartBeat.
    Or to send Relay ON command when temperature is reported below 25 Celsius.
    I read something about the Relay sensor sending a request just after sending its HeartBeat here but it is not clear to me how to modify the Relay sensor Arduino sketch:
    https://forum.mysensors.org/topic/5452/requesting-value-from-domoticz/14?loggedin

    My Relay NodeManager sketch:

    /*
      NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
    
      NodeManager includes the following main components:
      - Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
      - Power manager: allows powering on your sensors only while the node is awake
      - Battery manager: provides common functionalities to read and report the battery level
      - Remote configuration: allows configuring remotely the node without the need to have physical access to it
      - Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
    
      Documentation available on: https://github.com/mysensors/NodeManager
    
      pin 5 - TH
      pin 6 - 4K7 series resistor
      pin 7 - LED
      pin 8 - LED
    */
    
    // load user settings
    #include "config.h"
    // include supporting libraries
    #ifdef MY_GATEWAY_ESP8266
    #include <ESP8266WiFi.h>
    #endif
    // load MySensors library
    #include <MySensors.h>
    // load NodeManager library
    #include "NodeManager.h"
    
    // create a NodeManager instance
    NodeManager nodeManager;
    
    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);
      /*
         Register below your sensors
      */
      // [8] send NodeManager's the version back to the controller
      nodeManager.version();
      // to save battery the sensor can be optionally connected to two pins which will act as ground and vcc and activated on demand
      //nodeManager.setPowerPins(7,6,100);
      // [23] if enabled the pins will be automatically powered on while awake and off during sleeping (default: true)
      //nodeManager.setAutoPowerPins("TRUE");
      // configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
      //nodeManager.setInterrupt(3, 1, 1);
      // [11] the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7)
      nodeManager.setBatteryMin(1.8);
      // [12] the expected vcc when the batter is fully charged, used to calculate the percentage (default: 3.3)
      nodeManager.setBatteryMax(5.0);
      // [15] if true, the battery level will be evaluated by measuring the internal vcc without the need to connect any pin, if false the voltage divider methon will be used (default: true)
      nodeManager.setBatteryInternalVcc(1);
      // [17] After how many minutes the sensor will report back its measure (default: 10 minutes)
      nodeManager.setReportIntervalSeconds(10);
      // [40] after how many minutes report the battery level to the controller. When reset the battery is always reported (default: 60 minutes)
      nodeManager.setBatteryReportSeconds(30);
      // [3] set the duration (in seconds) of a sleep cycle
      nodeManager.setSleepSeconds(0);
    
      int relay = nodeManager.registerSensor(SENSOR_RELAY, 8);
      SensorRelay* relaySensor = ((SensorRelay*)nodeManager.getSensor(relay));
    
      /*
        int motion = nodeManager.registerSensor(SENSOR_MOTION, 3);
        SensorMotion* motionSensor = ((SensorMotion*)nodeManager.getSensor(motion));
        // [101] set the interrupt mode. Can be CHANGE, RISING, FALLING (default: CHANGE)
        motionSensor->setMode(3);
        motionSensor->setDebounce(500);
        motionSensor->setTriggerTime(3000);
      */
    
      /*
         Register above your sensors
      */
      nodeManager.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      nodeManager.presentation();
    
    }
    
    // setup
    void setup() {
      // call NodeManager setup routine
      nodeManager.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      nodeManager.loop();
    }
    
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      nodeManager.receive(message);
    }
    
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      nodeManager.receiveTime(ts);
    }
    

    My NodeManager Thermistor sketch:

    /*
      NodeManager is intended to take care on your behalf of all those common tasks a MySensors node has to accomplish, speeding up the development cycle of your projects.
    
      NodeManager includes the following main components:
      - Sleep manager: allows managing automatically the complexity behind battery-powered sensors spending most of their time sleeping
      - Power manager: allows powering on your sensors only while the node is awake
      - Battery manager: provides common functionalities to read and report the battery level
      - Remote configuration: allows configuring remotely the node without the need to have physical access to it
      - Built-in personalities: for the most common sensors, provide embedded code so to allow their configuration with a single line
    
      Documentation available on: https://github.com/mysensors/NodeManager
    
      pin 5 - TH
      pin 6 - 4K7 series resistor
      pin 7 - LED
      pin 8 - LED
    */
    
    // load user settings
    #include "config.h"
    // include supporting libraries
    #ifdef MY_GATEWAY_ESP8266
    #include <ESP8266WiFi.h>
    #endif
    // load MySensors library
    #include <MySensors.h>
    // load NodeManager library
    #include "NodeManager.h"
    
    // create a NodeManager instance
    NodeManager nodeManager;
    
    // before
    void before() {
      // setup the serial port baud rate
      Serial.begin(MY_BAUD_RATE);
      /*
         Register below your sensors
      */
      // [8] send NodeManager's the version back to the controller
      //nodeManager.version();
      // to save battery the sensor can be optionally connected to two pins which will act as ground and vcc and activated on demand
      nodeManager.setPowerPins(5,6,100);
      // [23] if enabled the pins will be automatically powered on while awake and off during sleeping (default: true)
      nodeManager.setAutoPowerPins("TRUE");
      // configure the interrupt pin and mode. Mode can be CHANGE, RISING, FALLING (default: MODE_NOT_DEFINED)
      //nodeManager.setInterrupt(3, 1, 1);
      // [11] the expected vcc when the batter is fully discharged, used to calculate the percentage (default: 2.7)
      nodeManager.setBatteryMin(1.8);
      // [12] the expected vcc when the batter is fully charged, used to calculate the percentage (default: 3.3)
      nodeManager.setBatteryMax(5.0);
      // [15] if true, the battery level will be evaluated by measuring the internal vcc without the need to connect any pin, if false the voltage divider methon will be used (default: true)
      nodeManager.setBatteryInternalVcc(1);
      // [17] After how many minutes the sensor will report back its measure (default: 10 minutes)
      nodeManager.setReportIntervalSeconds(10);
      // [40] after how many minutes report the battery level to the controller. When reset the battery is always reported (default: 60 minutes)
      nodeManager.setBatteryReportSeconds(30);
      // [3] set the duration (in seconds) of a sleep cycle
      nodeManager.setSleepSeconds(10);
    
      int sensor_tmp = nodeManager.registerSensor(SENSOR_THERMISTOR, A0);
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setPowerPins(5,6,100);
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setSamples(3);
      // [101] resistance at 25 degrees C (default: 10000)
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setNominalResistor(4700);
      // [102] temperature for nominal resistance (default: 25)
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setNominalTemperature(25);
      // [103] The beta coefficient of the thermistor (default: 3950)
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setBCoefficient(3950);
      // [104] the value of the resistor in series with the thermistor (default: 10000)
      ((SensorThermistor*)nodeManager.getSensor(sensor_tmp))->setSeriesResistor(4700);
      // [105] set a temperature offset
      //void setOffset(float value);
    
      //int relay = nodeManager.registerSensor(SENSOR_RELAY, 7);
      //SensorRelay* relaySensor = ((SensorRelay*)nodeManager.getSensor(relay));
    
      /*
        int motion = nodeManager.registerSensor(SENSOR_MOTION, 3);
        SensorMotion* motionSensor = ((SensorMotion*)nodeManager.getSensor(motion));
        // [101] set the interrupt mode. Can be CHANGE, RISING, FALLING (default: CHANGE)
        motionSensor->setMode(3);
        motionSensor->setDebounce(500);
        motionSensor->setTriggerTime(3000);
      */
    
      /*
         Register above your sensors
      */
      nodeManager.before();
    }
    
    // presentation
    void presentation() {
      // call NodeManager presentation routine
      nodeManager.presentation();
    
    }
    
    // setup
    void setup() {
      //pinMode(RED_LED, OUTPUT);
      //digitalWrite(RED_LED, HIGH);
      // call NodeManager setup routine
      nodeManager.setup();
    }
    
    // loop
    void loop() {
      // call NodeManager loop routine
      nodeManager.loop();
    }
    
    // receive
    void receive(const MyMessage &message) {
      // call NodeManager receive routine
      nodeManager.receive(message);
    }
    
    // receiveTime
    void receiveTime(unsigned long ts) {
      // call NodeManager receiveTime routine
      nodeManager.receiveTime(ts);
    }```
    
    Can anyone help please?

Log in to reply
 

Suggested Topics

  • 5
  • 2
  • 8
  • 5
  • 4
  • 5

62
Online

11.4k
Users

11.1k
Topics

112.6k
Posts