BTHome is an energy-efficient, but flexible BT format for devices to broadcast their sensor data and button presses.
Devices can run over a year on a single battery. It allows data encryption and is supported by popular home automation platforms, like Home Assistant, out of the box.
For more information, please visit BThome.
The project aims to implement a Server/Gateway library that facilitates the scanning and discovery of BTHome devices.
The vision of this development effort is to create a Server/Gateway library that simplifies the process of integrating BTHome devices into IoT setups. By enabling users to easily discover, add, and visualize BTHome devices' measured values, we aim to enhance the accessibility and usability of BTHome technology in various IoT projects.
The hardware connection is shown in the image below:
To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.
-
From the Launcher Home, add your hardware to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "bthome".
-
Click Create button on Third Party Hardware Drivers - BTHome v2 - Server examples. Example project creation dialog pops up -> click Create and Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.
-
Copy all source and header files in
app/example/bthome_v2_server
into the project root folder (overwriting the existing file). -
Install the software components:
-
Open the .slcp file in the project
-
Select the SOFTWARE COMPONENTS tab
-
Install the following components:
- [Third-Party Hardware Drivers] → [Services] → [BTHome v2 - Server]
- [Services] → [Command Line Interface] → [CLI Instance(s)] → default instance name: inst
- [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
- [Application] → [Utility] → [Log]
-
-
Build and flash the project to your device.
Note:
-
Make sure that the SDK extension is already installed. If not please follow this documentation.
-
Third-party Drivers Extension must be enabled for the project to install "BTHome v2 - Server" component.
-
Enable floating-point support for printf
The library offers functionality to scan for BTHome devices and display their measured values, such as temperature and humidity. The goal is to simplify the process of adding BTHome devices to IoT setups and visualize their data in a user-friendly manner.
The example implements a CLI Interface that provide some features:
- Scan BLE network and list BTHome devices. List them with the following parameters:
- MAC - Object ID - Encryption (Yes/No) - Encryption Key Available (Yes/No)
- List registered devices
- MAC - Encryption Key
- Register key by MAC
- Remove key by MAC
- Add device to the interested devices by MAC
- Remove device from the interested devices by MAC
- Start BTHome monitor : Periodically update the measured values for the interested devices in the console
- MAC - Encryption (Yes/No) - Encryption Key Available (Yes/No) - Object ID - Measurement Data
-
Open a console or a terminal program (e.g., TeraTerm) and connect to the device to see the logs.
-
Type
help
to see the supported commands: -
Start scanning to find BThome v2 devices
-
Register encryption key for device if need
-
You can add a device to the interested devices to check the data
-
Now you can be able to observe the data of device in the interested list
To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.
Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo.