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 involves an Arduino UNO microcontroller interfacing with various sensors and an SD card module. The sensors include the MICS2714 and MQ-7 Breakout for gas detection, and the SD SDHC module 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 capable of detecting 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 capable of detecting CO.
- Pins: VCC, GND, DO, AO
Wiring Details
Arduino UNO
- 5V: Connected to MICS2714 (5V), MQ-7 Breakout (VCC)
- A0: Connected to MICS2714 (A0), MQ-7 Breakout (AO)
- GND: Connected to MICS2714 (GND), MQ-7 Breakout (GND), SD SDHC (GND)
- D10: Connected to MICS2714 (/EN)
- 3.3V: Connected to SD SDHC (3V3)
- D4: Connected to SD SDHC (CS)
- D11: Connected to SD SDHC (MOSI)
- D13: Connected to SD SDHC (CLK)
- D12: Connected to SD SDHC (MISO)
- D8: Connected to MQ-7 Breakout (DO)
MICS2714
- 5V: Connected to Arduino UNO (5V)
- GND: Connected to Arduino UNO (GND)
- A0: Connected to Arduino UNO (A0)
- /EN: Connected to Arduino UNO (D10)
SD SDHC
- 3V3: Connected to Arduino UNO (3.3V)
- CS: Connected to Arduino UNO (D4)
- MOSI: Connected to Arduino UNO (D11)
- CLK: Connected to Arduino UNO (D13)
- MISO: Connected to Arduino UNO (D12)
- GND: Connected to Arduino UNO (GND)
MQ-7 Breakout
- VCC: Connected to Arduino UNO (5V)
- GND: Connected to Arduino UNO (GND)
- DO: Connected to Arduino UNO (D8)
- AO: Connected to Arduino UNO (A0)
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 Deivces !");
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.