Exception with "nan" messages
-
I am debugging now, but I am having some problems with some DHT11 sensors, that are sometimes (once per hour) returning weird values. I want to filter that away at the device, but currently I am getting:
2018-01-02 21:44:49,590 ERROR [Thread-6] [org.mycontroller.standalone.message.MessageMonitorThread:119] Throws exception while processing!, [RawMessage(gatewayId=1, data=nan, subData=out_esp/ESP_2D5A26/humid-3/C_SET/V_HUM/0, isTxMessage=false, networkType=MY_CONTROLLER, timestamp=1514925889586)] java.lang.NumberFormatException: For input string: "nan" at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043) at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) at java.lang.Double.parseDouble(Double.java:538) at java.lang.Double.valueOf(Double.java:502) at org.mycontroller.standalone.utils.McUtils.getDouble(McUtils.java:100) at org.mycontroller.standalone.utils.McUtils.getDouble(McUtils.java:95) at org.mycontroller.standalone.message.McMessageEngine.updateSensorVariable(McMessageEngine.java:913) at org.mycontroller.standalone.message.McMessageEngine.recordSetTypeData(McMessageEngine.java:997) at org.mycontroller.standalone.message.McMessageEngine.execute(McMessageEngine.java:108) at org.mycontroller.standalone.message.McMessageEngine.run(McMessageEngine.java:1117) at org.mycontroller.standalone.message.McMessageUtils.sendToMcMessageEngine(McMessageUtils.java:677) at org.mycontroller.standalone.provider.mc.McProviderBridge.executeRawMessage(McProviderBridge.java:59) at org.mycontroller.standalone.message.McMessageUtils.sendToProviderBridge(McMessageUtils.java:585) at org.mycontroller.standalone.message.MessageMonitorThread.processRawMessage(MessageMonitorThread.java:107) at org.mycontroller.standalone.message.MessageMonitorThread.run(MessageMonitorThread.java:182) at java.lang.Thread.run(Thread.java:748)
I am interested in knowing if there is a message somewhere else than in the server log when bad messages are coming from the devices.
-
@njbuch These type of messages dropped when it sees the error, hence you will not see anywhere other than this log.
-
If your DHT11 returns "nan" it means that it is not possible for the node to read the sensor, or received undeadable data, so the result should not even be send to mycontroller. You could try to make your sensor aware of this reading by using the isnan() function...
Below is an example i have found.
https://github.com/adafruit/DHT-sensor-library/blob/master/examples/DHTtester/DHTtester.ino
// Check if any reads failed and exit early (to try again). if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }
(DHT11 is from a specs perspective not the best one to use, DHT22 performs much better...)