Ruuvi payload bytes unpacking

I am trying to unpack in python the payload I receive from mqtt broker, from a ruuvi sensor flashed with WP5. After decoding the google protobuf, I end up with the payload which packed looks like:

b’\xbf\x18@\x82\x01\x18\x8f\x01\x02\x02\x19\x0b\xf2\x04\x18\xeb\x05\x04\x06\x19\x1f@\x07\x16\x08\x18\xff\x18A\x86\x02\x19\x03\xe8\x19\x03\xe8\x18\xf58I\x04\x18B\x82\x00\x00\xff’

I am using struct.unpack (format, payload) based on the documentation ruuvi provides

However I am having a hard time guessing the proper format for unpacking, although based on their direction it should look like similar to ‘iiiiii’, or smth like that.

I usually end up with struct.error: unpack requires a buffer of 68 bytes which means my format isn’t supporting the way it was packed. I presume there are no packing bits.

If someone has done this before, or have experience in this, will appreciate it if he can use the above payload and the right format to get the readings accordingly.

Thanks,
SA

Hello,

The sequence you pasted seems something else than the documented Wirepas sensor data format to me. My experience with Wirepas is a few years out of date, but their support is usually very fast.

Thanks otso.
Appreciate your answer and touching base.

All is solved now. You might have been right when you saw that payload and it seemed a bit odd : I was looking at the wrong end point and therefore at the wrong payload.

So readings of the sensor for say air pressure (scanning the right endpoint) are struct.unpack(’<L’, b’\x05\x8b\x01\x00’) in the ruuvi which corresponds to 1011.25hPa and makes sense, I live by the seaside.

Temp will be struct.unpack(‘h’, b’\xc5\x08’) and makes sense 22.45 celsius indoors while it was snowing outside.

Regards,
SA

1 Like