- Introduction
- Project Overview
- Hardware Requirements
- Pinout Map
- Software Requirements
- Setup Instructions
- How It Works
- Python (Qt) Interface Features
- Arduino Code
- Training the Model
- Real-Time Inference
- Adding New Smells
- Troubleshooting
- Future Enhancements
- License
- Folder Structure
The E-Nose Project is a system designed to detect and classify smells using an array of MQ gas sensors and a machine learning model. The system consists of:
- A microcontroller (MCU) to read sensor data.
- A Python (Qt) interface to record data, train a model, and perform real-time inference.
This project is ideal for applications such as:
- Environmental monitoring.
- Industrial safety.
- Food quality control.
- Home safety (e.g., gas leak detection).
The E-Nose system works as follows:
- Sensor Data Acquisition:
- The MCU reads data from the MQ sensors and sends it to the computer via serial communication.
- Data Recording and Filtering:
- The Python (Qt) interface records 150 data points per smell and filters them down to 25 points to minimize errors.
- Model Training:
- The recorded data is used to train an Artificial Neural Network (ANN) model.
- Real-Time Inference:
- The trained model is used to classify smells in real-time based on sensor data.
- Microcontroller (MCU):
- Any MCU with at least 1 analog pin (e.g., Arduino Nano, Arduino Mega, ESP32, STM32, etc.).
- If using more than 1 cluster, ensure the MCU has enough digital pins for multiplexer control.
- Sensors:
- MQ-2: LPG, propane, methane, hydrogen, smoke.
- MQ-3: Alcohol, ethanol, benzene.
- MQ-4: Methane, natural gas.
- MQ-6: LPG, butane, propane.
- MQ-135: Ammonia, benzene, alcohol, smoke, CO₂.
- MQ-136: Hydrogen sulfide (H₂S).
- MQ-138: Benzene, toluene, alcohol, acetone, propane, formaldehyde.
- MQ-9: Carbon monoxide (CO), flammable gases.
- Multiplexers (Optional):
- Use CD74HC4067 (16-channel analog multiplexer) if the MCU has limited analog pins.
- Connections:
- Connect each MQ sensor to the multiplexer (if used) or directly to the MCU’s analog pins.
- Power the sensors using the 5V and GND pins of the MCU.
Multiplexer | Control Pins (S0-S3) | Analog Pin | Sensors Connected |
---|---|---|---|
MUX 1 | D2, D3, D4, D5 | A0 | 1 × MQ-2, 1 × MQ-3, 1 × MQ-4, 1 × MQ-6, 1 × MQ-135, 1 × MQ-136, 1 × MQ-138, 1 × MQ-9 |
MUX 2 | D6, D7, D8, D9 | A1 | 1 × MQ-2, 1 × MQ-3, 1 × MQ-4, 1 × MQ-6, 1 × MQ-135, 1 × MQ-136, 1 × MQ-138, 1 × MQ-9 |
MUX 3 | D10, D11, D12, D13 | A2 | 1 × MQ-2, 1 × MQ-3, 1 × MQ-4, 1 × MQ-6, 1 × MQ-135, 1 × MQ-136, 1 × MQ-138, 1 × MQ-9 |
MUX 4 | D14, D15, D16, D17 | A3 | 1 × MQ-2, 1 × MQ-3, 1 × MQ-4, 1 × MQ-6, 1 × MQ-135, 1 × MQ-136, 1 × MQ-138, 1 × MQ-9 |
- Use the same structure, but adjust the pin numbers based on your MCU’s pinout.
- Arduino IDE:
- To upload the code to the MCU.
- Python 3.x:
- To run the Python (Qt) interface.
- Python Libraries:
- Install the required libraries using:
pip install pyserial numpy pandas scikit-learn PyQt5 matplotlib
- Install the required libraries using:
- Upload Arduino Code:
- Open the Arduino IDE.
- Copy and paste the provided Arduino code.
- Upload the code to the MCU.
- Run Python (Qt) Interface:
- Open the Python script on your computer.
- Run the script using:
python enose_gui.py
- Connect MCU to Computer:
- Connect the MCU to the computer via USB.
- Ensure the correct COM port is selected in the Python script.
- Sensor Data Acquisition:
- The MCU reads data from the MQ sensors and sends it to the computer.
- Data Recording:
- The Python interface records 150 data points for each smell.
- Data Filtering:
- The recorded data is filtered down to 25 points to minimize errors.
- Model Training:
- The filtered data is used to train an ANN model.
- Real-Time Inference:
- The trained model classifies smells in real-time based on sensor data.
- Add New Smell Library:
- Record and save data for new smells.
- Train Model:
- Train an ANN model using the recorded data.
- Import/Export Model:
- Save and load trained models.
- Real-Time Inference:
- Classify smells in real-time.
- Data Logging:
- Log sensor data and predictions.
- Real-Time Graph:
- Visualize sensor data in real-time.
The Arduino code reads data from the MQ sensors and sends it to the computer via serial communication. Refer to the provided Arduino code for details.
- Record Data:
- Use the "Add New Smell Library" feature to record data for each smell.
- Train Model:
- Click the "Train Model" button to train the ANN model.
- Evaluate Model:
- The model's accuracy is displayed after training.
- Start Logging:
- Click the "Start Logging" button to begin real-time inference.
- View Predictions:
- The predicted class is displayed in the GUI.
- Click "Add New Smell Library":
- Enter the name of the new smell.
- Record Data:
- The system will record 150 data points for the new smell.
- Save Data:
- Save the filtered data to a CSV file.
- No Data Received:
- Check the COM port and ensure the MCU is connected.
- Low Accuracy:
- Ensure sufficient data is recorded for each smell.
- Sensor Errors:
- Calibrate the sensors and check connections.
- Advanced Filtering:
- Implement more sophisticated filtering techniques.
- Data Visualization:
- Add real-time plotting of sensor data.
- Mobile App:
- Develop a mobile app for remote monitoring.
This project is licensed under the MIT License. Feel free to use, modify, and distribute it as needed.
The project is organized as follows:
- Readme.md
- enose_gui.py
- dummy_generator (folder)
- dummy_generator.ino
- sensors_data (folder)
- single (folder)
- single.ino
- cluster (folder)
- cluster.ino
Readme.md
: This file, containing the project documentation.enose_gui.py
: The Python (Qt) interface for data recording, model training, and real-time inference.dummy_generator
: Contains thedummy_generator.ino
file, which simulates sensor data for testing purposes.sensors_data
: Contains Arduino code for reading sensor data.single
: Containssingle.ino
, which reads data from multiple sensors (1 sensor per type) without multiplexer.cluster
: Containscluster.ino
, which reads data from multiple sensors using a multiplexer.