Testing the Bluetooth BLE server and clients interactions on different platforms

Introducing Bluetooth Low Energy

Bluetooth Low Energy, BLE for short, is a power-conserving variant of Bluetooth. BLE’s primary application is short distance transmission of small amounts of data (low bandwidth). Unlike Bluetooth that is always on, BLE remains in sleep mode constantly except for when a connection is initiated.
This makes it consume very low power. BLE consumes approximately 100x less power than Bluetooth (depending on the use case). Additionally, BLE supports not only point-to-point communication, but also broadcast mode, and mesh network.

With Bluetooth Low Energy, there are two types of devices: the server and the client. The server advertises its existence, so it can be found by other devices and contains data that the client can read. The client scans the nearby devices, and when it finds the server it is looking for, it establishes a connection and listens for incoming data.

Hardware under test

In this project, we will use a Bluetooth LE server running on ESP32 board and two BLE clients. The first one is running on Dell notebook with Windows 11 and the second one is running on Raspberry Pi4 with Raspbian OS.

ESP32 BLE Server:
– Freenove ESP32 S3 WROOM board
– DHT22 temperature/humidity sensor
– 10 kOm resistor
– breadboard

Pinout of DHT22 sensor you can see in the picture

 

 

 

 

 

 

 

This diagram should help you work out where each pin needs to go on the ESP32.
– Pin 1 is VCC (Power Supply 3.3 – 5V)
– Pin 2 is DATA (The data signal)
– Pin 3 is NULL (Do not connect)
– Pin 4 is GND (Ground)

This diagram below shows how we will connect for the testing sketch. Simply ignore pin 3, its not used. You will want to place a 10 KOhm resistor between VCC and the data pin, to act as a medium-strength pull up on the data line. Connect data to GPIO pin 21, you can change it later to any pin.

BLE Server implementation

We will use Arduino IDE for creating a service with two characteristics. One for the temperature and another for the humidity. The actual temperature and humidity readings are saved on the value under their characteristics. Each characteristic has the notify property, so that it notifies the client whenever the values change. The source code of BLE server could be found at the git repository here..

Client BLE build

I chose a SimpleBLE project because it provides fully cross-platform BLE libraries and bindings for Python, Rust and C++. Moreover the project has very good documentation. For more details about this projects, refer to the documentation here…

As I already mentioned I used Dell laptop with Windows 11 and Raspberry Pi4 running the last version of Raspbian OS.

First of all, we need to build the “simpleble” library on both platforms Windows and Linux. The build process is well documented and simple enough, just a few installations required-Windows SDK for Windows and libdbus-1-dev for Linux.
The second step is to build the test application. I took a “notify” example as a prototype for my simple test application.
– it scanning the BLE devices
– if BLE Server was found, it checks if the required service/characteristic is supported
– if supported then it subscribes for the service/characteristic.
– print the received temperature/humidity values

To build the test application you should use cmake. The “ble-client” directory contains CmakeLists.txt file which works on both platforms. The source code could be found at the git repository here…

The pictures below show the output of the test application on both platforms.
Linux:

Windows: