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. Development
  3. NodeManager
  4. Nodemanager: How to control a local output from a local input?

Nodemanager: How to control a local output from a local input?

Scheduled Pinned Locked Moved NodeManager
2 Posts 1 Posters 31 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    A3V
    wrote on last edited by
    #1

    I am trying to make a temperature control system that has a temperature sensor and a relay.
    I use an ESP32 and set it op as gateway. The sensor and relay are connected to the ESP32
    The sensor and relay should form a closed loop and should be able to run independently from the (Domoticz) controller.
    I want to use the Nodemanager to be able to track the temperature and relay state.
    In my first test I can read my sensor and I can switch my relay from Domoticz.
    I tried to add some code to the loop() to read the temperature locally and print it to the serial port:
    When I e.g. try to print Tsensor.getChild(0)->getValueString() it throws an error.
    My question: what is the proper way to do this?
    How can I get the sensor value and set the relay?
    Any suggestions are much appreciated

    1 Reply Last reply
    0
    • A Offline
      A Offline
      A3V
      wrote on last edited by
      #2

      Reply to myself:
      Looking thought the sources and the forum found out that you can do this using hooks.
      so enabled hooking

      #define NODEMANAGER_HOOKING ON
      

      and added the reference to the hook to before.

      void before() {
       Tsensor.setMeasureTimerMode(TIME_INTERVAL);   // set timer 
       Tsensor.setMeasureTimerValue(1); // interval to 1 sec measurement
      
       Tsensor.setPostLoopHook(&myfirstHook);
       ..etc.etc...
       nodemanager.before();
      }
      

      And finally the hook

      void myfirstHook(Sensor* sensor){
        float temperature =  Tsensor.children.get(1)->getValueFloat()
        Serial.println(temperature);
        if (temperature>setpoint) { 
              if (Relay.getStatus()==OFF){
              Relay.setStatus(ON);      // switch off
              } 
        
      
      }
      

      The error that I got initially was caused by using the wrong child: 0 (it starts from 1).

      I wonder if it is possible to do interval < 1 second?

      1 Reply Last reply
      1
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      13

      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