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. Troubleshooting
  3. Requesting a sensor value from a different node?

Requesting a sensor value from a different node?

Scheduled Pinned Locked Moved Troubleshooting
15 Posts 10 Posters 10.0k Views 4 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.
  • andyunoA andyuno

    @sansespere said:

    Awesome - pushing from the sensor at the same time it sends to the gateway has got it working. Will have to create what will almost be a stripped down version of a gateway to process all incoming messages and assign the contents to the correct variables for the screen : )

    Thanks for the advice!

    Hey Great idea been trying something similar myself sometime but getting nowhere any chance of you sharing some of your code, that might help me get started. What size LCD are you thinking of of using, or are you just going to use a small LCD menu driven with a couple buttons.

    S Offline
    S Offline
    sansespere
    wrote on last edited by sansespere
    #5

    @andyuno

    Hey, no problem - the LCD I'm using is this one in a 16x2 format.

    Haven't had much of a chance to work on it yet since first getting it working with Hek's advice above but this is what I have so far. Standard disclaimer though, I'm new to this whole coding and electronics stuff so there may be a better way of doing it.

    To start with, in the sketch of the sensor that has the information you want to display, find where it's sending the data to the gateway, and get it to send to the node that has the LCD at the same time. EG:

    gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //standard line sending data to the gateway
    gw.sendVariable(MONITOR_STATION,CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //new line that needs to be created, where MONITOR_STATION is defined as the radioID of the node with the LCD
    

    and below is the testing sketch I wrote to receive and display the messages:

     #include <SPI.h>
     #include <EEPROM.h>  
     #include <RF24.h>
     #include <Sensor.h>  
     #include <Time.h>  
     #include <Wire.h>  
     #include <LiquidCrystal_I2C.h>
    
     Sensor gw;
     #define CHILD_ID 10
     
     LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
     float temp = 0; //for storing temperature values
     float hum = 0; //for storing humidity values
     
     void setup()  
     {  
       gw.begin();
       // Send the sketch version information to the gateway and Controller
       gw.sendSketchInfo("LCD", "1.0");
     
       // Register any sensortype. This example we just create a motion sensor.
       gw.sendSensorPresentation(CHILD_ID, S_MOTION);
     
       lcd.begin(16,2);   //Specify LCD size
       lcd.backlight();   
     }
    
     void loop()     
     {     
       int LoopCount = 0; // LoopCount is there to make sure that we dont get stuck in a never ending loop of processing messages - not sure if this could ever even happen, but just to be safe
     
       while(gw.messageAvailable()==true && LoopCount < 10){ //while there are messages in the queue and we havent processed more than 10 since entering the loop
           message_s  message = gw.getMessage(); //get the message
           if (message.header.type == 0){  //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
           temp = atof(message.data); //if it's a temp type, get the data and convert it to float
           }
           if (message.header.type == 1){
           hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
           }  
           LoopCount++;  //increment the loop counter
       }
      
       if (LoopCount >= 1){ //Check if we need to update the LCD
        UpdateLCD(); 
       }
       
       //serial prints for troubleshooting
       Serial.print("Temp: ");
       Serial.println(temp);
       Serial.print("Hum: ");
       Serial.println(hum);
       Serial.println("Waiting");
    
       delay(10000);   //take a short break  
     }
    
     void UpdateLCD() { //LCD output
       lcd.clear();
       lcd.print("Temp:");
       lcd.print(temp,1);
       lcd.print("C"); 
       lcd.setCursor(0,1);
       lcd.print("Humi:");
       lcd.print(hum,1);
       lcd.print("%"); 
    
     }
    

    and you end up with something like this.....
    upload-782a7eaa-f12e-4e50-aeb8-d2c106de80aa
    showing data for a sensor I have sitting outside.

    Still a lot of work to do to get it right - there are other things I want to display, using scrolling messages to cycling messages, etc, but this is just a basic proof of concept.

    BulldogLowellB 1 Reply Last reply
    0
    • S sansespere

      @andyuno

      Hey, no problem - the LCD I'm using is this one in a 16x2 format.

      Haven't had much of a chance to work on it yet since first getting it working with Hek's advice above but this is what I have so far. Standard disclaimer though, I'm new to this whole coding and electronics stuff so there may be a better way of doing it.

      To start with, in the sketch of the sensor that has the information you want to display, find where it's sending the data to the gateway, and get it to send to the node that has the LCD at the same time. EG:

      gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //standard line sending data to the gateway
      gw.sendVariable(MONITOR_STATION,CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //new line that needs to be created, where MONITOR_STATION is defined as the radioID of the node with the LCD
      

      and below is the testing sketch I wrote to receive and display the messages:

       #include <SPI.h>
       #include <EEPROM.h>  
       #include <RF24.h>
       #include <Sensor.h>  
       #include <Time.h>  
       #include <Wire.h>  
       #include <LiquidCrystal_I2C.h>
      
       Sensor gw;
       #define CHILD_ID 10
       
       LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
       float temp = 0; //for storing temperature values
       float hum = 0; //for storing humidity values
       
       void setup()  
       {  
         gw.begin();
         // Send the sketch version information to the gateway and Controller
         gw.sendSketchInfo("LCD", "1.0");
       
         // Register any sensortype. This example we just create a motion sensor.
         gw.sendSensorPresentation(CHILD_ID, S_MOTION);
       
         lcd.begin(16,2);   //Specify LCD size
         lcd.backlight();   
       }
      
       void loop()     
       {     
         int LoopCount = 0; // LoopCount is there to make sure that we dont get stuck in a never ending loop of processing messages - not sure if this could ever even happen, but just to be safe
       
         while(gw.messageAvailable()==true && LoopCount < 10){ //while there are messages in the queue and we havent processed more than 10 since entering the loop
             message_s  message = gw.getMessage(); //get the message
             if (message.header.type == 0){  //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
             temp = atof(message.data); //if it's a temp type, get the data and convert it to float
             }
             if (message.header.type == 1){
             hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
             }  
             LoopCount++;  //increment the loop counter
         }
        
         if (LoopCount >= 1){ //Check if we need to update the LCD
          UpdateLCD(); 
         }
         
         //serial prints for troubleshooting
         Serial.print("Temp: ");
         Serial.println(temp);
         Serial.print("Hum: ");
         Serial.println(hum);
         Serial.println("Waiting");
      
         delay(10000);   //take a short break  
       }
      
       void UpdateLCD() { //LCD output
         lcd.clear();
         lcd.print("Temp:");
         lcd.print(temp,1);
         lcd.print("C"); 
         lcd.setCursor(0,1);
         lcd.print("Humi:");
         lcd.print(hum,1);
         lcd.print("%"); 
      
       }
      

      and you end up with something like this.....
      upload-782a7eaa-f12e-4e50-aeb8-d2c106de80aa
      showing data for a sensor I have sitting outside.

      Still a lot of work to do to get it right - there are other things I want to display, using scrolling messages to cycling messages, etc, but this is just a basic proof of concept.

      BulldogLowellB Offline
      BulldogLowellB Offline
      BulldogLowell
      Contest Winner
      wrote on last edited by
      #6

      @sansespere said:

      @andyuno

      Hey, no problem - the LCD I'm using is this one in a 16x2 format.

      Haven't had much of a chance to work on it yet since first getting it working with Hek's advice above but this is what I have so far. Standard disclaimer though, I'm new to this whole coding and electronics stuff so there may be a better way of doing it.

      To start with, in the sketch of the sensor that has the information you want to display, find where it's sending the data to the gateway, and get it to send to the node that has the LCD at the same time. EG:

      gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //standard line sending data to the gateway
      gw.sendVariable(MONITOR_STATION,CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //new line that needs to be created, where MONITOR_STATION is defined as the radioID of the node with the LCD
      

      and below is the testing sketch I wrote to receive and display the messages:

       #include <SPI.h>
       #include <EEPROM.h>  
       #include <RF24.h>
       #include <Sensor.h>  
       #include <Time.h>  
       #include <Wire.h>  
       #include <LiquidCrystal_I2C.h>
      
       Sensor gw;
       #define CHILD_ID 10
       
       LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
       float temp = 0; //for storing temperature values
       float hum = 0; //for storing humidity values
       
       void setup()  
       {  
         gw.begin();
         // Send the sketch version information to the gateway and Controller
         gw.sendSketchInfo("LCD", "1.0");
       
         // Register any sensortype. This example we just create a motion sensor.
         gw.sendSensorPresentation(CHILD_ID, S_MOTION);
       
         lcd.begin(16,2);   //Specify LCD size
         lcd.backlight();   
       }
      
       void loop()     
       {     
         int LoopCount = 0; // LoopCount is there to make sure that we dont get stuck in a never ending loop of processing messages - not sure if this could ever even happen, but just to be safe
       
         while(gw.messageAvailable()==true && LoopCount < 10){ //while there are messages in the queue and we havent processed more than 10 since entering the loop
             message_s  message = gw.getMessage(); //get the message
             if (message.header.type == 0){  //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
             temp = atof(message.data); //if it's a temp type, get the data and convert it to float
             }
             if (message.header.type == 1){
             hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
             }  
             LoopCount++;  //increment the loop counter
         }
        
         if (LoopCount >= 1){ //Check if we need to update the LCD
          UpdateLCD(); 
         }
         
         //serial prints for troubleshooting
         Serial.print("Temp: ");
         Serial.println(temp);
         Serial.print("Hum: ");
         Serial.println(hum);
         Serial.println("Waiting");
      
         delay(10000);   //take a short break  
       }
      
       void UpdateLCD() { //LCD output
         lcd.clear();
         lcd.print("Temp:");
         lcd.print(temp,1);
         lcd.print("C"); 
         lcd.setCursor(0,1);
         lcd.print("Humi:");
         lcd.print(hum,1);
         lcd.print("%"); 
      
       }
      

      and you end up with something like this.....
      upload-782a7eaa-f12e-4e50-aeb8-d2c106de80aa
      showing data for a sensor I have sitting outside.

      Still a lot of work to do to get it right - there are other things I want to display, using scrolling messages to cycling messages, etc, but this is just a basic proof of concept.

      nice work.

      for your next revision we can show you how to do this without holding in the while loop or using delays.

      terrific!!!!! :) I like LCD's :)

      S 1 Reply Last reply
      0
      • BulldogLowellB BulldogLowell

        @sansespere said:

        @andyuno

        Hey, no problem - the LCD I'm using is this one in a 16x2 format.

        Haven't had much of a chance to work on it yet since first getting it working with Hek's advice above but this is what I have so far. Standard disclaimer though, I'm new to this whole coding and electronics stuff so there may be a better way of doing it.

        To start with, in the sketch of the sensor that has the information you want to display, find where it's sending the data to the gateway, and get it to send to the node that has the LCD at the same time. EG:

        gw.sendVariable(CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //standard line sending data to the gateway
        gw.sendVariable(MONITOR_STATION,CHILD_ID_TEMP, V_TEMP, temperatureB, 1); //new line that needs to be created, where MONITOR_STATION is defined as the radioID of the node with the LCD
        

        and below is the testing sketch I wrote to receive and display the messages:

         #include <SPI.h>
         #include <EEPROM.h>  
         #include <RF24.h>
         #include <Sensor.h>  
         #include <Time.h>  
         #include <Wire.h>  
         #include <LiquidCrystal_I2C.h>
        
         Sensor gw;
         #define CHILD_ID 10
         
         LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
         float temp = 0; //for storing temperature values
         float hum = 0; //for storing humidity values
         
         void setup()  
         {  
           gw.begin();
           // Send the sketch version information to the gateway and Controller
           gw.sendSketchInfo("LCD", "1.0");
         
           // Register any sensortype. This example we just create a motion sensor.
           gw.sendSensorPresentation(CHILD_ID, S_MOTION);
         
           lcd.begin(16,2);   //Specify LCD size
           lcd.backlight();   
         }
        
         void loop()     
         {     
           int LoopCount = 0; // LoopCount is there to make sure that we dont get stuck in a never ending loop of processing messages - not sure if this could ever even happen, but just to be safe
         
           while(gw.messageAvailable()==true && LoopCount < 10){ //while there are messages in the queue and we havent processed more than 10 since entering the loop
               message_s  message = gw.getMessage(); //get the message
               if (message.header.type == 0){  //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
               temp = atof(message.data); //if it's a temp type, get the data and convert it to float
               }
               if (message.header.type == 1){
               hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
               }  
               LoopCount++;  //increment the loop counter
           }
          
           if (LoopCount >= 1){ //Check if we need to update the LCD
            UpdateLCD(); 
           }
           
           //serial prints for troubleshooting
           Serial.print("Temp: ");
           Serial.println(temp);
           Serial.print("Hum: ");
           Serial.println(hum);
           Serial.println("Waiting");
        
           delay(10000);   //take a short break  
         }
        
         void UpdateLCD() { //LCD output
           lcd.clear();
           lcd.print("Temp:");
           lcd.print(temp,1);
           lcd.print("C"); 
           lcd.setCursor(0,1);
           lcd.print("Humi:");
           lcd.print(hum,1);
           lcd.print("%"); 
        
         }
        

        and you end up with something like this.....
        upload-782a7eaa-f12e-4e50-aeb8-d2c106de80aa
        showing data for a sensor I have sitting outside.

        Still a lot of work to do to get it right - there are other things I want to display, using scrolling messages to cycling messages, etc, but this is just a basic proof of concept.

        nice work.

        for your next revision we can show you how to do this without holding in the while loop or using delays.

        terrific!!!!! :) I like LCD's :)

        S Offline
        S Offline
        sansespere
        wrote on last edited by
        #7

        Ahhh ok - so something more like this:

        #include <SPI.h>
        #include <EEPROM.h>  
        #include <RF24.h>
        #include <Sensor.h>  
        #include <Time.h>  
        #include <Wire.h>  
        #include <LiquidCrystal_I2C.h>
        
        Sensor gw;
        #define CHILD_ID 1
        
        LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
        float temp = 0; //for storing temperature values
        float hum = 0; //for storing humidity values
        
        void setup()  
        {  
          gw.begin();
          // Send the sketch version information to the gateway and Controller
          gw.sendSketchInfo("LCD", "1.0");
        
          // Register any sensortype. This example we just create a motion sensor.
         gw.sendSensorPresentation(CHILD_ID, S_MOTION);
        
          lcd.begin(16,2);   //Specify LCD size
          lcd.backlight();   
        }
        
        void loop()     
        {     
            message_s  message = gw.waitForMessage(); //wait for a message to process
        
            //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
            if (message.header.type == 0){  
              temp = atof(message.data); //if it's a temp type, get the data and convert it to float
            }
            else if (message.header.type == 1){
              hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
            }  
            else {
              Serial.print("Unknow Message Type");
            } 
        
          //serial prints for troubleshooting
          Serial.print("Temp: ");
          Serial.println(temp);
          Serial.print("Hum: ");
          Serial.println(hum);
          UpdateLCD(); 
          Serial.println("Waiting");
        }
        
        void UpdateLCD() { //LCD output
          lcd.clear();
          lcd.print("Temp:");
          lcd.print(temp,1);
          lcd.print("C"); 
          lcd.setCursor(0,1);
          lcd.print("Humi:");
          lcd.print(hum,1);
          lcd.print("%"); 
        
        }
        
        andyunoA 1 Reply Last reply
        0
        • S sansespere

          Ahhh ok - so something more like this:

          #include <SPI.h>
          #include <EEPROM.h>  
          #include <RF24.h>
          #include <Sensor.h>  
          #include <Time.h>  
          #include <Wire.h>  
          #include <LiquidCrystal_I2C.h>
          
          Sensor gw;
          #define CHILD_ID 1
          
          LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address
          float temp = 0; //for storing temperature values
          float hum = 0; //for storing humidity values
          
          void setup()  
          {  
            gw.begin();
            // Send the sketch version information to the gateway and Controller
            gw.sendSketchInfo("LCD", "1.0");
          
            // Register any sensortype. This example we just create a motion sensor.
           gw.sendSensorPresentation(CHILD_ID, S_MOTION);
          
            lcd.begin(16,2);   //Specify LCD size
            lcd.backlight();   
          }
          
          void loop()     
          {     
              message_s  message = gw.waitForMessage(); //wait for a message to process
          
              //check the type of message it is - temperature, humidity, etc. as per Variable Types defined in http://www.mysensors.org/build/sensor_api
              if (message.header.type == 0){  
                temp = atof(message.data); //if it's a temp type, get the data and convert it to float
              }
              else if (message.header.type == 1){
                hum =  atof(message.data); //if it's a humidity type, get the data and convert it to float
              }  
              else {
                Serial.print("Unknow Message Type");
              } 
          
            //serial prints for troubleshooting
            Serial.print("Temp: ");
            Serial.println(temp);
            Serial.print("Hum: ");
            Serial.println(hum);
            UpdateLCD(); 
            Serial.println("Waiting");
          }
          
          void UpdateLCD() { //LCD output
            lcd.clear();
            lcd.print("Temp:");
            lcd.print(temp,1);
            lcd.print("C"); 
            lcd.setCursor(0,1);
            lcd.print("Humi:");
            lcd.print(hum,1);
            lcd.print("%"); 
          
          }
          
          andyunoA Offline
          andyunoA Offline
          andyuno
          wrote on last edited by
          #8

          @sansespere.. Nice work, I don't think I would've got most of that, now that should give me something to work from thanks.

          :) Any Help is Appreciated Thank You.

          1 Reply Last reply
          0
          • jendrushJ Offline
            jendrushJ Offline
            jendrush
            wrote on last edited by
            #9

            If someone have this converted to 1.4 version of library please post it.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kwest
              wrote on last edited by kwest
              #10

              If someone have this converted to 1.4 version of library please post it.

              Have node №2 child 1 - temp sensor.
              For example: how to ask the node 2 child 1 value from node №10?

              1 Reply Last reply
              0
              • K Offline
                K Offline
                kwest
                wrote on last edited by
                #11
                This post is deleted!
                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andriej
                  wrote on last edited by
                  #12

                  Anyone?

                  @sansespere

                  :-)

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    franklin216
                    wrote on last edited by franklin216
                    #13

                    I've just found this thread, which describes the Convertion from 1.3 to 1.4:

                    http://forum.mysensors.org/topic/172/convert-sketch-from-1-3-to-1-4

                    I think, the following would do the trick, i will try it, when i am home this evenening:

                    // process incoming messages (like config from server) <-- insert line
                    gw.process(); <-- insert line
                    gw.sendVariable(MONITOR_STATION, CHILD_ID, V_TEMP, temperature, 1); change to --> gw.send(msg.setSensor(CHILD).set(temperature,1).setDestination(MONITOR_STATION)); // send float with one decimal point

                    1 Reply Last reply
                    0
                    • AWIA Offline
                      AWIA Offline
                      AWI
                      Hero Member
                      wrote on last edited by
                      #14

                      I would imagine the "royal" way of getting sensor values is requesting them from the controller. In this case the sensor to be read does not need to bother about sending the values to all of the nodes and waking up is not an issue.

                      1 Reply Last reply
                      0
                      • Lawrence HelmL Offline
                        Lawrence HelmL Offline
                        Lawrence Helm
                        wrote on last edited by
                        #15

                        did anyone convert this succesfully? I'm having some problems, this would make a great example build :) I looked at other ones like "node to node " but something simple like this would be great to start building from..

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


                        14

                        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