Skip to main content

Subsection 15.1.6 The Bluefruit Module: BLE as a UART

A complete BLE implementation is a large piece of software: the radio’s own firmware, the advertising and connection machinery of GAP, the attribute database of GATT, encryption, and the timing rules that tie them together. We will not write any of that ourselves. Instead we use the Adafruit Bluefruit LE UART Friend (Figure 15.1.4), a module that runs the whole BLE stack on its own processor. The module connects to our microcontroller through a USART, and the service it offers over the air is a UART service, with a characteristic for each direction. A phone that subscribes to the UART service’s transmit characteristic receives every byte our program transmits, and every character typed on the phone arrives as a received byte in our program. The outcome is that the Nucleo and the phone can talk to each other as if they had a direct USART connection. The app on the phone side is Adafruit’s Bluefruit LE Connect, and the link to install it is in Lab 9.
Figure 15.1.4. The Adafruit Bluefruit LE UART Friend. The silver metal box is the radio module that runs the BLE stack. The pads carry, by silkscreen name, DFU (device firmware update), GND (ground), VIN (the module’s power supply, which we run at 3.3 V), RXI (UART receive, from the microcontroller into the module), TXO (UART transmit, from the module to the microcontroller), CTS (clear to send) and RTS (request to send), the two flow-control wires that carry each side’s ready-or-not state, and MOD (mode selection). The switch labeled UART and CMD selects the module’s mode, and the MOD pin makes the same selection under software control. Image from the Adafruit guide.
The module has two operating modes, selected by the switch on the board, or by a Nucleo GPIO pin driving MOD. In data mode (the switch position labeled UART) the module streams raw data: every byte that arrives on the board via RXI goes out over the air, and every byte the module receives from the air gets placed and sent out on TXO. UART is the switch’s own label; Adafruit’s documentation calls the mode Data Mode. In command mode (the switch position labeled CMD) the module instead interprets what it receives on RXI as configuration commands, each beginning with the letters AT; you will use a few of them in Lab 9 to reset the module and give your device its name. The module also has two LEDs, labeled CONN and MODE on the board; CONN indicates the connection state, which is useful for debugging.
CTS (clear to send) is an input that gates the module’s transmissions: it is pulled high on the module by default, and it must be brought low before the module will send data out of TXO. In our wiring, the Nucleo’s USART drives it low through its own RTS (request to send) output whenever it is ready to receive, and the module’s RTS output does the same for us in the other direction; a design that does not use flow control ties the module’s CTS to ground instead. We’ll look in class at how the USART is configured to do this. The module’s own documentation is the Adafruit guide, linked in Lab 9; its pinout page is the one to read before class.