Arduino UNO Gas Detection System with MICS2714 and MQ-7 Sensors and SD Card Logging
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to interface various sensors and an SD card module with an Arduino UNO microcontroller. The sensors include the MICS2714, MQ-7 Breakout, and MQ-2, which are used for gas detection. The SD card module is used for data storage. The Arduino UNO reads data from the sensors and can store the data on the SD card.
Component List
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
MICS2714
- Description: A gas sensor used to detect NO2.
- Pins: 5V, GND, A0, /EN
SD SDHC
- Description: An SD card module for data storage.
- Pins: 3V3, CS, MOSI, CLK, MISO, GND
MQ-7 Breakout
- Description: A gas sensor used to detect CO.
- Pins: VCC, GND, DO, AO
MQ-2
- Description: A gas sensor used to detect various gases.
- Pins: GND, VCC, ANALOG, Digital
Wiring Details
Arduino UNO
- 5V: Connected to 5V of MICS2714 and VCC of MQ-7 Breakout
- GND: Connected to GND of MICS2714, SD SDHC, and MQ-7 Breakout
- A0: Connected to A0 of MICS2714 and AO of MQ-7 Breakout
- D10: Connected to /EN of MICS2714
- 3.3V: Connected to 3V3 of SD SDHC
- D4: Connected to CS of SD SDHC
- D11: Connected to MOSI of SD SDHC
- D13: Connected to CLK of SD SDHC
- D12: Connected to MISO of SD SDHC
- D8: Connected to DO of MQ-7 Breakout
MICS2714
- 5V: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- A0: Connected to A0 of Arduino UNO
- /EN: Connected to D10 of Arduino UNO
SD SDHC
- 3V3: Connected to 3.3V of Arduino UNO
- CS: Connected to D4 of Arduino UNO
- MOSI: Connected to D11 of Arduino UNO
- CLK: Connected to D13 of Arduino UNO
- MISO: Connected to D12 of Arduino UNO
- GND: Connected to GND of Arduino UNO
MQ-7 Breakout
- VCC: Connected to 5V of Arduino UNO
- GND: Connected to GND of Arduino UNO
- DO: Connected to D8 of Arduino UNO
- AO: Connected to A0 of Arduino UNO
MQ-2
- GND: Not connected in the provided net list
- VCC: Not connected in the provided net list
- ANALOG: Not connected in the provided net list
- Digital: Not connected in the provided net list
Code Documentation
Arduino UNO Code
#include "DFRobot_MICS.h"
#define CALIBRATION_TIME 3 // Default calibration time is three minutes
// When using the Breakout version, use the following program to construct an object from DFRobot_MICS_ADC
/**!
adcPin is A0~A5
powerPin is General IO
*/
#define ADC_PIN A0
#define POWER_PIN 10
DFRobot_MICS_ADC mics(/*adcPin*/ADC_PIN, /*powerPin*/POWER_PIN);
void setup()
{
Serial.begin(115200);
while(!Serial);
while(!mics.begin()){
Serial.println("NO Devices !");
delay(1000);
}
Serial.println("Device connected successfully !");
/**!
Gets the power mode of the sensor
The sensor is in sleep mode when power is on,so it needs to wake up the sensor.
The data obtained in sleep mode is wrong
*/
uint8_t mode = mics.getPowerState();
if(mode == SLEEP_MODE){
mics.wakeUpMode();
Serial.println("wake up sensor success!");
}else{
Serial.println("The sensor is wake up mode");
}
/**!
Do not touch the sensor probe when preheating the sensor.
Place the sensor in clean air.
The default calibration time is 3 minutes.
*/
while(!mics.warmUpTime(CALIBRATION_TIME)){
Serial.println("Please wait until the warm-up time is over!");
delay(1000);
}
}
void loop()
{
/**!
Gas type:
MICS-4514 You can get all gas concentration
MICS-5524 You can get the concentration of CH4, C2H5OH, H2, NH3, CO
MICS-2714 You can get the concentration of NO2
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
*/
float gasdata = mics.getGasData(NO2);
Serial.print(gasdata,1);
Serial.println(" PPM");
delay(1000);
//mics.sleepMode();
}
#include "MQ7.h"
#define A_PIN 2
#define VOLTAGE 5
// init MQ7 device
MQ7 mq7(A_PIN, VOLTAGE);
void setup() {
Serial.begin(9600);
while (!Serial) {
; // wait for serial connection
}
Serial.println(""); // blank new line
Serial.println("Calibrating MQ7");
mq7.calibrate(); // calculates R0
Serial.println("Calibration done!");
}
void loop() {
Serial.print("PPM = ");
Serial.println(mq7.readPpm());
Serial.println(""); // blank new line
delay(1000);
}
This code initializes and reads data from the MICS2714 and MQ-7 gas sensors, and prints the gas concentration values to the serial monitor. The MICS2714 is used to detect NO2, while the MQ-7 is used to detect CO. The code also includes calibration routines for the sensors.