Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. sansespere
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    sansespere

    @sansespere

    0
    Reputation
    4
    Posts
    646
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    sansespere Follow

    Best posts made by sansespere

    This user hasn't posted anything yet.

    Latest posts made by sansespere

    • RE: Requesting a sensor value from a different node?

      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("%"); 
      
      }
      posted in Troubleshooting
      sansespere
      sansespere
    • RE: Requesting a sensor value from a different node?

      @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.

      posted in Troubleshooting
      sansespere
      sansespere
    • RE: Requesting a sensor value from a different node?

      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!

      posted in Troubleshooting
      sansespere
      sansespere
    • Requesting a sensor value from a different node?

      Hi,

      I'm trying to put together a "status" type LCD screen on a separate node which can display values from other sensor nodes in the network but am running into some problems reading the data from the other nodes.

      the setup is like this:
      Node A - temp, humidity, pressure
      Node B - Distance
      Node C- LCD screeen

      I'm using a Vera as my controller, and all devices are in there and reporting correctly. I've used the "TimeAndVariable" example as the base of the LCD node, and can get it to read custom variables without any problems. But looking at the API reference I should be able to get the last value from any sensor using:

      void requestStatus(uint8_t radioId, int8_t childId, uint8_t variableType);

      But I cant for get this to work! Just trying to play with the code here is a section with the problem:

      gw.getStatus(1,11,0); //altID of temp sensor 1;11, 0 is for V_TEMP
      Status(gw.getMessage()); //function is below
      lcd.print(value);

      void Status(message_s message) {
      value = atoi(message.data);
      }

      I'm obviously doing something wrong - any advice would be appreciated!

      posted in Troubleshooting
      sansespere
      sansespere