Today, things like the Internet of Things (IoT) and Tiny Machine Learning (TinyML) are smoothly making computers a part of our everyday lives. In this article, we'll look at how Pico LTE is used, especially in a TinyML application that detects smoke.
By running the smoke detection algorithm on the edge, the need for constant data transmission to a centralized server is minimized, reducing latency and bandwidth requirements.
Pico LTE streamlines this process by providing LTE connectivity to the Raspberry Pi, ensuring a reliable network connection even in remote areas. This connectivity allows seamless communication between the Pico LTE device and the Edge Impulse platform, facilitating the training and optimization of the TinyML model. The trained model is then deployed back to Pico LTE, enabling smoke detection on the device itself.
It reduces dependence on continuous network connectivity, making the solution more resilient and applicable in scenarios with intermittent or limited internet access. In essence, Pico LTE serves as a bridge between the edge device and the cloud, optimizing the implementation of TinyML for smoke detection in a practical and resource-efficient manner.
Creating a TinyML model can be challenging because it's a relatively new field, and there's not much documentation or tutorials available online. Luckily, the Edge Impulse team has come to the rescue! ❤️ They've crafted a fantastic platform that guides you through building your TinyML model step by step. From collecting data to deploying the model, everything is well-explained and neatly organized.
In this project, I used the SparkFun ENS160 Air Quality Sensor with the Pico LTE device. Pico LTE RP2040 includes and:
The Raspberry Pi RP2040 is the debut microcontroller from Raspberry Pi - and it's fully supported by Edge Impulse. You'll be able to sample raw data, build models, and deploy trained machine learning models directly from the studio
Create an account on Edge Impulse to collect data and build models.
Sensor data can be read from the serial port using the CLI, but the Raspberry Pi Pico board does not support capturing data directly. You can use Edge-Impulse CLI to capture data from Pico LTE.
Simply follow these steps to install Edge Impulse CLI on your computer. You'll need NodeJS and Python, so make sure to install these dependencies before the CLI. Once the CLI is successfully installed, you're all set to capture data using the "edge-impulse-data-forwarder" command.
To send data over the serial port, a specific format is required. Values are separated by commas. Sensor 3 data are read, these are: TVOC, ECO2 and AQI. We won't use AQI data in model training as it's not needed. Thonny IDE is a handy tool for reading sensor data and sending it to the Edge Impulse Data forwarder.
The sensor connection was quite easy. It is enough to connect it to the Qwiic port of the Pico LTE with the Qwiic cable. That's it.
Script to read data from sensor and send it via serial port:
from ENS160 import ENS160
import time
air = ENS160()
while True:
TVOC = air.getTVOC()
AQI = air.getAQI()
ECO2 = air.getECO2()
data = str(TVOC)+","+str(AQI)+","+str(ECO2)
print(data)
time.sleep(0.1)
Serial port output:
196,2,689
196,2,695
196,2,689
160,2,642
160,2,641
160,2,644
...
...
After running the code, it is sent to the serial port. Now run the “edge-impulse data forwarder” command from the terminal. If you are running it for the first time, Edge Impulse will ask for credentials, board name and data names. The frequency of data will be automatically detected. In this example it was detected as 9Hz.
Navigate to the Data Acquisition page on Edge Impulse. After labeling the data, click the save button to record the data for 10 seconds. Repeat this step. The more data you use to train the model, the better.
Creating three different classes is sufficient. I will name them as suggested by Edge Impulse.
- smoke: true smoke
- meat: smoke from cooking meat (nuisance smoke)
- ambient: no smoke
Collect data for each class with 7-8 recordings of 10 seconds each.
Here are some examples of 3 classes from the data collected:
The next step is to create our model. Go to the Impulse design -> Create Impulse page. For each data read from the sensor, these are the TVOC and eCO2 required for the project. Since neural networks perform better in the 0 - 1 range, you can use blocks of raw data to normalize.
After normalizing the raw data, it feeds a two-layer neural network. It is important to achieve high accuracy with samples.
69.3% is not a very good accuracy rate, but it is sufficient. If the data collected were collected more carefully, much higher accuracy rates could be achieved.
Machine learning on Pico LTE is demonstrated to distinguish between three different classes: smoke, no smoke , and slightly smoky air conditions. The algorithm can be improved and improved with more accurate training data.
Comments
Please log in or sign up to comment.