Bcf-kit-sigfox-climate-monitor - data received

Hello,
I succesfully uploaded firmware bcf-kit-sigfox-climate-monitor and I am receiving some data to sigfox backend.

But for me it looks that data received are a bit strange.

From firmware code i expect to receive 7 values:

buffer[1] = temperature;
buffer[2] = temperature >> 8;
buffer[3] = humidity;
buffer[4] = illuminance;
buffer[5] = illuminance >> 8;
buffer[6] = pressure;
buffer[7] = pressure >> 8;

In my API callback I have following:

data1::uint:8 data2::uint:8 data3::uint:8 data4::uint:8 data5::uint:8 data6::uint:8 data7::uint:8 data8::uint:8

If I check message I have there this:

GET https://api.thingspeak.com/update?api_key=xxxxxxxxxxxx&field1=15&field2=48&field3=0&field4=94&field5=0&field6=0&field7=179&field8=191 HTTP/1.0

I copied data here:

field1=15
field2=48
field3=0
field4=94
field5=0
field6=0
field7=179
field8=191

None of received data looks like what I expected (temperature, humidity, illuminance, pressure). What am I doing wrong? :slight_smile:

HI,
because you used bad value format for decoding, uint:8 can use only for humidity, but other values is uint:16:little-endian. And if you look at the code, the values are multiplied or divided by an example:

float average;

int16_t temperature = 0;

if (bc_data_stream_get_average(&stream_thermometer, &average))
{
    header |= 0x01;

    temperature = average * 2;
}

After more than year I am trying to experiment more and still have problems with correct “custom payload”.

I configured two callbacks, one is this:

data1::uint:8 data2::int:8 data3::int:8 data4::uint:8 data5::uint:8 data6::uint:8 data7::uint:8 data8::uint:8

Data I am receiving are following:

“data1” : {“value”:“15”},
“data2” : {“value”:“8”},
“data3” : {“value”:“0”},
“data4” : {“value”:“146”},
“data5” : {“value”:“83”},
“data6” : {“value”:“2”},
“data7” : {“value”:“255”},
“data8” : {“value”:“182”}

For second callback I tried to configure correct enconding (for now only for temperature)
data1::uint:8 data2::int:16:little-endian data3::int:8 data4::uint:8 data5::uint:8 data6::uint:8 data7::uint:8 data8::uint:8
, but in message I am receiving

{“value”:“null”} for all data fields.

If I tried In my opinion correct enconding for all data I received also “null”

data1::uint:8 data2::int:16:little-endian data3::int:16:little-endian data4::uint:8 data5::uint:16:little-endian data6::uint:16:little-endian data7::uint:16:little-endian data8::int:16:little-endian

On another side, if I use for all uint:8 data and divide/multiply them as in code for example temperature seems to be OK.

I am not programmer, so all this is for me “try and you will see” :slight_smile:

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.