EmonHub receiving weird data, where is it coming from....?

I am running the attached (very basic) sketch that reads the temp from a DS18B20 and PSI from a pressure transducer.

I am seeing data arriving via the radio:

2016-06-26 01:43:10,057 DEBUG    RFM2Pi     149 NEW FRAME : OK 27 51 51 161 66 45 0 (-80)
2016-06-26 01:43:10,059 DEBUG    RFM2Pi     149 Timestamp : 1466905390.06
2016-06-26 01:43:10,060 DEBUG    RFM2Pi     149 From Node : 27
2016-06-26 01:43:10,061 DEBUG    RFM2Pi     149    Values : [13107, 17057, 45]
2016-06-26 01:43:10,061 DEBUG    RFM2Pi     149      RSSI : -80
2016-06-26 01:43:10,062 INFO     RFM2Pi     Publishing: emon/pool_water_meter/box_temp 13107
2016-06-26 01:43:10,063 INFO     RFM2Pi     Publishing: emon/pool_water_meter/filter_psi 17057
2016-06-26 01:43:10,065 INFO     RFM2Pi     Publishing: emon/pool_water_meter/3 45
2016-06-26 01:43:10,066 INFO     RFM2Pi     Publishing: emon/pool_water_meter/rssi -80
2016-06-26 01:43:10,067 INFO     RFM2Pi     Publishing: emonhub/rx/27/values 13107,17057,45
2016-06-26 01:43:10,069 INFO     RFM2Pi     Publishing: emonhub/rx/27/rssi -80
2016-06-26 01:43:10,070 DEBUG    RFM2Pi     149 adding frame to buffer => [1466905390, 27, 13107, 17057, 45, -80]
2016-06-26 01:43:10,071 DEBUG    RFM2Pi     149 Sent to channel' : ToEmonCMS

but none of the values are correct with the exception of the rssi which is sent automatically.

First, I am only transmitting two values from my sketch (box_temp and filter_psi, but according to my emonhub.log there are four values getting sent and the numbers make no sense to me. I have no idea why more than two numbers and the rssi are getting sent.

box_temp 13107 (this should be a temp in F)
filter_psi 17057 (should be a 1 to 2 digit number 0 to 60)

It looks like whatever: emon/pool_water_meter/3 45
is is actually my filter_psi

This is my enonhub.conf entry:

[[27]]
    nodename = pool_water_meter
    firmware = emon
    hardware = ds18b20_psi_transducer
    [[[rx]]]
       names = box_temp, filter_psi
       datacode = h
       scales = 1,1
       units = F,P

Under datacode I have tried f,i as that is what they are, but then I get an error in enomhub.log starting that 6 is not valid for datacodes f , i.

2016-06-26 02:02:36,644 WARNING  RFM2Pi     449 RX data length: 6 is not valid for datacodes ['f', 'i']

Also, none of the values except the rssi show up in my inputs on my emonpi.

In my sketch I am debugging the values I am sending:

Serial.print("TEMP: "); Serial.print(pool_sensors.box_temp);
Serial.print(", Filter PSI: "); Serial.println(pool_sensors.filter_psi); 

The values are correct. Here is the serial output:

Dallas Temperature IC Control Library
Locating devices...Found 1 devices.
Parasite power is: ON
Device 0 Resolution:9
TEMP: 80.60, Filter PSI: 46
TEMP: 80.60, Filter PSI: 44
TEMP: 81.50, Filter PSI: 44

DS18B20_PSI_RFM69HW-TESTING.ino (6.1 KB)

UPDATE -

For some reason, by changing my float to an int for my temperature, all of the bod data disappeared. I ahve no idea why that might be the case, but it did!

Hi Richard
In the original configuration your sketch was sending a float(4b) and a int(2b), which is 6 bytes of data. The “datacode = h” setting tells emonhub to expect unspecified number of ints(2b), the 6 byte packet was therefore seen as 3x Ints(2b).

So the float(4b) temperature value was seen as 2 x ints(2b) and the 3rd pair of bytes was actually the int(2b) filter_psi ie “emon/pool_water_meter/3 45” is value of 45 for un-named input number 3.

When you changed “datacode=h” to “datacode=f” you were telling emonhub to expect an unspecified number of floats(4b) so when 6 bytes arrived it was an issue as it was either 2 bytes too many or 2 bytes too little.

The “datacode=” function cannot be used to define mixed datatypes, had you used the plural “datatypes=” and defined the exact payload eg “datacodes = f, h” that would have worked as expected.

By changing the temperature to an int(2b) in your sketch you have altered the payload to fit the “unspecified number of ints” definition in emonhub by reducing the first value from 4 to 2 bytes and therefore the unexpected 3rd value becomes the pressure value ie ~45psi.

You should be able to return to using a float in your sketch if you define “datacodes = f, h” in emonhub.conf.

Paul -

Thanks! I see it now. I was thinking the datacode(s) setting was specific to each individual part of the payload that I was sending and that it just had to match what was being sent.

I did try

datacodes = f, i

Which matched what I was sending, but that gave me this:

2016-06-26 02:02:36,644 WARNING  RFM2Pi     449 RX data length: 6 is not valid for datacodes ['f', 'i']

Why is that? It should ahve matched the two fields I was sending it (temp and psi) and 6 should be valid for ‘f’, ‘i’ based on what you are saying.

Thanks

datacodes = f, i

Is a 4b float and a 4b signed integer = 8 bytes. Where as

datacodes = f, h

is a 4b float and a 2b signed integer = 6 bytes.

These are the data types commonly used by the OEM projects

there is a fuller version of this chart somewhere on the original site too but I can’t find it right now, I will try and find my original/local copy.

The datacode letters are defined by the python struct lib and most of them are available in emonHub.

EDIT - This was the original chart showing a wider range of datacodes. You can see the integer type can be between 1 and 8 bytes in Python and more interestingly, if you were using your same code on an Arduino Duo the “datacodes = f, i” would have worked since the same “int” datatype is twice the size of when used on an Atmega328 based Arduino Uno (or emonTx/TH etc). Using “int16_t” rather than just “int” would ensure the right size is used…

A post was split to a new topic: Measuring pressure (psi)