Aller directement au contenu
  • MySensors
  • OpenHardware.io
  • Categories
  • Récent
  • Mots-clés
  • Populaire
Habillages
  • 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

  • Défaut (Aucun habillage)
  • Aucun habillage
Réduire
Logo
  1. Accueil
  2. Development
  3. MySensors - Get Temperature value from another node through the Gateway

MySensors - Get Temperature value from another node through the Gateway

Planifier Épinglé Verrouillé Déplacé Development
36 Messages 7 Publieurs 5.7k Vues 6 Watching
  • Du plus ancien au plus récent
  • Du plus récent au plus ancien
  • Les plus votés
Répondre
  • Répondre à l'aide d'un nouveau sujet
Se connecter pour répondre
Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
  • J Hors-ligne
    J Hors-ligne
    Joe13
    a écrit sur dernière édition par
    #1

    Hi Everyone,
    I did search for this in several place, however could not find a solution.
    I have a node that gets the temp and hum in Room1 and sends these data to the Domoticz controller.
    Now i have another node with LCD in Room2. How can i display the temp and hum of Room1 node onto the Room2 LCD.

    So far it I have put the below code, but the value comes in as 0. The Room1 temp child Id is 12

    void loop() 
    {
      delay(10000);
      request(12, V_VAR1, 0);
      Serial.print("Requested temp from gw VAR1");
      
    
    }
    
    void receive(const MyMessage &message) {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_VAR1) {
         // Change relay state
       //  digitalWrite(RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        
         // Write some debug info
         Serial.print("Incoming change for sensor:");
         Serial.print(message.sensor);
         Serial.print(", New status: ");
         Serial.println(message.getInt());
       } 
    }
    

    Serial monitor Output

    517420 TSF:MSG:SEND,1-1-0-0,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
    Requested temp from gw VAR1517427 TSF:MSG:READ,0-0-1,s=12,c=2,t=24,pt=0,l=0,sg=0:
    Incoming change for sensor:12, New status: 0
    

    Hope someone can provide some insight on this.
    thanks

    mfalkviddM 1 réponse Dernière réponse
    0
    • J Joe13

      Hi Everyone,
      I did search for this in several place, however could not find a solution.
      I have a node that gets the temp and hum in Room1 and sends these data to the Domoticz controller.
      Now i have another node with LCD in Room2. How can i display the temp and hum of Room1 node onto the Room2 LCD.

      So far it I have put the below code, but the value comes in as 0. The Room1 temp child Id is 12

      void loop() 
      {
        delay(10000);
        request(12, V_VAR1, 0);
        Serial.print("Requested temp from gw VAR1");
        
      
      }
      
      void receive(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_VAR1) {
           // Change relay state
         //  digitalWrite(RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
          
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", New status: ");
           Serial.println(message.getInt());
         } 
      }
      

      Serial monitor Output

      517420 TSF:MSG:SEND,1-1-0-0,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
      Requested temp from gw VAR1517427 TSF:MSG:READ,0-0-1,s=12,c=2,t=24,pt=0,l=0,sg=0:
      Incoming change for sensor:12, New status: 0
      

      Hope someone can provide some insight on this.
      thanks

      mfalkviddM Hors-ligne
      mfalkviddM Hors-ligne
      mfalkvidd
      Mod
      a écrit sur dernière édition par mfalkvidd
      #2

      Hi @joe13, welcome to the MySensors community!
      I haven't tried this myself, but I think the 0 in

      request(12, V_VAR1, 0);
      

      needs to be changed to the id of the node in Room 1. Could you try that?

      Documentation reference: https://www.mysensors.org/download/sensor_api_20#requesting-data

      1 réponse Dernière réponse
      0
      • J Hors-ligne
        J Hors-ligne
        Joe13
        a écrit sur dernière édition par
        #3

        Hi @mfalkvidd thanks. Yes my first post.
        I did try that, however, there is no response in the Receive part in the Serial Monitor

        void loop() 
        {
          delay(10000);
          request(12, V_VAR1,3);
          Serial.print("Requested temp from gw VAR1");
          
        
        }
        
        void receive(const MyMessage &message) {
          // We only expect one type of message from controller. But we better check anyway.
          if (message.type==V_VAR1) {
        
            
             // Write some debug info
             Serial.print("Incoming change for sensor:");
             Serial.print(message.sensor);
             Serial.print(", New status: ");
             Serial.println(message.getFloat());
           } 
        }
        

        Serial monitor output after setting Node id (3) instead of Gateway(0)

        Requested temp from gw VAR122279 !TSF:MSG:SEND,1-1-0-3,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=NACK:
        Requested temp from gw VAR132287 TSF:MSG:SEND,1-1-0-3,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=1,st=OK:
        Requested temp from gw VAR142296 TSF:MSG:SEND,1-1-0-3,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
        Requested temp from gw VAR152303 TSF:MSG:SEND,1-1-0-3,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
        Requested temp from gw VAR162311 TSF:MSG:SEND,1-1-0-3,s=12,c=2,t=24,pt=0,l=0,sg=0,ft=0,st=OK:
        
        1 réponse Dernière réponse
        0
        • gohanG Hors-ligne
          gohanG Hors-ligne
          gohan
          Mod
          a écrit sur dernière édition par
          #4

          I would approach the problem on the opposite direction, I'd send the temperature to gateway and also to the node with display, so if your temperature node is a sleeping node it would just send when it wakes up and you get your temperature displayed

          J 1 réponse Dernière réponse
          0
          • gohanG gohan

            I would approach the problem on the opposite direction, I'd send the temperature to gateway and also to the node with display, so if your temperature node is a sleeping node it would just send when it wakes up and you get your temperature displayed

            J Hors-ligne
            J Hors-ligne
            Joe13
            a écrit sur dernière édition par
            #5

            @gohan but isn't there a way to get the Temp from the Gateway. I am getting some sort of Receive msg (based on the my initial post) but the value is 0.
            in this way, i can request the temp from the GW whenever required and not ask the node to send the data every few mins

            1 réponse Dernière réponse
            0
            • gohanG Hors-ligne
              gohanG Hors-ligne
              gohan
              Mod
              a écrit sur dernière édition par
              #6

              The gateway doesn't store any data. You could request data from controller if you have one running.

              J 1 réponse Dernière réponse
              1
              • gohanG gohan

                The gateway doesn't store any data. You could request data from controller if you have one running.

                J Hors-ligne
                J Hors-ligne
                Joe13
                a écrit sur dernière édition par Joe13
                #7

                @gohan Yes that would be great. i have Domoticz running and the temp shows up there. could you let me know how I can get the temp from the controller.
                I found this link and that is the code that i initially tried https://www.domoticz.com/forum/viewtopic.php?t=9708
                but gives an O/P of 0

                1 réponse Dernière réponse
                0
                • gohanG Hors-ligne
                  gohanG Hors-ligne
                  gohan
                  Mod
                  a écrit sur dernière édition par gohan
                  #8

                  I have never done it myself, but I'd start looking at the pulse energy meter as it has a function to retrieve a sensor value from controller

                  The code in that post is for the old mysensors version

                  J 1 réponse Dernière réponse
                  0
                  • gohanG gohan

                    I have never done it myself, but I'd start looking at the pulse energy meter as it has a function to retrieve a sensor value from controller

                    The code in that post is for the old mysensors version

                    J Hors-ligne
                    J Hors-ligne
                    Joe13
                    a écrit sur dernière édition par Joe13
                    #9

                    @gohan i did convert it to the 2.1V but the result is the same. so if you were to do something like this, show all the temps from different rooms(nodes) on a central LCD placed in the hall, how would you go about it. I am just a beginner so an ideal way would be great.
                    The Pulse energy meter code tell " Received last pulse count from gw:" so could it be possible to get values from GW.

                    1 réponse Dernière réponse
                    0
                    • gohanG Hors-ligne
                      gohanG Hors-ligne
                      gohan
                      Mod
                      a écrit sur dernière édition par
                      #10

                      As said before I'd go for the node to node communication, so send the temperature also to the lcd node, or you could also use an esp8266 and read the the mqtt messages from topic domoticz/out that domoticz sends every time there is a change in the controller data.

                      J 1 réponse Dernière réponse
                      0
                      • gohanG gohan

                        As said before I'd go for the node to node communication, so send the temperature also to the lcd node, or you could also use an esp8266 and read the the mqtt messages from topic domoticz/out that domoticz sends every time there is a change in the controller data.

                        J Hors-ligne
                        J Hors-ligne
                        Joe13
                        a écrit sur dernière édition par
                        #11

                        @gohan thanks, but i do not have much knowledge on ESP8266 and mqtt but will give the a try to push data from the node to the LCD node

                        1 réponse Dernière réponse
                        0
                        • J Hors-ligne
                          J Hors-ligne
                          Joe13
                          a écrit sur dernière édition par
                          #12

                          anyone who has tried pulling value from GW or controller to a different node, please let me know on how you did it. thanks

                          K 1 réponse Dernière réponse
                          0
                          • J Joe13

                            anyone who has tried pulling value from GW or controller to a different node, please let me know on how you did it. thanks

                            K Hors-ligne
                            K Hors-ligne
                            kimot
                            a écrit sur dernière édition par kimot
                            #13

                            @joe13
                            I think, you must send temperature ( for later resending) to domoticz like V_VAR1 for storing it, and then requested it again like V_VAR1. Do not use V_TEMP for this.
                            Look at V_VAR like universal variable for storing anything.
                            At your code examples is not evident, what you put to V_VAR1 first, maybe nothing, so do not be disappointed, if you read 0 back.
                            At EnergyCounter Sensor you can see:

                            MyMessage wattMsg(CHILD_ID,V_WATT);
                            MyMessage kwhMsg(CHILD_ID,V_KWH);
                            MyMessage pcMsg(CHILD_ID,V_VAR1);    !!!!!!
                            ....
                            
                            send(wattMsg.set(watt));
                            send(kwhMsg.set(kwh, 4));  // Send kwh value to gw
                            send(pcMsg.set(pulseCount));  // Send pulse count value to gw         !!!!!!
                             .....
                            
                            request(CHILD_ID, V_VAR1);
                            
                            
                            

                            So it sends to domoticz not only W and kWh for displaying it, but pulse for storing and reading later too.

                            But like wrote gohan, I think better way is sending temperature from node twice - to domoticz and to LCD node. This will work even if domoticz will bee down.

                            J 1 réponse Dernière réponse
                            1
                            • K kimot

                              @joe13
                              I think, you must send temperature ( for later resending) to domoticz like V_VAR1 for storing it, and then requested it again like V_VAR1. Do not use V_TEMP for this.
                              Look at V_VAR like universal variable for storing anything.
                              At your code examples is not evident, what you put to V_VAR1 first, maybe nothing, so do not be disappointed, if you read 0 back.
                              At EnergyCounter Sensor you can see:

                              MyMessage wattMsg(CHILD_ID,V_WATT);
                              MyMessage kwhMsg(CHILD_ID,V_KWH);
                              MyMessage pcMsg(CHILD_ID,V_VAR1);    !!!!!!
                              ....
                              
                              send(wattMsg.set(watt));
                              send(kwhMsg.set(kwh, 4));  // Send kwh value to gw
                              send(pcMsg.set(pulseCount));  // Send pulse count value to gw         !!!!!!
                               .....
                              
                              request(CHILD_ID, V_VAR1);
                              
                              
                              

                              So it sends to domoticz not only W and kWh for displaying it, but pulse for storing and reading later too.

                              But like wrote gohan, I think better way is sending temperature from node twice - to domoticz and to LCD node. This will work even if domoticz will bee down.

                              J Hors-ligne
                              J Hors-ligne
                              Joe13
                              a écrit sur dernière édition par Joe13
                              #14

                              @kimot that part i missed. thanks for pointing that out. I will give this option also a try. its just that the other sensors that are in the other rooms are already set in place and I do not want to pluck them out and recode them. So pulling the values from the GW would have been an advantage. But anyways, if that is the way to go, then Ill probably do that.
                              Thanks everyone for your inputs

                              1 réponse Dernière réponse
                              1
                              • ben999B Hors-ligne
                                ben999B Hors-ligne
                                ben999
                                a écrit sur dernière édition par ben999
                                #15

                                Hi all,

                                Sorry to jump in. If my post is off-topic please say so and i will start a new thread

                                I am in the process of doing the same: a temp/hum node and a node with LCD displaying temp and hum

                                Many-many questions :

                                • all messages (even node-to-node ones) go through gateway and controller ?
                                • sending request(CHILD_ID, V_VAR1) does not mention the node's ID... i just can't get my head round this... there could be many sensors handling the same variable type with the same child id... ? So how do we know we will be getting data from the right node and sensor (child) ?
                                • sending request(CHILD_ID, V_VAR1) will actually ask the controller to ask the node to send its data? Or does it request data straight from node?
                                • isn't there a simple way for nodes to fetch data (data coming from itself and from other nodes) from controller?

                                Thanks for your help

                                rejoe2R 1 réponse Dernière réponse
                                0
                                • ben999B ben999

                                  Hi all,

                                  Sorry to jump in. If my post is off-topic please say so and i will start a new thread

                                  I am in the process of doing the same: a temp/hum node and a node with LCD displaying temp and hum

                                  Many-many questions :

                                  • all messages (even node-to-node ones) go through gateway and controller ?
                                  • sending request(CHILD_ID, V_VAR1) does not mention the node's ID... i just can't get my head round this... there could be many sensors handling the same variable type with the same child id... ? So how do we know we will be getting data from the right node and sensor (child) ?
                                  • sending request(CHILD_ID, V_VAR1) will actually ask the controller to ask the node to send its data? Or does it request data straight from node?
                                  • isn't there a simple way for nodes to fetch data (data coming from itself and from other nodes) from controller?

                                  Thanks for your help

                                  rejoe2R Hors-ligne
                                  rejoe2R Hors-ligne
                                  rejoe2
                                  a écrit sur dernière édition par
                                  #16

                                  @ben999 If you do node-to-node communication, the message does not necessarily need a controller; it is routed through the lowest common repeater node (this might be the gateway). Eg. if you have two nodes 5 and 6 that are communicating over node 4 with the gw, the gw may not even see the message.
                                  Coding then looks like this:

                                  send(SisternodeMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_SISTER_TEMP).set(temperature, 1));
                                  

                                  In case you use a controller, you would have to map the values through the controller's functionality (eg. put temperature value #2 from node 5 to value2100 on node 6 so this can be requested from node #6 using it's own ID and child ID 100 - V_VAR2.

                                  In both cases you have to code appropriate receive()-functionality.

                                  Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                  ben999B 1 réponse Dernière réponse
                                  2
                                  • rejoe2R rejoe2

                                    @ben999 If you do node-to-node communication, the message does not necessarily need a controller; it is routed through the lowest common repeater node (this might be the gateway). Eg. if you have two nodes 5 and 6 that are communicating over node 4 with the gw, the gw may not even see the message.
                                    Coding then looks like this:

                                    send(SisternodeMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_SISTER_TEMP).set(temperature, 1));
                                    

                                    In case you use a controller, you would have to map the values through the controller's functionality (eg. put temperature value #2 from node 5 to value2100 on node 6 so this can be requested from node #6 using it's own ID and child ID 100 - V_VAR2.

                                    In both cases you have to code appropriate receive()-functionality.

                                    ben999B Hors-ligne
                                    ben999B Hors-ligne
                                    ben999
                                    a écrit sur dernière édition par
                                    #17

                                    If you do node-to-node communication, the message does not necessarily need a controller; it is routed through the lowest common repeater node (this might be the gateway). Eg. if you have two nodes 5 and 6 that are communicating over node 4 with the gw, the gw may not even see the message.
                                    Coding then looks like this:

                                    send(SisternodeMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_SISTER_TEMP).set(temperature, 1));
                                    

                                    That makes sense, big thumbs up, thanks a lot

                                    On the other hand I didn't understant a word of that... sorry...
                                    Could you please detail a wee bit more? And also please explain who is doing what...

                                    In case you use a controller, you would have to map the values through the controller's functionality (eg. put temperature value #2 from node 5 to value2100 on node 6 so this can be requested from node #6 using it's own ID and child ID 100 - V_VAR2.

                                    I should be able to do that :)

                                    In both cases you have to code appropriate receive()-functionality.

                                    Thanks a lot for your help

                                    rejoe2R 1 réponse Dernière réponse
                                    0
                                    • ben999B ben999

                                      If you do node-to-node communication, the message does not necessarily need a controller; it is routed through the lowest common repeater node (this might be the gateway). Eg. if you have two nodes 5 and 6 that are communicating over node 4 with the gw, the gw may not even see the message.
                                      Coding then looks like this:

                                      send(SisternodeMsg.setDestination(MY_SISTER_NODE_ID).setSensor(CHILD_ID_SISTER_TEMP).set(temperature, 1));
                                      

                                      That makes sense, big thumbs up, thanks a lot

                                      On the other hand I didn't understant a word of that... sorry...
                                      Could you please detail a wee bit more? And also please explain who is doing what...

                                      In case you use a controller, you would have to map the values through the controller's functionality (eg. put temperature value #2 from node 5 to value2100 on node 6 so this can be requested from node #6 using it's own ID and child ID 100 - V_VAR2.

                                      I should be able to do that :)

                                      In both cases you have to code appropriate receive()-functionality.

                                      Thanks a lot for your help

                                      rejoe2R Hors-ligne
                                      rejoe2R Hors-ligne
                                      rejoe2
                                      a écrit sur dernière édition par
                                      #18

                                      @ben999 I also had a hard time to sort things out wrt. to node-to-node communication. But in the end, its simple:
                                      You just have to use appropriate send()- and recieve() commands in the nodes. Example for the temperature part, using the node numbers from above:

                                      • For the one providing the needed info (node 5): This one is measuring temp and sends this to node 6: In the code for this node use additionally to the "normal" send() the above code and replace "MY_SISTER_NODE_ID" with 6 and "CHILD_ID_SISTER_TEMP" let's say with 101 (or use appropriate #define's).
                                      • In the receive() part of Node 6 you have to sort things by using the correspondant Child ID as follows:
                                      if (message.sensor == 101) {...
                                      

                                      I personally prefer using "speaking names" like CHILD_ID_SISTER_TEMP and define them in the header, that's what's behind the first send() code-snipplet, but that's just a question of style.

                                      Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                      ben999B 1 réponse Dernière réponse
                                      2
                                      • rejoe2R rejoe2

                                        @ben999 I also had a hard time to sort things out wrt. to node-to-node communication. But in the end, its simple:
                                        You just have to use appropriate send()- and recieve() commands in the nodes. Example for the temperature part, using the node numbers from above:

                                        • For the one providing the needed info (node 5): This one is measuring temp and sends this to node 6: In the code for this node use additionally to the "normal" send() the above code and replace "MY_SISTER_NODE_ID" with 6 and "CHILD_ID_SISTER_TEMP" let's say with 101 (or use appropriate #define's).
                                        • In the receive() part of Node 6 you have to sort things by using the correspondant Child ID as follows:
                                        if (message.sensor == 101) {...
                                        

                                        I personally prefer using "speaking names" like CHILD_ID_SISTER_TEMP and define them in the header, that's what's behind the first send() code-snipplet, but that's just a question of style.

                                        ben999B Hors-ligne
                                        ben999B Hors-ligne
                                        ben999
                                        a écrit sur dernière édition par
                                        #19

                                        @rejoe2 GREAT! You gave sense to all that. Is it what some clever blokes refer to "dummy sensor" method?

                                        May I ask some more @rejoe2 ?
                                        How would you retrieve a value DIRECTLY FROM the controller?
                                        Say that node 5 and 6 sleep most of their time... so they never get to speak directly to each other. Then the controller would be the mail box... I already send temp data to the controller and get it displayed in PaperUI and iOS app (using openHab). How would node 6 fetch this piece of data?

                                        Once more, thanks a lot for your time and patience (it's not easy eaducating people :D )

                                        rejoe2R 1 réponse Dernière réponse
                                        0
                                        • ben999B ben999

                                          @rejoe2 GREAT! You gave sense to all that. Is it what some clever blokes refer to "dummy sensor" method?

                                          May I ask some more @rejoe2 ?
                                          How would you retrieve a value DIRECTLY FROM the controller?
                                          Say that node 5 and 6 sleep most of their time... so they never get to speak directly to each other. Then the controller would be the mail box... I already send temp data to the controller and get it displayed in PaperUI and iOS app (using openHab). How would node 6 fetch this piece of data?

                                          Once more, thanks a lot for your time and patience (it's not easy eaducating people :D )

                                          rejoe2R Hors-ligne
                                          rejoe2R Hors-ligne
                                          rejoe2
                                          a écrit sur dernière édition par rejoe2
                                          #20

                                          @ben999 You are welcome.
                                          For "indirect" communication you may use the V_VARx-method already mentionned. This requires the controller to have the requested info stored at the right place (eg. FHEM would store V_VAR1 of Child 101 in a reading named "value1101" of the respective device).
                                          Then just use the EnergyMeterPulse-sketch as example how to ask info from nodes side to be send from controller while not sleeping.
                                          That should do the trick.

                                          Just one remark: Having a display and a sleeping node doesn't fit to well together imo :grinning:

                                          EDIT: To make things more clear: the V_VARx has to be stored in the values of the requesting node, so if the display is attached to node 6, your controller has to provide the values as reading on node 6...

                                          Controller: FHEM; MySensors: 2.3.1, RS485,nRF24,RFM69, serial Gateways

                                          ben999B 1 réponse Dernière réponse
                                          1
                                          Répondre
                                          • Répondre à l'aide d'un nouveau sujet
                                          Se connecter pour répondre
                                          • Du plus ancien au plus récent
                                          • Du plus récent au plus ancien
                                          • Les plus votés


                                          21

                                          En ligne

                                          11.7k

                                          Utilisateurs

                                          11.2k

                                          Sujets

                                          113.1k

                                          Messages


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

                                          • Vous n'avez pas de compte ? S'inscrire

                                          • Connectez-vous ou inscrivez-vous pour faire une recherche.
                                          • Premier message
                                            Dernier message
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Récent
                                          • Mots-clés
                                          • Populaire