Serial GW Stops Working Periodically



  • Not positive what's going on and hope others could help with troubleshooting. The nano GW locks-up/freezes - it can be seen the Arduino log messages stop in the LuaUPnP.log file on the Veralite. Pushing the "reset" button on the nano clears the condition and everything then works as expected.

    The log messages right prior to the GW not working are shown below. Strange behaviour because the node-2 message is received twice via the "repeater node" (node-3) and the second message value is peculiar as it's showing a floating point with many zero's. All other times the sensor value is only sent once and in the proper format (meaning no zero's added).

    My sketch only sends the value once and with no decimal value, as shown here: gw.send(msgHum.set(humidity, 0));

    50	15:00:14.245	luup_log:107: Arduino: Log: read: 2-3-0 s=0,c=1,t=1,pt=7,l=5:31 <0x2deb4680>
    50	15:00:14.246	luup_log:107: Arduino: Set variable: 2;0;1;0;1;31 <0x2deb4680>
    50	15:00:14.247	luup_log:107: Arduino: Setting variable 'CurrentLevel' to value '31' <0x2deb4680>
    50	15:00:14.247	luup_log:107: Arduino: urn:micasaverde-com:serviceId:HumiditySensor1,CurrentLevel, 31, 119 <0x2deb4680>
    50	15:00:16.255	luup_log:107: Arduino: Log: read: 2-3-0 s=0,c=1,t=1,pt=7,l=5:31.00000000000000000000000 <0x2deb4680>  ==> last log message from GW
    

    Any idea's as why the value received has zero's added, then causing the nano to freeze up? And, why the message was sent twice within 2secs of each other? It works most of the time w/o problems until this condition occurs.

    Regards,
    Joe


  • Admin

    Surely looks strange. Is it always zeroes?

    Do you have a powered USB hub around which you could attach your serial gateway to?
    Or try powering the nano externally?



  • @hek

    Thanks for your suggestion. I'll work on using a separate power supply on the GW to see if it helps some.

    "Is it always zeroes?"

    No, never - only see zero's when GW freezes. Below is another example from the last freeze. Not sure if the problem is with the GW or node-3 which is a "repeater node"? Thinking maybe the repeater is sending a bad/corrupted message to GW causing it to freeze.

    50  5:21:33.186	luup_log:107: Arduino: Log: read: 3-3-0 s=0,c=1,t=5,pt=7,l=5:148.0002400000000000000000 <0x2e0fe680>
    

    Thanks,
    Joe


  • Admin

    @joe.k

    Hmm. I wonder if there might be a buffer overflow error somewhere in the gateway code when the over-the-air transmitted floats is converted back to string.


  • Admin

    Buffer seems to be big enough...

    What happens if you send in values with one decimal?

    gw.send(msgHum.set(humidity, 1))

    dtostrf is used to convert float value string. Not sure how it reacts when you specify 0 for precision but I hope it behaves as expected!
    http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#ga060c998e77fb5fc0d3168b3ce8771d42



  • @hek

    "What happens if you send in values with one decimal?"

    Around my house I have four separate climate nodes that use the DHT22 sensor. Each node uses the same code and reports temperature with one decimal point (ex: 73.8) and humidity reports with no decimal point (ex: 25). I am not seeing problems with 3 of the 4, but node-3 is the only repeater of the bunch and suspect as it's the last node communicating with the GW when it freezes.

    "dtostrf is used to convert float value string. Not sure how it reacts when you specify 0 for precision but I hope it behaves as expected!"

    I'll have to investigate further ... although this code works I now question the round() because it's a double and humidity is a float (single precision). Not sure if there's an occasional problem as a result.

    humidity = dht.getHumidity();
    humidity = round(humidity); 
    if (humidity != lastHum) {      
        gw.send(msgHum.set(humidity, 0)); 
        lastHum = humidity;
    }
    

    The purpose of the code is to just use whole numbers when comparing previous reading and reporting back to GW. Greater accuracy isn't needed with humidity.

    Thanks,
    Joe


  • Contest Winner

    @joe.k said:

    The purpose of the code is to just use whole numbers when comparing previous reading and reporting back to GW. Greater accuracy isn't needed with humidity.

    cast the float into an int... rounding doesn't fix the precision issue and you still have a float...

    try it:

    float humidity = 11.321;
    
    void setup()
    {
      Serial.begin(9600);
      humidity = round(humidity); 
      Serial.print(humidity);
      //
      humidity = 11.321;
      humidity += 0.5;
      humidity = floor(humidity);
      int myHumidity = (int) humidity;
      Serial.print(myHumidity);
    }
    void loop()
    {
      
    }


  • Just to report back my findings .....

    After reloading the sketch onto node-3 repeater my RF network of sensors have worked flawlessly. No GW freezes. There were no changes made to the GW or any other node except node-3.

    Node-3 went from code 1.4 to 1.4.1 after the sketch reload, but not aware of any changes in 1.4.1 that would have made a difference(?).

    So in conclusion the problems were mostly caused by the repeater node-3 and reloading the sketch fixed it.

    Joe


  • Admin

    A serious bug in communication was fixed in 1.4.1. Could very well be this that caused your problems.


Log in to reply
 

Suggested Topics

1
Online

11.4k
Users

11.1k
Topics

112.7k
Posts