Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Gas Detection System with MICS2714 and MQ-7 Sensors and SD Card Logging

View and Edit Project In Cirkit DesignerImage of Arduino UNO Gas Detection System with MICS2714 and MQ-7 Sensors and SD Card Logging

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

MICS2714

SD SDHC

MQ-7 Breakout

Wiring Details

Arduino UNO

MICS2714

SD SDHC

MQ-7 Breakout

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.