A Simple Web Configured BLE To GPIO Bridge

[Daniel Dakhno] kept ending up in a situation where the ability to read the status of, or control a few digital IO pins with minimal effort, would be terribly useful. Not wanting to keep compiling code, for such simple needs, they instead used a nRF51-based module as a physical interface and produced a general purpose firmware that could be configured with a simple web interface. The NRF51-IO-module was born, whose job is to pair with whatever device you have in front of you, provided it supports BLE, and give direct access to those IO pins.

Rather than acting as a rather slow logic analyser, the firmware is intended for mostly static configurations. The web application sends a configuration packet over to the nRF51 board, which then programs it into FLASH and restarts, reading the updated configuration and applying it to the IO pins. These outputs then persist as long as there is power. The read-side of the equation can also be performed via the web page, but we didn’t have a chance to verify that. The code implements the Bluetooth automation IO service as well as the binary sensor service so if you have access to applications that talk these services, then you should be able to fire it up and go with it, although we’ve not personally tested this due to lack of an nRF51 board. We noticed that the Home Assistant automation platform supports the BT binary sensor, which might be a big help for some people with a need for some wireless control and sensing.

If you need a practical example of a use for remote sensing, here’s a physical mailbox status monitor, using the nRF51. Whilst we’re thinking of Bluetooth and sensors, here’s a custom firmware for some super cheap environment sensors that frees them from vendor lock-in.

Header image: Ubahnverleih, CC0.

5 thoughts on “A Simple Web Configured BLE To GPIO Bridge

  1. Oh man there is SO MUCH MORE IN STORE for Bluetooth and Home Assistant. Check the release notes for the upcoming September release which should ship in the next day or two: https://rc.home-assistant.io/blog/2022/09/06/release-20229/#bluetooth-everywhere

    Home Assistant will now support Bluetooth Proxy devices, which can be as simple as an ESP32. Plug ESP32s where you need BT access, and BT messages can be relayed to your Home Assistant installation.

  2. Nice. Another more generic solution to this problem may be using Espruino – the javascript interpreter that also runs on nrf51 (e.g. the microbit 1). It is tight fit for 16KB RAM and 256KB of Flash of nrf51 so some features are stripped down and there is not much storage and ram stack space for storing and executing complex js programs when compared to nrf52 builds but still it is quite capable to implement such BLE service too and more. I can provide generic nrf51 build I use if there is an interest. BTW I also managed to squeeze Espruino interpreter into stlink v2 dongle clone https://github.com/fanoush/EspruinoBoards/tree/master/STLINKV2 (also is a tight fit into 20KB RAM and 128KB Flash) – so it is also generic scriptable usb to gpio/spi/i2c bridge. Web Bluetooth and Web Serial API can both be used from chromium based browsers as part of web page.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.