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. Round-about way to make a sleepable relay node

Round-about way to make a sleepable relay node

Scheduled Pinned Locked Moved Development
3 Posts 2 Posters 801 Views 3 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.
  • dsieeD Offline
    dsieeD Offline
    dsiee
    wrote on last edited by dsiee
    #1

    Hi all,

    I'm trying to make a node which is solar powered to control a few relays to automate our sprinklers. In order to get power consumption to a reasonable, sustainable level i will need to sleep the nodes.

    In order to allow the nodes to sleep without missing their messages to change state i am considereing employing a middle man node which the controller changes the state of the sprinkler on then the actual sprinkler nodes wake up, request the sprinkler state from the middle man node and change their state to suit. If the middle man node doesn't hear from the sprinkler node for a set period of time (say 10 mins) it changes the state of the sprinkler back to the original and pushes this change to the gateway (and thus controller) in the same way a button would.

    Here is a crappy diagram of what im trying to achieve-
    diagram dropbox link it that doesn't work https://www.dropbox.com/s/amhwu6maicnxi5p/middle man node diagram.png?dl=0

    I'm encountering one main issues implementing this approach-

    1- using the Requesting data function- how do i specify the varible i want? say the middle na node has an array of 20 sprinklers, what sprinkler node they are attached to, and their state. can i send the request for var1 meaning sprinkler one for the current node (node n) and then in the middle man node extract the destination node (the sprinkler node) id along with which custom variable requested (1 to 5) to tell which of the multiple attached sprinklers to turn on? Is there an example sketch using the request data function to get data from another node i can see (i couldn't find one)?

    it is mainly the "handle the reply message yourself in the destination node" and extracting the node and sensor id from the state request message recieved by the middle man node parts i cannot solve. Can i just construct the msg using the constructors here http://www.mysensors.org/download/sensor_api_15#MyMessage ? judging from the message stucture the sending nodes id isn't included in the header, how is the middle man node to determine who to send the data back to?

    sorry for all the questions, they seem little and i could probably resolve them myself if anyone has some examples of a node getting and receiving a variable from another node. Thanks for any and all input everyone!

    BTW- Currently i have the nodes built and was planing on waiting for a controller to implement the smart sleep feature in mysensors 1.5, however i have given up on waiting. Adding the feature to domotics was beyond my abilities (i tried) unfortunately).

    BartEB 1 Reply Last reply
    0
    • dsieeD dsiee

      Hi all,

      I'm trying to make a node which is solar powered to control a few relays to automate our sprinklers. In order to get power consumption to a reasonable, sustainable level i will need to sleep the nodes.

      In order to allow the nodes to sleep without missing their messages to change state i am considereing employing a middle man node which the controller changes the state of the sprinkler on then the actual sprinkler nodes wake up, request the sprinkler state from the middle man node and change their state to suit. If the middle man node doesn't hear from the sprinkler node for a set period of time (say 10 mins) it changes the state of the sprinkler back to the original and pushes this change to the gateway (and thus controller) in the same way a button would.

      Here is a crappy diagram of what im trying to achieve-
      diagram dropbox link it that doesn't work https://www.dropbox.com/s/amhwu6maicnxi5p/middle man node diagram.png?dl=0

      I'm encountering one main issues implementing this approach-

      1- using the Requesting data function- how do i specify the varible i want? say the middle na node has an array of 20 sprinklers, what sprinkler node they are attached to, and their state. can i send the request for var1 meaning sprinkler one for the current node (node n) and then in the middle man node extract the destination node (the sprinkler node) id along with which custom variable requested (1 to 5) to tell which of the multiple attached sprinklers to turn on? Is there an example sketch using the request data function to get data from another node i can see (i couldn't find one)?

      it is mainly the "handle the reply message yourself in the destination node" and extracting the node and sensor id from the state request message recieved by the middle man node parts i cannot solve. Can i just construct the msg using the constructors here http://www.mysensors.org/download/sensor_api_15#MyMessage ? judging from the message stucture the sending nodes id isn't included in the header, how is the middle man node to determine who to send the data back to?

      sorry for all the questions, they seem little and i could probably resolve them myself if anyone has some examples of a node getting and receiving a variable from another node. Thanks for any and all input everyone!

      BTW- Currently i have the nodes built and was planing on waiting for a controller to implement the smart sleep feature in mysensors 1.5, however i have given up on waiting. Adding the feature to domotics was beyond my abilities (i tried) unfortunately).

      BartEB Offline
      BartEB Offline
      BartE
      Contest Winner
      wrote on last edited by
      #2

      @dsiee This answer is to explain the basics for node 2 node communications

      To respond to node 2 node requests the incomingMessage() function needs to be changed in such a way that it responds to requests
      In this example, for the answering node, one can request for temperature, humidity and pressure

      void incomingMessage(const MyMessage &message) 
      {
         //  Check for incoming node to node request
         if (mGetCommand(message) == C_REQ) {
               MyMessage msg;
               mSetCommand(msg, C_SET);
               msg.setType(message.type);
               msg.setSensor(message.sensor);
               msg.setDestination(message.sender);
               bool bHandled = true;
               switch (message.sensor) {
                 case CHILD_ID_HUM:
                     msg.setType(V_HUM);
                     msg.set(lastHum, 1);
                     break;
                     
                 case CHILD_ID_TEMP:
                     msg.setType(V_TEMP);
                     msg.set(lastTemp, 1);
                     break;
      
                 case CHILD_ID_BARO:
                     msg.setType(V_PRESSURE);
                     msg.set(lastPressure, 0);
                     break;
      
                default:
                     bHandled = false; 
                     break;
               }
               if (bHandled) {
                   gw.send(msg); 
               }
          } else {
             // do normal message handling stuff
             switch  (message.type) {
                 case V_STATUS:
                     // Do something useful
                     break;
          }
      }
      

      With this call one can perform the request

      gw.request( TEMP_SENS_ID,  V_TEMP, WEATHER_NODE_ID);
      

      And the requesting node should hande incoming data in incomingMessage()

      void incomingMessage(const MyMessage &message) {
         // We only expect one type of message from controller. But we better check anyway.
         if (message.isAck()) {
             Serial.println(F("GW ack"));
         }
        switch (message.type) {
      	case V_TEMP:
      	   // Write some debug info
      	   Serial.print(F("Temp received: "));
      	   Serial.print(message.sensor);
      	   Serial.print(F(" : "));
      	   Serial.println((int)message.getFloat());
      	   break;
      
      	case V_HUM:
      	   // Write some debug info
      	   Serial.print(F("Humidity received: "));
      	   Serial.print(message.sensor);
      	   Serial.print(F(" : "));
      	   Serial.println(message.getInt(), HEX);
      	   break;
      
      	case V_PRESSURE:
      	   // Write some debug info
      	   Serial.print(F("Pressure received: "));
      	   Serial.print(message.sensor);
      	   Serial.print(F(" : "));
      	   Serial.println(message.getInt());
      	   break;
         }
      }
      
      1 Reply Last reply
      1
      • dsieeD Offline
        dsieeD Offline
        dsiee
        wrote on last edited by
        #3

        @BartE Thanks so much! That explains just about everything i needed. Glad the see that message.sender exists as it was integral to my plan of attack!

        Thanks again, I really appreciate it!

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


        23

        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