Tutorial: Connecting a wireless Bluetooth SoC board to update a Cloud Dashboard via an industrial gateway.
This application note explains the complete setup and sample script to send environmental data, e.g. temperature from a BLE sensor board to a cloud dashboard using our industrial nodeG5 gateway.
This exercise uses the following
1. A Silicon Labs EFR32XG24 Wiless SoC BLE development board
2. Amplified Engineering nodeG5 industrial gateway with integrated sample scripts.
3. Ubidots IoT Cloud Dashboard
We will not go deep into programming the XG24 development board using the Simplicity Studio 5 IDE for C development.
To get started, we used the sample bt_doc_thermometer C application, which enables a remote Bluetooth host (nodeG5) to pair with the board and then will send temperature readings to the gateway. We then build and the flash the .hex file over to the board.
We have included a demo script \amp\iot\BTdata2DB.py that (1) connect to the XG24 dev board via Bluetooth BLE to receive temperature readings then (2) writes the data (temperature) to on board data store for an active IoT Cloud client to send the data out.
First enable the gateway Bluetooth radio by switching “Bluetooth Radio” to “On” and the gateway needs to be rebooted to activate the radio (and will be enabled in future reboots).
Next, we need to check the BLE sensor board’s MAC Address and UUIDs using [bluetootctl]
The user can check the Bluetooth Assigned Numbers documents i.e. the GATT UUIDs (i.e. for Device Service and Parameter Characteristics) and also data types used for the temperature data sent to our gateway.
The user will now have the MAC and UUID that is needed for the Python script.
SERVICE_UUID = “00001809-0000-1000-8000-00805f9b34fb”
CHARACTERISTIC_UUID = “00002a1c-0000-1000-8000-00805f9b34fb”
DEVICE_MAC_ADDRESS = “68:0A:E2:4B:D4:0C”
The script uses the Python Bleak package to connect and manage the Bluetooth connection with the XG24 board.
The program then waits for notification of data received from the device 0x1809 Health Temperature and specific GATT Characteristics, i.e. temperature 0x2A1c
A Python asyncio notification handler will be initiated to wait for temperature data bytes from the service i.e. our prototype “Healthcare Temperature” sensor apparatus.
Each time the gateway receives a data packet from the temperature sensor board over BLE, the write_data_measurements() function will process the received bytes and write the temperature data to the gateway’s database. The user can choose to further process the data, e.g. statistically or send the data to a Cloud back-end or server (e.g. MQTT)
In this demo, the data is sent to a cloud dashboard service, Ubidots over LTE with the integrated data client. The nodeG5 gateway also supports AWS Iot Core, Azure IoT Hub/Central and also via a TLS secured MQTT client (example below).
In this demo, the sensor board’s temperature data is visualised as a graphical real-time widget.