Noob problem on debugging transmissions



  • Hello,

    I'm quite new to MySensor and Arduino/Raspberry world.
    I'm struggling since few days to add some sensors on Domoticz by using a NRF24L01+ device (Gateway is direclty connected on Rpi3 using SPI).

    Currently, i'm trying to send data with a DHT22:
    On the sensor part, the monitor displays the following:

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    12 TSM:INIT:TSP OK
    14 TSM:INIT:STATID=4
    16 TSF:SID:OK,ID=4
    18 TSM:FPAR
    53 TSF:MSG:SEND,4-4-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    759 TSF:MSG:READ,0-0-4,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    765 TSF:MSG:FPAR OK,ID=0,D=1
    2062 TSM:FPAR:OK
    2062 TSM:ID
    2064 TSM:ID:OK
    2066 TSM:UPL
    2070 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    4077 TSM:UPL
    4079 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    6088 TSM:UPL
    6090 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    8099 TSM:UPL
    8101 TSF:MSG:SEND,4-4-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    

    While on the Raspberry side (GW):

    4;255;3;0;24;1
    4;255;3;0;24;1
    4;255;3;0;24;1
    4;255;3;0;24;1
    

    What is strange, is that I never see any data from the DHT Sensor.
    My code:

    #include <SPI.h>
    #include <Wire.h>
    #include <DHT.h>
    
    #define MY_DEBUG                      // Active le mode debug / Enable debug prints to serial monitor
    #define MY_RADIO_NRF24                // Mode Radio / Enable and select radio type attached
    #define MY_RF24_PA_LEVEL RF24_PA_LOW
    #define MY_NODE_ID 4                  // Noeud de l'objet / Object Node
    
    #define RF_CE    9
    #define RF_CSN   10
    #define CHILD_ID_HUM 1
    #define CHILD_ID_TEMP 2
    #define HUMIDITY_SENSOR_DIGITAL_PIN 3
    #define DHTTYPE DHT22   // DHT 22  (AM2302), DHT11
    #include <MySensors.h>  
    
    unsigned long SLEEP_TIME = 10000;     // Sleep time between reads (in milliseconds)
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    int reportCount = 1;
    
    void setup()  { 
    }
    
    void presentation(){
      // Send the sketch version information to the gateway and Controller
      sendSketchInfo("Outdoor temperature + Humidity", "1.0");
    
      // Register all sensors to gateway (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
    }
    
    void loop()      { 
      // Temperature
      
      DHT dht(HUMIDITY_SENSOR_DIGITAL_PIN, DHTTYPE, 3); 
      float temperature = dht.readTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } 
      else {
        Serial.print("T: ");
        Serial.println(temperature);
        if(lastTemp != temperature || reportCount == 10) { 
          lastTemp = temperature;
          send(msgTemp.set(temperature, 1));    
        }
      }
    
      // Humidity
      float humidity = dht.readHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } 
      else {
        Serial.print("H: ");
        Serial.println(humidity);
        if(lastHum != humidity || reportCount == 10) { 
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
        }
      }
      
      if(reportCount == 10) {
        reportCount = 1;
      }
      else {
        reportCount++;
      }
      
      sleep(SLEEP_TIME);
    }
    

    Shouldn't I see the measurement values in the monitor (serial.print cmd) ?

    Thanks for helping !



  • @Korleone said in Noob problem on debugging transmissions:

    4;255;3;0;24;1

    Do you know the log parser: https://www.mysensors.org/build/parser?
    Seems your node doesn't get registered by your controller. The gateway is in inclusion mode?

    If there is no registration, your node will never go into loop() - at least in standard configuration.

    Wrt. your code, I would recommend to define all of the variables in the header, not in the loop() and - more important to declare the DHT object in setup().

    Kind regards



  • Thanks for the quick answer and advices. I understand my mistake:
    It is not linked to the inclusion, but on the Gateway and Nodes versions: (Gateway was on MySensors 1.4, while Nodes were on MySensors 2).
    Reconfiguration of the Gateway gives appropriate results and is immediately included in Domoticz !


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.