Request node infos by arduino ide



  • Hi all,

    I'm new in the mysensors world, and love it.
    I'm trying to make a driver in csharp with serialGateway for my application.
    I received all my two humidity sensors without any problems.
    But when I want to ask something to my sensors, they send me nothing... I don't understand what going on.

    here is the code in my sensors :

    #include <SPI.h>
    #include <MySensor.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    unsigned long Time_Measure = 60000; // Sleep time between reads (in seconds)
    
    MySensor gw;
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    unsigned long timeOfLastChange = 0;
    
    void setup()  
    { 
        gw.begin(NULL, AUTO, true);
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      // Send the Sketch Version Information to the Gateway
      gw.sendSketchInfo("Atelier", "1.0");
    
      // Register all sensors to gw (they will be created as child devices)
      gw.present(CHILD_ID_HUM, S_HUM);
      gw.present(CHILD_ID_TEMP, S_TEMP);
      
      metric = gw.getConfig().isMetric;
      timeOfLastChange = millis();
    }
    
    void loop()      
    {  
      float humidity;
      float temperature;
    
      if ((millis() - timeOfLastChange) > Time_Measure)
      {
        delay(dht.getMinimumSamplingPeriod());
        temperature = dht.getTemperature();
        if (isnan(temperature)) {
            Serial.println("Failed reading temperature from DHT");
        } else if (temperature != lastTemp) {
          lastTemp = temperature;
          if (!metric) {
            temperature = dht.toFahrenheit(temperature);
          }
          gw.send(msgTemp.set(temperature, 1));
          Serial.print("T: ");
          Serial.println(temperature);
        }
        
        delay(dht.getMinimumSamplingPeriod());
        humidity = dht.getHumidity();
        if (isnan(humidity)) {
            Serial.println("Failed reading humidity from DHT");
        } else if (humidity != lastHum) {
            lastHum = humidity;
            gw.send(msgHum.set(humidity, 1));
            Serial.print("H: ");
            Serial.println(humidity);
        }
      }
      gw.process();
    }
    
    
    

    And this is an example of terminal view

    0;0;3;0;14;Gateway startup complete.
    0;0;3;0;9;read: 2-2-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
    2;255;0;0;18;1.4.1
    0;0;3;0;9;read: 2-2-0 s=255,c=3,t=6,pt=1,l=1:0
    2;255;3;0;6;0
    0;0;3;0;9;read: 2-2-0 s=255,c=3,t=11,pt=0,l=7:Atelier
    2;255;3;0;11;Atelier
    0;0;3;0;9;read: 2-2-0 s=255,c=3,t=12,pt=0,l=3:1.0
    2;255;3;0;12;1.0
    0;0;3;0;9;read: 2-2-0 s=0,c=0,t=7,pt=0,l=0:
    2;0;0;0;7;
    0;0;3;0;9;read: 2-2-0 s=1,c=0,t=6,pt=0,l=0:
    2;1;0;0;6;
    0;0;3;0;9;send: 0-0-2-2 s=255,c=3,t=6,pt=0,l=1,st=ok:0
    0;0;3;0;9;read: 1-1-0 s=0,c=1,t=1,pt=7,l=5:49.6
    1;0;1;0;1;49.6
    0;0;3;0;9;send: 0-0-2-2 s=255,c=3,t=6,pt=0,l=1,st=ok:M
    0;0;3;0;9;read: 2-2-0 s=1,c=1,t=0,pt=7,l=5:24.8
    2;1;1;0;0;24.8
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.6
    2;0;1;0;1;46.6
    0;0;3;0;9;read: 2-2-0 s=1,c=1,t=0,pt=7,l=5:24.9
    2;1;1;0;0;24.9
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.7
    2;0;1;0;1;46.7
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.6
    2;0;1;0;1;46.6
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.5
    2;0;1;0;1;46.5
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.6
    2;0;1;0;1;46.6
    0;0;3;0;9;read: 2-2-0 s=1,c=1,t=0,pt=7,l=5:25.0
    2;1;1;0;0;25.0
    0;0;3;0;9;read: 2-2-0 s=0,c=1,t=1,pt=7,l=5:46.5
    2;0;1;0;1;46.5
    
    

    What I make wrong???
    I add the gw.process on sensor code and nothing add...
    Bouhhh....😓 😥

    Please help me....


  • Admin

    What do you mean? The gateway log you publish contains both temperature and humidity readings from node 2.



  • Yes, you are wright. The sensor is working well.
    But Iwant to know is sketch_name, sketch_version.
    What Have I to do for it?


  • Admin

    2;255;3;0;11;Atelier
    2;255;3;0;12;1.0
    

    First line is sketch name and the second is the version reported in the sketch.



  • Yes, this informations is sended at sensor start up.
    But I want this information later in sensor life.
    I want to ask for this information with a command via serialgateway.
    Is that Possible?


  • Admin

    You can send the information whenever you want.

    In the provided examples it is placed in the setup() method which only runs once at startup. But nothing stops you from sending the information later (for example after a incoming request message of your choice arrives).


Log in to reply
 

Suggested Topics

  • 3
  • 1
  • 2
  • 4
  • 2
  • 24

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts