Taking a sauna is a really emotional and personal experience. Sometimes after taking a sauna you know something was not right but often is it hard to actually be sure what was wrong. Using the here proposed system it is not only possible to measure but also to save and visualize the quantitative values. That way you can sustainably improve your sauna experience!
Modern sensors and advanced technology allow us to measure different environmental values. A powerful sensor is the Gas Sensor BME688 by Bosch Sensortec GmbH. Using an humidity, pressure, temperature and gas sensor in combination with a neural network it is possible to gain information about the air quality as well as the smell of the sauna infusion. Therefore the neural network had to be trained (this was the fun part).
With the XIAO ESP32-C3 it is possible to receive the decision of the neural network but also the raw sensor data from the BME688. This is important because depending on the heating oven, carbon monoxide can be a huge risk. The gas sensor is highly sensitive to CO which will lead to high values of the gas sensor. We used the Rock5b (or any other Single Board Computer like Raspberry Pi can be used) to receive the values from the ESP32 over MQTT. The task of the Raspberry Pi is to be the MQTT Broker (we used HiveMQ), to save the data to a database (Influxdb) and visualize it using Grafana. For comfort we used docker for managing the applications.
1) HardwareThe used micro controller XIAO-ESP32-C3 controls the environmental sensor BME688 via I2C-Interface. The default I2C address of the sensor is 0x77.
A Li-Po battery is connected to the charging interface of the µC. Through a 100k ohm voltage divider the voltage of the battery can be monitored by the µC.
Also we 3D-printed a casing. Everything set up correctly, the hardware could look like this:
The used single board computer (SBC) is the Rock5b from Radxa, on which the front-end application is running. The SBC creates an access point to which the microcontroller is connected.
You will need to install the BSEC2 library from Bosch Sensortec in order to control the BME688.
- Bosch BSEC2 library from https://github.com/boschsensortec/Bosch-BSEC2-Library
- Bosch BME68x library from https://github.com/BoschSensortec/Bosch-BME68x-Library
Add the downloaded libraries (zip file) to the Arduino IDE.
2.2) Arduino FirmwareThe ESP32 collects the following data:
- temperature
- pressure
- humidity
- gas sensor resistance
- Indoor air quality (IAQ) value
- IAQ accuracy
- IAQ static (optimized for non mobile measurements)
- CO2 equivalent
- Volatile organic compounds (VOC) equivalent
- sensor status
- battery level
Here is shown a rough flowchart of the firmware:
First, the ESP needs to connect to a PC via the serial port for debugging. It also uses wifi to connect to the MQTT broker on our SBC. Then the BME needs to be initialized and a connection validated. The main loop polls the BME for values. As soon as a new message is received, an interrupt is triggered. The values are interpreted in the callback function. Then the battery level is calculated and all data is sent via MQTT. Then the main loop continues with polling data.
2.3) NetworkAs mentioned before the µC is connected wirelessly to the single board computer and sends the sensor data via MQTT protocol to the broker.
Node-RED forwards the data to the database and saves them in a collection.
The actual user interface is the dashboard in Grafana where all the sensor data are plotted and accessible. So far, only the sensor data is displayed, but possible triggered actions based on a threshold value would be quite conceivable.
A crucial point of the BME is the ability to implement a neural network that can detect a odor (the infusion in our case) based on the sensor data. The training process is explained below.
3.1) Test setup- Raspberry Pi 3B+
- BME688
- Long four-core cable
In the following picture you can see the test setup in order to record the raw sensor data.
- You need to install the python library to control the BME688 via the GPIO-pins. Follow the installations instruction of the following Github project: https://github.com/pi3g/bme68x-python-library
- The library provides a python script that saves the raw sensor data in the right format so you can afterwards use the record to train a neural network in BME AI Studio.
- To start the measurement, boot the Raspberry Pi and run the script "BME_RawData.sh". The terminal then opens and if everything is connected correctly, the measurement starts. To end the measurement and save the data, press "Ctrl+C" in the terminal. If saving is successful, the saved measurement can be found in the ".../bme68x-python-library/tools/bmerawdata/..." folder.
As a demonstration example we record sample data from different types of tea: blueberry and raspberry. We recorded two data sets of 15 minutes per tea type.
During the measurement, always log the system time of the Raspberry Pi and the odor so you can specify the specimen later on in the BME AI Studio.
3.2) Training the neural network in BME AI StudioOnce the data has been recorded, the data is imported into BME AI Studio and labeled according to the investigated odor. A classification algorithm can then be created, here for example the type of tea: blueberry or raspberry. Two classes are created for this, to which the data samples are added accordingly. Before you train the neural network, you should read the instructions regarding the training settings (https://www.bosch-sensortec.com/software/bme/docs/process-steps/train-algorithms.html). These influence the quality of the AI model.
Unfortunately, the neural network can only be trained with a certain minimum number of data points. We were therefore unable to create an AI model with our training data.
Nevertheless, we tested an already trained model on the BME688.
3.3) Deploy the neural network to the BME688To deploy your trained network you have to export the algorithm in BME AI Studio. That done, you have to open the .c file and copy the generated array which have 2064 elements to the Arduino File "Deploy_AI_Classification.ino":
const uint8_t bsec_config_selectivity[2063] = {2,0,5,2,189,1,0,0,0,0,0,0,247, ... }; ==> const uint8_t bsec_config [2063] = {<<Copy array data here>>};
Then you can compile the Arduino program and upload to the micro controller. Because we were not able to train our own AI model, we tried out the example project, which distinguishes between coffee beans and neutral air.
In the following video you can see the output of the AI algorithm. Class 1 belongs to the odor "coffee beans" and class 2 belongs to the odor "neutral air".
It was interesting that the sensor has a certain delay in detection. This means that the odour is only detected after a short dead time and it takes a moment before the odour is no longer detected, even though the substance is no longer there.
This means that odours can be detected that are no longer perceptible but must have been present at this location in the past. However, the delay in detection must be taken into account.
4) Further challenges- Adjust the program code to execute the gas classification and the sensor data collection in parallel
- Tweak the sleep mode settings to reduce energy consumption
- Record more raw data to successfully train the neural network
We hope you enjoy read We hope you enjoyed our project and were inspired by our idea!
Comments
Please log in or sign up to comment.