When developing a Bluetooth Low Energy peripheral, it’s often useful to have an app that can connect to and test the peripheral to ensure it’s working as expected. If, however, you don’t already have a companion app for the device, you’d either have to write one from scratch, or use an existing app, such as our flagship mobile app LightBlue® (available on Android and iOS).
LightBlue® allows you to connect to Bluetooth Low Energy devices, read and write to characteristics, subscribe to notifications, and a lot more. Though it’s a powerful tool, you’ll probably need a way to automate more complex tests for long-term development. This is a situation where we can leverage the rapid prototyping capabilities of Python and write a script that emulates a BLE client.
As luck would have it, we recently worked on a device that had a flaky BLE connection with its companion mobile app. We’ll break down how a Python script and Adafruit’s BluetoothLE library was used to test the robustness of the BLE connections, and figure out whether the source of the issue was the mobile app or the device itself.
The nice thing about Adafruit’s BluefruitLE library is that it works on both Linux and macOS. Under the hood, it uses BlueZ on Linux and CoreBluetooth on macOS, but it abstracts away all platform-specific BLE code behind the API. We should also note that this library does not support Windows. For Windows development, an alternative could be to use PyGatt with a BlueGiga dongle.
Adafruit publishes a wide range of writing and video content, including interviews and reporting on the maker market and the wider technology world. Our standards page is intended as a guide to best practices that Adafruit uses, as well as an outline of the ethical standards Adafruit aspires to. While Adafruit is not an independent journalistic institution, Adafruit strives to be a fair, informative, and positive voice within the community – check it out here: adafruit.com/editorialstandards
Stop breadboarding and soldering – start making immediately! Adafruit’s Circuit Playground is jam-packed with LEDs, sensors, buttons, alligator clip pads and more. Build projects with Circuit Playground in a few minutes with the drag-and-drop MakeCode programming site, learn computer science using the CS Discoveries class on code.org, jump into CircuitPython to learn Python and hardware together, TinyGO, or even use the Arduino IDE. Circuit Playground Express is the newest and best Circuit Playground board, with support for CircuitPython, MakeCode, and Arduino. It has a powerful processor, 10 NeoPixels, mini speaker, InfraRed receive and transmit, two buttons, a switch, 14 alligator clip pads, and lots of sensors: capacitive touch, IR proximity, temperature, light, motion and sound. A whole wide world of electronics and coding is waiting for you, and it fits in the palm of your hand.
Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7pm ET! To join, head over to YouTube and check out the show’s live chat – we’ll post the link there.
Python for Microcontrollers — Python on Microcontrollers Newsletter: CircuitPython 8.1.0 and 8.2.0-beta0 out and so much more! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi