Hi Michal,
let start with a check and validation of received data
“data1” : {“value”:“15”},
“data2” : {“value”:“8”},
“data3” : {“value”:“0”},
“data4” : {“value”:“146”},
“data5” : {“value”:“83”},
“data6” : {“value”:“2”},
“data7” : {“value”:“255”},
“data8” : {“value”:“182”}
converted to hex numbers is
0F, 08, 00, 92, 53, 02, FF, B6
In the github repository there is a decode.py
script. If you use it, the data are decoded and it seems like valid values with 4°C temperature:
bcf-sigfox-climate-monitor$ ./decode.py 0F0800925302FFB6
Temperature : 4.0
Humidity : 73.0
Illuminance : 1190.0
Pressure : 93694.0
I’m not familiar with Sigfox backend decoder and we don’t use it, we have custom decoder scripts in Python. Unfortunatelly the Sigfox backend doesn’t have any decoder simulator to their grammar so it’s hard to do it from my head. Maybe @Karel has more experience.
I also couldn’t find their documentation so I’ll stick with https://gist.github.com/kthy/c0c46091bce186188a11b369c32702f5
The issue I see here is that in the C code we divide or multiply some values before transmission but the Sigfox backend does not allow this in their grammar. You can get around this by using float
if you need some decimal precision, but float is 4B so you can fit only 3 values in a single Sigfox packet. That is why our firmware has to do some math before sending 4 sensor variables.
See for the lines in the firmware starting from here:
temperature = average * 2;
humidity = average * 2;
illuminance = average / 2;
pressure = average / 2;
So to get correct values you need to have your own script to do the decode bits, or change the firmware and the format of sent data (get rid of all * 2 and / 2, you need also to take into account that the values must fit in two bytes or extend them to 4byte int. Pressure with value 93694.0 is well above 65535 which can fit in 16bits/2bytes, the same apply for illuminance).
Also in your script you use “variables” data1 to data8 but if you use int::16 then the Sigfox parser uses two bytes, so you cannot have 8 variables in your decoder.
So this could be the decode script, but you still have to do proper multiplation/divide for the values:
header::uint:8 temperature::int:16:little-endian humidity::uint8:8 illuminance::uint:16:little-endian pressure::uint:16:little-endian
Illuminance and pressure are unsigned variables, so I’ve used uint
for these items.
In case the temperature will be 4°C then the byte 1&2 (indexed from zero) would be exactly same like the data in the begining of my post: 0x08, 0x00
which in little endian is 8
in decimal, then you need to divide this by 2 (because in the firmwre it is multiplied by 2 to get 0.5°C precision). 8/2 = 4°C
.