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 816 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

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

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

      With your input, this post could be even better 💗

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


      17

      Online

      12.0k

      Users

      11.2k

      Topics

      113.4k

      Posts


      Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • MySensors
      • OpenHardware.io
      • Categories
      • Recent
      • Tags
      • Popular