BLE temperature sensor
Advertise a GATT temperature characteristic fed by an SHT3X — read it from your phone, and get notified every two seconds.
Click through the files — it's the whole project
BLE temperature sensor — Visual Studio Code
Select a file from the explorer
xiao_ble · GATT 2A6E BLE · Sensor · notify
What's going on
- One sensor, one characteristic. The SHT3X sits on I2C at 0x44, and the GATT Temperature
characteristic (2A6E) is an
Int16in hundredths of a degree — the spec's units, not a float. onRead(centi)answers a phone's read request with the last fetched value;notify(0, centi())pushes a fresh one to subscribers every two seconds. The0is declaration order — the first characteristic declared is index 0.char()without aservice()rides the default Environmental Sensing service, which is where 2A6E belongs.- Requires a board with a BLE radio — the XIAO nRF52840 target in the config file is the primary one. On a board without one, this program is a compile-time error, not a runtime surprise.
Flash and read it
terminal
npx @typecad/hal create my-project --target xiao_ble/nrf52840
cd my-project
npx @typecad/hal build --compile --upload --port COM4Open a BLE scanner app (nRF Connect, LightBlue), find TempSensor, and subscribe
— the temperature rolls in every two seconds. Breathe on the sensor and watch it climb.
Where to go next
- Bluetooth Low Energy — services, permissions, notify, and connection events
- Sensors — part tokens, channels, and the typed
get() - Communication buses — I2C devices and addresses