Being the physicist that I am, I recently bought a Ventus W820 BLE enabled weather station. It comes with a rather crappy Android (also iOS) app that allows you to read out the values. Of course, what you really want is to be able to graph these data on your computer, for example using the neat WeeWX software. Of course, there isn't the tiniest bit of documentation regarding the data format of the BLE communication of this weather station, but then I guess that's why I really bought it in the first place. So how to get it working?
- First idea: decompile the Android app. This yields astonishingly readable code. I learned how to extract the sensor values from the BLE data packets, but how to get these packets at all? If you've ever taken a look at the BLE documentation you'll agree that it's far from trivial to get an BLE device to behave. So how do we find the ini sequence necessary to make the W820 spill its values?
- Time for some hardware magic. I bought a BLE sniffer and started poking around the airwaves, first with a Sensirion Smart Gadget (where the communication is fully understood) and then eavesdropping on the communication between the W820 and its app. With the help of Wireshark, the BLE dissector and some trial and error in gatttool I managed to come up with the required ini sequence.
- Next up: write a library to read the W820 sensor values. I chose Python since there's the excellent bluepy low level library and also the weather station software WeeWX is written in Python. In the process of getting all sensor values into WeeWX I stumbled upon a very nasty bug in the W820 firmware: the value of the wind speed depends on the temperature unit setting! The LCD display of the W820 shows the correct value, but over BLE there's a badly wrong value (also the app shows this error: try switching between degC and degF and watch the wind speed value). I have some empirical correction values that more or less fix the problem. Also: the temperatures come in two's complement which the app can't handle. So everything below zero is VERY hot...
- The final step was to write a connector to make the W820 usable in WeeWX. Nothing fancy here.