Community
OpenEnergyMonitor

OpenEnergyMonitor Community

EmonTH decoded values with too many decimal places

Dear members,
after upgrading to 10.2.7 I got my emonhub decoding humidity and battery data from emonth devices with many decimals places .

Emonhub reports :

2021-03-19 23:42:18,095 DEBUG    RFM2Pi     55502 NEW FRAME : OK 23 205 0 0 0 153 1 29 0 1 0 0 0 (-68)
2021-03-19 23:42:18,096 DEBUG    RFM2Pi     55502 Timestamp : 1616193738.095091
2021-03-19 23:42:18,097 DEBUG    RFM2Pi     55502 From Node : 23
2021-03-19 23:42:18,097 DEBUG    RFM2Pi     55502    Values : [20.5, 0, 40.900000000000006, 2.9000000000000004, 1]
2021-03-19 23:42:18,097 DEBUG    RFM2Pi     55502      RSSI : -68
2021-03-19 23:42:18,098 DEBUG    RFM2Pi     55502 Sent to channel(start)' : ToEmonCMS
2021-03-19 23:42:18,098 DEBUG    RFM2Pi     55502 Sent to channel(end)' : ToEmonCMS
2021-03-19 23:42:18,355 DEBUG    MQTT       Publishing: emon/emonth5/temperature 20.5
2021-03-19 23:42:18,356 DEBUG    MQTT       Publishing: emon/emonth5/external temperature 0
2021-03-19 23:42:18,357 DEBUG    MQTT       Publishing: emon/emonth5/humidity 40.900000000000006
2021-03-19 23:42:18,358 DEBUG    MQTT       Publishing: emon/emonth5/battery 2.9000000000000004
2021-03-19 23:42:18,359 DEBUG    MQTT       Publishing: emon/emonth5/pulsecount 1
2021-03-19 23:42:18,360 DEBUG    MQTT       Publishing: emon/emonth5/rssi -68

and emonhub configuration related to emonth5 is:

[[23]]
    nodename = emonth5
    [[[rx]]]
       names = temperature, external temperature, humidity, battery, pulsecount
       datacodes = h,h,h,h,L
       scales = 0.1,0.1,0.1,0.1,1
       units = C,C,%,V,p

Could you help on having only one decimal place ?
Thanks in advance

Formatted text. BT, Moderator

The short answer is no - what you are seeing there is a result of the way the floating point numbers are encoded. The number that comes from the emonTH is an integer that is 10 × the true temperature so that you can have the temperature to one decimal place. You multiply the value that comes from the emonTH by 0.1 to get back to the correct number. That number is now a floating point number and while certain values can be represented exactly, most floating point numbers will have an error in the last few digits.

When you display those values in emonCMS, you can choose the number of decimal places to be shown.

image

Robert, thank you so much.

After your answer I managed to trim unnecessary decimals in emoncms mqtt messages.

Regards, ciao