You are here

osidc

BluetoothLE Project

Last spring, a faculty member and student met with me to discuss building an instrument and I agreed as a kind of "dry run" as part of the preparation for my new class.  It sounds like a relatively simple project: a small, wearable device that collects two temperature readings. After a cursory bit of research, I recommended we try using the Adafruit Feather with BluetoothLE and two Onewire temperature sensors. It sounds simple, but trying to get it to work proved way more complicated than I had imagined.

First, we were hampered by trying to connect to the feather using the Windows laptop the student had. She didn't know anything about using serial ports via USB. And the USB cable she had was power only. And the bluetooth interface on her laptop couldn't do BluetoothLE at all. So everything felt like two steps forward and one step back.

Getting first one and then two temperature sensors working over the Onewire interface was not too bad. But then we confronted the fact that her laptop couldn't do BluetoothLE -- and I realized that even if we could, we would end up wanting a data logger that would remain after she completed her project. So I recommended we get a Raspberry Pi.

I had expected BluetoothLE to be relatively straightforward. Boy was I surprised. There were a few examples that were provided with the Adafruit Feather: we tried the heart-rate monitor example to start with. But it turned out to be not a good fit for what we were trying to do. It turned out that the implementation is tied to proprietary protocols and there were complicated twists at every level. The heart rate monitor example uses a predefined set of characteristics that are not readily generalizable. After struggling with it for a long time I was on the point of giving up.

After much experimentation, I decided that a generic uart connection would make more sense. But there were a bunch of tricks to getting it to work at all. It turned out I couldn't connect to the device without first doing a "scan" with the adaptor. The python bindings that came from Adafruit didn't work. Eventually, I found pygatt -- a different set of python libraries that (by using a deprecated set of connection tools) I could get to connect more-or-less reliably, and receive data. But it could only send text, so I multiplied the float by 100, rounded to an integer, transmitted the integer as CSV, parsed the CSV with python, and divided by 100, before rebuilding CSV together with a time stamp.

It reminded me a bit of the Galileos I worked with a couple of years ago. https://blog.bierfaristo.com/content/galileo-wrap As an expert, I could work with them and ultimately get them to roll-over and bark. But it wasn't something that I would expect a novice to be able to take on and get anywhere with.

Overall, the experience was very useful to me for the kinds of projects I'm hoping students will do. And I learned a bunch of useful tricks for working with these tools, although there are still a number of hurdles to overcome.

Subscribe to RSS - osidc