Close

Upgrading BMD-350 Firmware, Hot Swapping AT Mode

A project log for STM32L4 Sensor Tile

Small, connected device for smelling and hearing in any environment.

kris-winerKris Winer 07/19/2017 at 03:030 Comments

07/18/2017

The BMD-350 comes loaded with firmware that creates a BLE UART bridge such that simply writing Serial2.print (the BMD-350 is on the STM32L432 host's Serial 2 port) in the host's Arduino sketch sends anything one would normally write to an IDE serial monitor to the UART console in the Rigado Toolbox app on the smart device (iPhone in my case). This is convenient for checking on current conditions or proper sensor operation during a logging session, for example. And the BMD-350 UART configuration (baud rate, TX power, etc) can be changed on the fly using the Rigado Toolbox app.

The way the BMD-350 is configured in the host sketch is by entering AT Command mode, passing some configuration statements via Serial2.write, and then entering UART bridge mode for normal functioning. In order to enter AT Command mode one has to 1) hold the AT Mode pin on the BMD-350 module LOW, 2) then hold and release BMD-350 Reset LOW to reset the module. Of course, these pins are connected to STM32L432 GPIOs for this purpose. When the module powers on it senses the AT Mode pin and if it is LOW, the module enters AT Command mode. After the commands have been entered, the reverse process puts the BMD-350 back into UART bridge mode for normal operation. All of this takes a bit of time (~seconds), but for a one-time initial configuration (i.e., in setup) this is fine.

Rigado has impemented a hot swap AT mode such that if the hot swap is enabled during the BMD-350 initialization, then simply holding the AT Mode pin LOW during the running of the sketch will put the BMD-350 in AT mode and the configuration can be changed "on the fly" in the same way the configuration can be changed from the Rigado Toolbox app on the smart phone. Resetting the AT Mode pin HIGH returns the BMD-350 to BLE UART bridge mode. This is very convenient. More on this in a moment...

I upgraded the firmware on the BMD-350 nRF52 BLE module on the Sensor Tile since I wanted to be able to use the hot swap capability just added to the new protocol 3 firmware; the BMD-350 came with protocol 2 from the factory. After some initial fussing and after I finally decided to actually follow the directions on the Rigado website I succeeded in getting the firmware update to work. The update process was accomplished via OTA from the iPhone and required e-mailing myself three separate .bin files, a bootloader, the S132 soft device and the new BMDware (firmware). For each file I used the Rigado toolbox firmware upgrade tool to load the corresponding .bin file and after a few false starts got everything properly loaded. In order to make my Sensor Tile work again with the new firmware I had to "restart" bluetooth on my iPhone, meaning I had to disable and re-enable it in Settings for the changes to "take". Don't ask me why, it all finally worked so---no harm no foul!

Now the initial idea for my interest in hot swapping was so I could set the Tx power to the lowest setting, as I have been doing, but just before a Serial2.write I would bump up the Tx power to 11 or at least a higher-than-minimum value to temporarily increase the range. Then after the message was sent, bump it back down to the minimum to save power. Nice idea, but it takes time to effect the mode changes even without having to reset the module twice. For data update rates of ~1 Hz like I am using on the Sensor Tile this is simply not practical. The reason is that it takes ~100 ms or so each direction. So my idea of using hot swapping as a power saving strategy isn't going to work.

But there is another potential application of hot swapping that might.

Turns out BLE, despite the hype about BLE 5.0, is often best as a near-field protocol. Meaning for a lot of applications, people choose BLE because it requires a lot less power than wifi. The lowest power is achieved with the lowest Tx power settings, meaning using the BLE as a near-field communication protocol for when someone brings a smartphone close, say within a few feet, is where the optimum power efficiency is achieved. For longer range, we really want something like LoRaWAN when power efficiency is critical. Best practice is both near- and far-field connectivity using BLE + wifi, like on and ESP32 or a Raspberry Pi W Zero, or BLE + LoRaWAN (we're working on this one), etc. With the Sensor Tile, all we have is the one radio.

But the Sensor Tile can smell and hear. So wouldn't it be interesting if the BLE range could be increased on alert to, say, 40 meters or so. This could occur when voices are detected in an area where there should be none, or when CO2 levels breach a threshold, etc. The idea is, for most of the time, the Sensor Tile is in its lowest power state sniffing and listening. Interactions with its minders can be in the near-field, such as when a maintenance tech stops by to make sure everything is still running. But when the Sensor Tile detects an alert condition, it lets out a yell by cranking the Tx power to 11 to be sure its alert is heard in the front office.

Now one doesn't need a hot swap capability to do this since what's the difference if the alert happens right away or after a few seconds delay? Well, the host program has to be interrupted during this transition and thereby miss some important information. There could be multiple alert conditions that might get lost if the mode transition takes a long time. Lastly, the Sensor Tile might spend more time at the higher-power alert condition than necessary, reducing life in the field.

Are there applications where a power-efficient, short-time-to-alert capability might be useful?

Discussions