Detect harmful gases with Arduino and Machine Learning (Bhopal 84)

Industries working with chemicals are always subject to leaks that could harm workers and people nearby. Sometimes those leaks are formed by a specific combination of gases not suitable by off the shelf sensors. 

 

Can a machine learning model be trained to identify subtle relationships between all the gas readings?

 

This project uses DFRobot MiCS-4514 multi gas sensor. The sensor is able to detect the following gases:

 

Methane (CH4) (1000–25000) PPM

Ethanol (C2H5OH) (10-500) PPM

Hydrogen (H2) (1-1000) PPM

Ammonia (NH3) (1-500) PPM

Carbon Monoxide (CO) (1- 1000) PPM

Nitrogen Dioxide (NO2) (0.1-10) PPM

 

The device will read the multigas sensor x times for y seconds and then calculate min, max and average. Those values will be forwarded to the Machine Learning model for inference and then a score will be obtained. Example: “harmful” gas 95% “regular” gas 0%


Important: this project is 100% experimental. There are no guarantees of any kind. Being a health related project you should always use professionals advice before going to production.

 

Materials


Arduino BLE 33 Sense (you can use any other ARM based Arduino. No onboard sensors are used in this project)

MiCS-4514 gas sensor 

5V Cooler (a stronger cooler will perform better)

Oled screen 128x32

Buzzer

3d printed parts

DC female connector

5v Power Supply
 

projectImage

Connections

 

Circuit schema will work as a reference. In detail you need to connect Buzzer to D2 and GND. Oled Screen VCC to Arduino 3.3v, GND to Arduino GND, SDA to A4, SCL to A5. Gravity Gas Sensor to Arduino 3.3v, GND, SDA to A4, SCL to A5

 

Data acquisition

projectImage

For data acquisition script and details please visit this link

 

Model training

 

First check that you have all the data for training and testing uploaded with correct labels. Then go to Impulse Design, Create Impulse. What is an Impulse? An impulse takes raw data, uses signal processing to extract features, and then uses a learning block to classify new data.


 

In Times Series Data, we will use 1500ms Windows Size and 0,6 frecuency. Window increase is not important here, since samples are taken at exactly X seconds.


 

Processing block will be raw data with all axis checked. For classification we will use Keras with 2 output features: regular and harmful.


 

In Raw Data you can see all values for regular and harmful inside every windows size. Then you have to click Generate Features.


 

For NN Classifier we will use 60 training cycles, 0.0005 Learning Rate, Validation 20 and Autobalance dataset. It worked for me adding an extra layer Droput Rate 0.1 Click Start Training and check if you get good accuracy. In my case 86% good harmful detection and 96% regular gas detection. 


 

If you are ok with results you can go to Model Testing and check the performance with new data. If there are lots of readings with wrong classification you should check again data acquisition procedure. 

projectImage

Deployment


 

After a successful Model Testing, everything is ready for deployment. Go to Deployment. Select Arduino Library and save the zip file. Now go to Arduino IDE, Sketch, Include Library, Add Zip library and select the downloaded zip file.

 

Download and install the execution script bhopalX.ino 

 

Connect the Arduino to the computer with the USB cable and Upload the code. Please note that it will take long minutes to upload.

 

3d printed parts

 

Download 3d parts from this link. Print with PLA.

 

Settings


 

If you want to change calibration time in minutes, use

#define CALIBRATION_TIME 3 

 

If your OLED screen has a different I2C address

#define SCREEN_ADDRESS 0x3C 

 

If you want to use another pin for the Buzzer

# define pinBuzzer 2

 

If you want to use more readings for min, max and average

 

int measuresNumber=4;

 

If you want to change the measure timeframe

int measuresTimeFrame=1500; // 1.5 seconds

 

If you want to change the percentage to identify the gases

float scoreLimit=0.8;


 

projectImage

Using Bhopal 84


 

After displaying Bhopal and Edge Impulse logos, the unit will start the calibration phase. During this phase do not place any substance or gas under the sensor unit. It should read normal air conditions. As soon as this step is finished you can put the leaked substance under the sensor unit and it should be detected in 1.5 seconds. Why 1.5 seconds? 4 readings will be made to obtain mix, max and average for all gases. That information will be forwarded to the model and a classification will be returned. 

 

License
All Rights
Reserved
licensBg
0