UT61E Bluetooth: HM-11 Receiving and Decoding on Linux

The HM-11 Module implements a Bluetooth 4.0 (BLE) notification characteristic, this means after subscription to this characteristic the other side will automatically receive the serial data packets without explicitly asking. In the case of the UT61E this happens every 0.5s (2Hz sample rate).

Important note (2019/2020): This post is outdated, i built a better solution in the meantime: BLE Serial

Utilizing the the BlueZ bluetooth stack on Linux and the included gatttool, it is possible to set up the connection/subscription in an interactive terminal session. I am not going to show here how this works though, since doing it programatically makes more sense. The pygatt module does exactly this, makes the gatttool interface usable in python scripts. I had to modify it a bit to get the data out, also i have written a script that opens the device and prints the raw data as ASCII to stdout. To use it clone or download my repo, make sure you have installed the pexpect python2 module and then execute bt4-reader.py with python2. It will be very likely that it will not connect, because the MAC is not matching (line 30):

device = adapter.connect('20:91:48:4C:4C:54')

It is necessary to change this to your module address, to get the addresses of devices in reach use hcitool lescan. In addition the script assumes that hci0 is the bluetooth adapter and the UUID is from the HM-11 module, on all other setups this must be adopted.

Now if everything works it should output something like that (example from the voltage range):

000002;000:0
000002;000:0
000001;000:0
000001;000:0
000002;000:0

This are the raw 12 byte long packets.

To decode this there comes another nice project into play, the ut61e (Python) package from Philipp Klaus. It can be simply installed with pip install ut61e. Now just pipe the output into the es51922 script to get the interpreted output:

./bt4-reader | es51922
00:03:52.215904 0.0002 V
00:03:52.695507 0.0002 V
00:03:53.215803 0.0001 V
00:03:53.695640 0.0001 V
00:03:54.215732 0.0002 V

Also the output will be saved into a csv file in the current directory and can be easily imported into other applications.

Another option is create virtual serial ports with socat and write the data there, i have a few lines in bt4-reader.py to do this, comment in the lines cointaining ser. Then for example dmmut61e can be used to save/process the data.