loungeroom sketch transport failure



  • hi all
    using
    mysensors 2.1.1

    get the following log

    0 MCO:BGN:INIT NODE,CP=RNNNA--,VER=2.1.1
    4 TSM:INIT
    4 TSF:WUR:MS=0
    10 !TSM:INIT:TSP FAIL
    14 TSM:FAIL:CNT=1
    14 TSM:FAIL:PDT
    10018 TSM:FAIL:RE-INIT
    10020 TSM:INIT
    10027 !TSM:INIT:TSP FAIL
    10031 TSM:FAIL:CNT=2
    10033 TSM:FAIL:PDT
    

    transport failure...not really sure what that is, and posts show it being many different things
    this is my code

    i know i must have something wrong, but i cant work it out.... any help is appreciated

    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_NODE_ID 4
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_LIGHT 2
    #define HUMIDITY_SENSOR_DIGITAL_PIN 6
    #define LIGHT_SENSOR_ANALOG_PIN A1
    unsigned long SLEEP_TIME = 120000; // Sleep time between reads (in milliseconds)
    
    #define SKETCH_NAME "loungeroom living sensor #1"        // Change to a fancy name you like
    #define SKETCH_VERSION "1"                    // Your version
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    int LightLevel = 0;
    int lastLightLevel;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    
    //=========================
    // BATTERY VOLTAGE DIVIDER SETUP
    // 1M, 470K divider across battery and using internal ADC ref of 1.1V
    // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
    // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
    // 3.44/1023 = Volts per bit = 0.003363075
    #define VBAT_PER_BITS 0.003363075  
    #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
    #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
    int batteryPcnt = 0;                              // Calc value for battery %
    int batLoop = 0;                                  // Loop to help calc average
    int batArray[3];                                  // Array to store value for average calc.
    int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
    //=========================
    
    void setup()  
    { 
     analogReference(INTERNAL);             // For battery sensing
    
      delay(500); // Allow time for radio if power used as reset
      
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      metric = getControllerConfig().isMetric;
    }
    
    void presentation()  
    { 
      // Send the Sketch Version Information to the Gateway
     // Send the Sketch Version Information to the Gateway
      sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }
    
    void loop()      
    {  
      delay(500); // Allow time for radio if power used as reset
      delay(dht.getMinimumSamplingPeriod());
     
      // Fetch temperatures from DHT sensor
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      // Fetch humidity from DHT sensor
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
      int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
          send(LightMsg.set(lightLevel));
          lastLightLevel = lightLevel;
      }
          
      batM();
      sleep(SLEEP_TIME); //sleep a bit
    }
    
    void batM() //The battery calculations
    {
       delay(500);
       // Battery monitoring reading
       int sensorValue = analogRead(BATTERY_SENSE_PIN);    
       delay(500);
       
       // Calculate the battery in %
       float Vbat  = sensorValue * VBAT_PER_BITS;
       int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
       Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
       
       // Add it to array so we get an average of 3 (3x20min)
       batArray[batLoop] = batteryPcnt;
      
       if (batLoop > 2) {  
         batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
         batteryPcnt = batteryPcnt / 3;
     
       if (batteryPcnt > 100) {
         batteryPcnt=100;
     }
     
         Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
           sendBatteryLevel(batteryPcnt);
           batLoop = 0;
          }
         else 
         {
         batLoop++;
         }
    }
    


  • Did you already follow the procedures described here: https://forum.mysensors.org/topic/666/debug-faq-and-how-ask-for-help


  • Hardware Contributor

    Transport init fail = the Arduino didn't manage to communicate with the radio.
    Check the wiring and power source of the radio.



  • god i need new glasses...back to fornt capacitor on the antenna module....

    ok thanks guys...that parts resolved, now just gotta go though no parent found part....other devices in the same location works, just not this one...time to start swapping capacitors


  • Hardware Contributor

    @markjgabb - no reply means the node can't find its way to the radio. Just as you are saying look over that you have all the right capacitors. Sometimes you need a 47uF capacitor instead of the 4,7uF on the radio. (Sometimes you need to try different ones).

    How do you power the node?



  • its battery powered, i have the jumpers, i just got registration on node....but not all sensors are sending data....

    @sundberg84 would it be possible for you to review the below code....have i missed something?

    // Enable debug prints
    #define MY_DEBUG
    
    // Enable and select radio type attached
    #define MY_RADIO_NRF24
    //#define MY_RADIO_RFM69
    #define MY_NODE_ID 4
    
    #include <SPI.h>
    #include <MySensors.h>  
    #include <DHT.h>  
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_LIGHT 2
    #define HUMIDITY_SENSOR_DIGITAL_PIN 6
    #define LIGHT_SENSOR_ANALOG_PIN A1
    unsigned long SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
    
    #define SKETCH_NAME "loungeroom living sensor #1"        // Change to a fancy name you like
    #define SKETCH_VERSION "1"                    // Your version
    
    DHT dht;
    float lastTemp;
    float lastHum;
    boolean metric = true; 
    int LightLevel = 0;
    int lastLightLevel;
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage LightMsg(CHILD_ID_LIGHT, V_LIGHT_LEVEL);
    
    //=========================
    // BATTERY VOLTAGE DIVIDER SETUP
    // 1M, 470K divider across battery and using internal ADC ref of 1.1V
    // Sense point is bypassed with 0.1 uF cap to reduce noise at that point
    // ((1e6+470e3)/470e3)*1.1 = Vmax = 3.44 Volts
    // 3.44/1023 = Volts per bit = 0.003363075
    #define VBAT_PER_BITS 0.003363075  
    #define VMIN 1.9                                  //  Vmin (radio Min Volt)=1.9V (564v)
    #define VMAX 3.0                                  //  Vmax = (2xAA bat)=3.0V (892v)
    int batteryPcnt = 0;                              // Calc value for battery %
    int batLoop = 0;                                  // Loop to help calc average
    int batArray[3];                                  // Array to store value for average calc.
    int BATTERY_SENSE_PIN = A0;                       // select the input pin for the battery sense point
    //=========================
    
    void setup()  
    { 
     analogReference(INTERNAL);             // For battery sensing
    
      delay(500); // Allow time for radio if power used as reset
      
      dht.setup(HUMIDITY_SENSOR_DIGITAL_PIN); 
    
      metric = getControllerConfig().isMetric;
    }
    
    void presentation()  
    { 
      // Send the Sketch Version Information to the Gateway
     // Send the Sketch Version Information to the Gateway
      sendSketchInfo(SKETCH_NAME, SKETCH_VERSION);
    
      // Register all sensors to gw (they will be created as child devices)
      present(CHILD_ID_HUM, S_HUM);
      present(CHILD_ID_TEMP, S_TEMP);
      present(CHILD_ID_LIGHT, S_LIGHT_LEVEL);
    }
    
    void loop()      
    {  
      delay(500); // Allow time for radio if power used as reset
      delay(dht.getMinimumSamplingPeriod());
     
      // Fetch temperatures from DHT sensor
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
          Serial.println("Failed reading temperature from DHT");
      } else if (temperature != lastTemp) {
        lastTemp = temperature;
        send(msgTemp.set(temperature, 1));
        Serial.print("T: ");
        Serial.println(temperature);
      }
      
      // Fetch humidity from DHT sensor
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
          Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum) {
          lastHum = humidity;
          send(msgHum.set(humidity, 1));
          Serial.print("H: ");
          Serial.println(humidity);
      }
      int lightLevel = (1023-analogRead(LIGHT_SENSOR_ANALOG_PIN))/10.23; 
      Serial.println(lightLevel);
      if (lightLevel != lastLightLevel) {
          send(LightMsg.set(lightLevel));
          lastLightLevel = lightLevel;
      }
          
      batM();
      sleep(SLEEP_TIME); //sleep a bit
    }
    
    void batM() //The battery calculations
    {
       delay(500);
       // Battery monitoring reading
       int sensorValue = analogRead(BATTERY_SENSE_PIN);    
       delay(500);
       
       // Calculate the battery in %
       float Vbat  = sensorValue * VBAT_PER_BITS;
       int batteryPcnt = static_cast<int>(((Vbat-VMIN)/(VMAX-VMIN))*100.);
       Serial.print("Battery percent: "); Serial.print(batteryPcnt); Serial.println(" %");  
       
       // Add it to array so we get an average of 3 (3x20min)
       batArray[batLoop] = batteryPcnt;
      
       if (batLoop > 2) {  
         batteryPcnt = (batArray[0] + batArray[1] + batArray[2] + batArray[3]);
         batteryPcnt = batteryPcnt / 3;
     
       if (batteryPcnt > 100) {
         batteryPcnt=100;
     }
     
         Serial.print("Battery Average (Send): "); Serial.print(batteryPcnt); Serial.println(" %");
           sendBatteryLevel(batteryPcnt);
           batLoop = 0;
          }
         else 
         {
         batLoop++;
         }
    }
    

  • Hardware Contributor

    @markjgabb said in loungeroom sketch transport failure:

    if (lightLevel != lastLightLevel) {

    This means it will only send if the value is changed... could that be the cause?

    Any logs from the node? Ack ok?



  • 7778 MCO:SLP:WUP=-1
    9306 TSF:MSG:SEND,3-3-0-0,s=1,c=1,t=0,pt=7,l=5,sg=0,ft=0,st=OK:20.0
    T: 20.00
    9316 TSF:MSG:SEND,3-3-0-0,s=0,c=1,t=1,pt=7,l=5,sg=0,ft=0,st=OK:18.0
    H: 18.00
    0
    Battery percent: -89 %
    10326 MCO:SLP:MS=120000,SMS=0,I1=255,M1=255,I2=255,M2=255
    10332 MCO:SLP:TPD
    

    this is my current log....

    so temp and hum is wrking...but my lux level keeps coming back 0 i think thats what its saying....can i insert more logging on that one to see how its doing the math?


  • Hardware Contributor

    @markjgabb - ok, communication looks good! Great!
    It looks like you are not getting anything out of the sensor. Is it powered? Did you connect it to analog output? (Some sensors have both digital and analog out).

    There is not much else to log.
    You could do: Serial.println(LIGHT_SENSOR_ANALOG_PIN); to see the raw value (should be 0-1v). on the analog input.
    You can also measure the voltage coming on the analog output pin on the sensor and see.

    The battery measurment looks strange though... negative 89? 🙂



  • ok raw lux is 15

    good point...ive used a 47k resistor instead of a 470k, ill change that in the morning
    Raw Lux: 15
    send Lux: 0

    obviously a sensor error, ive moved the photo resistor into diffrent light like 4 times, and no change in reading


  • Hardware Contributor

    @markjgabb - if you can confirm that with a multimeter, its defenetly a error in the sensor... but verify because it can be a fault in the pro mini hardware/software as well.

    Raw lux (Serial.println(LIGHT_SENSOR_ANALOG_PIN);) should be between value 0 and 1023.

    I probably wrote wrong above though... if you are using a 5v pro mini, the input voltage range should be 0 to 5 volts



  • nah its a 3.3 pro mini
    photo

    back



  • photo resistor is now working...domoticz is showing varied amounts of reading though the night and morning....
    but its back to front....

    its reads 90ish in the middle of the night and this morning fluxuated between 50-10 and is now sitting at 30 with an empty house......did i math backwards? or is this expected behaviour due to the way the resistance works?

    in domoticz would i just use low values as my brightness


  • Hardware Contributor

    @markjgabb said in loungeroom sketch transport failure:

    photo resistor is now working...domoticz is showing varied amounts of reading though the night and morning....
    but its back to front....

    its reads 90ish in the middle of the night and this morning fluxuated between 50-10 and is now sitting at 30 with an empty house......did i math backwards? or is this expected behaviour due to the way the resistance works?

    in domoticz would i just use low values as my brightness

    Resistance gets lower when you have light. So higher when you have no light, meaning you have higher voltage when you measure voltage across the photoresistor.


  • Hardware Contributor

    @Nca78 - what kind of sensor are you using? Or just a single photoresistor as Nca78 suggested?



  • just a single photoresistor,
    i just wasnt sure if there was a way to reverse map the numbers so that if it says 1 it sends 99


  • Hardware Contributor

    @markjgabb - a single photoresistor can be extremly sensitive, ie 0 to full in a small change in light. There are alot of guides out there, just google around.



  • @sundberg84 solved the light sensitivity level by swapping the 10k for a 100k...
    makes it more acurate in lighter enviroments, but less so in dark enviroments

    but by my theory after its a little dim im counting it as dark all the way to full dark for lighting purposes anyway

    cheers for all your help....


Log in to reply
 

Suggested Topics

25
Online

11.2k
Users

11.1k
Topics

112.5k
Posts