In the competitive Bluetooth Low Energy chips, STMicroelectronics differentiates itself from the competition thanks to unique development tools and a standalone solution with no application embedded microcontroller. An external microcontroller is necessary and communicates via an SPI bus with the BLUENRG-MS.
See related product
A great tool is the BlueNRG Current Consumption, which allows you to visualize which parameters have the most influence on the power consumption. For instance, if we advertise 10 byte long data every 100 ms or 20 bytes every 200 millisecond, the difference of current consumption is around 40% for the same data rate.
But if the data rarely changes and 10 seconds is good enough, the current consumption decreases by 98%.
This application allows you to simulate all the configurations: scanning, advertising, connection in slave or master mode, number of channels for advertising, accuracy of the crystal and all the timings that are specified by the Special Interest Group (SIG). So before entering in the programming details to optimize the microcontroller, it is important to adequately specify the application requirements and understand the consequences of current consumption for each specification. This tool, whatever the final designed product, helps you to decide about trade-offs.
Because it can be tedious to develop and test their silicon when writing embedded programming firmware, STMicroelectronics offers the option to use Python. A software called BlueNRG GUI works in conjunction with a USB dongle that can be ordered as P/N STEVAL-IDB006V1M.
The tab script allows you to launch Python scripts.
All the specific Python commands are explained in the user manual UM2058.
When installing the BlueNRG GUI software, many examples of Python scripts are provided. Let's explain the script shown below.
The beginning of the program is a set-up. The hardware is reset followed by the mode configuration. Four modes are available. As we want only one connection as a slave, we need to choose mode 2. The public address must be defined as in general advertising, the payload always contains the 6 bytes of the advertising device address. The address can be entered as a parameter, but that is optional. With no parameter, the Python script automatically decides the address. With the windows at the bottom, we have access to the raw packets and meaning of each byte. By double clicking, a window pops up showing the raw packet. In our case, the address is 0x0280E1008BC5.
The transmission power level is equal to -2 dBm as shown by the correspondence table between enable high power, PA level and transmission power.
The GATT and GAP are initialized, the GAP as a peripheral. Then it is time to set up the service as a primary service that returns the service handle and add the characteristic inside the service. The parameters for each function are self-explanatory. All the details are available through the BlueNRG GUI or with the user manual UM1865 as shown for the add characteristic below.
There is an optional scan response, and the advertising discoverable parameters are written with the local name 'test'.
When the script is running, a sniffer can be used to monitor the packets sent by BLE devices.
In the AdvData section, it is verified that sent data matches the code. The payload has the following meaning:
- 02 01 06: 2 bytes; for flag 01 classic Bluetooth not supported and general discoverable mode for BLE
- 05 08 74 65 73 74: 5 bytes; with shortened name 'test'
- 05 12 06 00 08 00 : 5 bytes; flag 12 for slave connection internal range, and the minimum and maximum equal to parameters when we called the ACI_GAP_SET-DISCOVERABLE function
- 02 0A FE: 2 bytes for flag 0A (transmission power) and FE means -2dbm
We confirm these are the values that are entered in the code.
We finally wait for the connection, and in an infinite loop, a random number is generated, the characteristic value is updated and the system sleeps for one second. The script just needs to be uploaded in the Blue NRG GUI, and then you can push the “run script” button.
Once the Python script meets the requirements, you are ready to write an embedded program and take advantage of the ST ecosystem. Indeed, the BlueNRG also comes with an Arduino shield that can be plugged directly to an STM32 board. STMicroelectronics is a leader in cortex M microcontrollers thanks to its large family of STM32.
Python script, a USB dongle, an Arduino board easily pluggable to microcontroller boards and current consumption simulation are the key tools from STMicroelectronics that will allow you to develop a Bluetooth Low Energy application in a quick and efficient manner.