Smart IoT Sensor Built With XIAO ESP32C6: WiFi, MQTT, BME280/BME680 Integration & Power Management
by BegoonLab in Circuits > Sensors
437 Views, 3 Favorites, 0 Comments
Smart IoT Sensor Built With XIAO ESP32C6: WiFi, MQTT, BME280/BME680 Integration & Power Management
The project uses a Seeed XIAO ESP32C6 to build a low-cost, Wi-Fi-enabled sensor, ideal for applications where you need remote environmental monitoring. It includes instructions to set up a temperature, RSSI, and battery voltage sensor using MQTT to relay data to a Home Assistant setup or similar platform.
Supplies
- Seeed XIAO ESP32C6 – Main microcontroller
- Temperature sensor (BME280/BME680) - For monitoring environment
- Li-ion battery 3.7V – Power source for the sensor. The enclosure is designed for the usage of 18650.
- Soldering iron and solder
- Cable USB Type C – For programming and power
- Wi-Fi Antenna with U.FL connector - Highly recommended
- A few 3D printed parts
- Wires to solder up everything together.
- PC – For flashing firmware
- (Optional) two THT resistors 220k. One THT capacitor 100n.
Printing Enclosure
The sensor is housed in a customizable 3D-printed enclosure. STL files are available for download and 3D printing. To customize a model use a FreeCAD project. A 3D preview is available here.
When printing, it is recommended to orient the parts on the hotbed as shown in the picture.
Enclosure Assembly - Insert XIAO Board Into SoC Holder
Enclosure Assembly - Insert SoC Holder Into the Core Part
Pull down until it can't go any farther
Enclosure Assembly - Insert SoC Bracket
Enclosure Assembly - Insert Lock Into the Core Part
Wire All Components
Now solder up everything together according to schematics. And repeat an assembly steps if everything fits nicely.
Attach an antenna. Put the coaxial wire into the channels in the core part. Use a couple of drops of glue or double-sided tape to secure the antenna in its place.
Avoid blocking environmental sensors. Keep it away from SoC board, because when charging a battery it can be affected by built-in BMS heat exposure.
Pull the Wrapper
Finally, pull the wrapper onto the core part. Ensure that the lock is securing the wrapper.
At this step the enclosure is done, and you can plug in USB Type C and start flash the firmware.
Flash Firmware
Connect USB Type C.
- Install ESP-IDF - Official development framework for Espressif chips. Follow the ESP-IDF Getting Started Guide to set up the development environment.
- Clone the Repository of this project:
- Configure the Project
- go to XIAO Sensor Configuration
- Wi-Fi Configuration: Set up your Wi-Fi credentials to enable network connectivity.
- MQTT Configuration: Connect the sensor to your MQTT server by providing the necessary broker details.
- Battery Check (Optional): Enable battery voltage monitoring if power management insights are needed.
- BME Sensor Configuration (Optional): Choose between BME280 and BME680 sensors based on your requirements.
- Power Management Configuration: Set up wakeup duration, which is the duration in seconds that the device will remain in deep sleep before waking up.
- Then build a firmware
- And flash
- In case of issues check the logs. Some useful debug info might occur here.
Integrate With Home Assistant
Set Up MQTT Server. If you don't have an MQTT server, refer to the Home Assistant MQTT Integration guide.
The sensor publishes data to an MQTT broker in the following JSON format:
- ID: Unique identifier of the sensor
- RSSI: Wi-Fi signal strength in dBm
- battery_voltage: Current battery voltage
- temperature: Temperature reading from the BME sensor
- humidity: Humidity reading from the BME sensor (%)
- pressure: Pressure reading from the BME sensor (hPa)
- connection_duration_ms: Time taken to establish the MQTT connection
Configure `configuration.yaml`: Add the following configuration to your `configuration.yaml` file to define the sensor entities.
Restart Home Assistant. After updating the configuration, restart Home Assistant to apply the changes.
Configure Entity Card. Here is an example configuration for the entity card:
That's it. A simple HA configuration is ready to collect and show the data. For an extra sensor don't forget to change Sensor ID field, to distinguish them.
Follow the Project on GitHub
This is the project repository: https://github.com/BegoonLab/xiao-esp32c6-wifi-sensor/tree/main
Contributions are welcome!