This application implements a Bluetooth Low Energy (BLE) temperature sensor using the BTHome format for data advertisement. BTHome is an energy-efficient format for transmitting sensor data over Bluetooth LE, compatible with popular home automation platforms like Home Assistant.
The application supports three different temperature sensors:
- Texas Instruments TMP112 - I2C digital temperature sensor (default)
- Maxim DS18B20 - 1-Wire digital temperature sensor
- Bosch BME680 - I2C environmental sensor (temperature + humidity)
Key features:
- Advertises temperature data every ~1 second using BTHome format
- Low power consumption suitable for battery-powered applications
- Supports both nRF52840 DK and nRF54L15 DK development boards
- Configurable sensor selection through Kconfig
- Nordic nRF52840 DK or nRF54L15 DK development board
- One of the supported temperature sensors:
- TMP112 (I2C address 0x48)
- DS18B20 (1-Wire)
- BME680 (I2C address 0x76)
- Breadboard and jumper wires for sensor connections
- BTHome compatible listener (e.g., Home Assistant with BTHome integration)
- nRF Connect SDK v2.4.0 or later
- West build tool
- nRF Connect for Desktop (for board configuration and flashing)
Connect to nRF52840 DK:
- VCC → 3.3V
- GND → GND
- SDA → P0.26 (Arduino A4)
- SCL → P0.27 (Arduino A5)
Connect to nRF52840 DK:
- VCC → 3.3V
- GND → GND
- DATA → P1.02 (Arduino D1) with 4.7kΩ pull-up resistor to 3.3V
Connect to nRF52840 DK:
- VCC → 3.3V
- GND → GND
- SDA → P0.26 (Arduino A4)
- SCL → P0.27 (Arduino A5)
Clone this repository under the samples folder in your nRF Connect SDK installation.
TMP112 sensor (default):
west build -b nrf52840dk/nrf52840 -- -DCONFIG_SENSOR_TMP112=y
DS18B20 sensor:
west build -b nrf52840dk/nrf52840 -- -DCONFIG_SENSOR_DS18B20=y
BME680 sensor (temperature + humidity):
west build -b nrf52840dk/nrf52840 -- -DCONFIG_SENSOR_BME680=y
TMP112 sensor (default):
west build -b nrf54l15dk/nrf54l15/cpuapp -- -DCONFIG_SENSOR_TMP112=y
DS18B20 sensor:
west build -b nrf54l15dk/nrf54l15/cpuapp -- -DCONFIG_SENSOR_DS18B20=y
BME680 sensor (temperature + humidity):
west build -b nrf54l15dk/nrf54l15/cpuapp -- -DCONFIG_SENSOR_BME680=y
After building, flash the application using west:
west flash
Or use nRF Connect Programmer from nRF Connect for Desktop.
Before flashing firmware to the nRF54L15 DK:
- Use the Board Configurator
- Disable VCOM0
- Set VDD to 3.3V
- Apply the configuration before flashing
After flashing and powering on the device:
- The device will start advertising as "BTHome sensor"
- Temperature data is broadcast every ~1 second using BTHome format
- For BME680, both temperature and humidity data are advertised
You can monitor the device operation via RTT or UART:
Starting BTHome temp sensor
Bluetooth initialized
Sensor initialized
Temperature: 23.5°C
[BME680 only] Humidity: 45.2%
- Ensure the BTHome integration is installed and configured
- The sensor should be auto-discovered as "BTHome sensor"
- Temperature (and humidity for BME680) will appear as sensor entities
- Data updates approximately every second
Any application supporting BTHome format can receive the sensor data. The device advertises:
- Service UUID: 0xFCD2 (BTHome)
- Data format: BTHome v2 (unencrypted)
- Temperature: 0.01°C resolution
- Humidity: 0.01% resolution (BME680 only)
- Check that the sensor is properly connected and powered
- Verify the correct sensor configuration is selected
- Monitor console output for initialization errors
- Ensure the device is not already connected to another BLE central
- TMP112/BME680: Check I2C connections and pull-up resistors
- DS18B20: Verify 1-Wire connection and 4.7kΩ pull-up resistor
- Check sensor power supply (3.3V)
- Verify sensor address matches overlay configuration
- Ensure BTHome integration is installed
- Check Bluetooth adapter range and interference
- Restart Home Assistant if discovery is delayed
- Check HA logs for BTHome-related errors
- Ensure nRF Connect SDK is properly installed
- Check that you're in the correct directory
- Verify the target board is supported
- Clean build directory:
west build -t clean
├── boards/ # Board-specific overlays
│ ├── nrf52840dk_nrf52840.overlay
│ └── nrf54l15dk_nrf54l15_cpuapp.overlay
├── include/
│ └── sensor.h # Sensor interface header
├── src/
│ ├── main.c # Main application and BLE advertising
│ └── sensor.c # Sensor initialization and reading
├── CMakeLists.txt # Build configuration
├── Kconfig # Configuration options
├── prj.conf # Project configuration
└── README.rst # This file
For more information about BTHome format, visit https://bthome.io