The UPT Demo Firmware is a powerful showcase of how to build a modular, sensor-rich IoT device using Sensirion's Unified Prototyping Toolkit (UPT) ecosystem. Its primary highlights include:
- I2C Auto Detection: True plug-and-play functionality. The firmware automatically scans the I2C bus, identifies connected Sensirion sensors, and starts reading data without any manual code changes for new sensor types.
- MyAmbience Integration: Full compatibility with the Sensirion MyAmbience app. The firmware broadcasts sensor data via BLE, allowing you to visualize environmental metrics on your smartphone in real-time. It also supports remote configuration of Wi-Fi settings and the broadcasted device name.
To get started with this project, you will need:
Hardware:
- LilyGo T-Display S3: An ESP32-S3 based development board with a built-in LCD.
- Sensirion Sensors: Any UPT-compatible I2C sensors (e.g., SHT4x, SEN66, SCD4x).
- Cables: Appropriate I2C cables (Qwiic/Stemma or similar depending on your setup).
Development Environment:
- Visual Studio Code with the PlatformIO extension.
This project leverages several Sensirion UPT libraries to handle complex tasks with minimal code:
- Sensirion Core: The base library for Sensirion sensor communication.
- Sensirion UPT Core: Provides the foundational data structures like
Measurement,DeviceTypeandSignalTypeused across the ecosystem. - Sensirion UPT I2C Auto Detection: Handles the heavy lifting of scanning the I2C bus and managing sensor drivers dynamically.
- Sensirion UPT BLE Server: Implements the UPT Bluetooth protocol for MyAmbience compatibility, including data broadcasting and settings services.
- Sensirion UPT Display: A high-level library for rendering sensor data and information screens on the T-Display S3.
- Third-party Libraries: NimBLE-Arduino for efficient BLE, Button2 for input handling, and
TFT_eSPIfor display support.
The firmware is built on a Task-based Architecture using FreeRTOS. This ensures that time-critical tasks like sensor reading and BLE broadcasting don't interfere with the UI responsiveness.
Configuration: config.h
Most high-level behavior can be tuned in include/config.h:
// Example configuration snippets
#define DEFAULT_DEVICE_NAME "UPT Demo"
#define SENSOR_AUTODETECT_UPDATE_INTERVAL_MS 500
#define BLE_ADVERTISEMENT_SAMPLES_UPDATE_RATE_MS 1000You can toggle features like enabling Wi-Fi or serial-on-startup for debugging here as well.
Core Logic and Tasks
The firmware is split into several key tasks initialized in main.cpp:
1. I2C AutoDetect Task: Periodically scans the bus and pushes new measurements to the AppContext:
// Snippet from I2cAutoDetectTask.cpp
sensorManager.refreshAndGetSensorReadings(pCurrentData);
// ... package data into MeasurementRecord and send to queue2.Data Manager Task:
Acts as the central hub, routing data from producers (sensors) to consumers (Display, BLE).
3.BLE Server Task:
Subscribes to the active sensor's data and updates the BLE advertisement for MyAmbience.
4.Display Task:
Manages the UI states (Info page, Sensor page) and handles user navigation.
5. AppContext:
The AppContext class serves as the "thread-safe" global state, managing the list of discovered devices and a circular buffer of the latest measurements.
By combining the power of the ESP32 with Sensirion's UPT libraries, we've created a versatile environmental monitor that is easy to extend.
We achieved a system that automatically adapts to hardware changes via I2C auto-detection while providing a seamless mobile experience through MyAmbience integration.
This project serves as an ideal template for anyone looking to build an IoT sensor nodes.














Comments