Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Based Gas Level Detector with SMS Alerts Using SIM900A

Image of Arduino UNO Based Gas Level Detector with SMS Alerts Using SIM900A

Circuit Documentation

Summary of the Circuit

This circuit is designed to detect gas levels using an MQ6 sensor and provide alerts via SMS using a SIM900A GSM module when the gas level exceeds a predefined threshold. The core of the circuit is an Arduino UNO microcontroller, which reads the analog output from the MQ6 sensor and controls the SIM900A module to send SMS messages. The circuit operates on a 5V supply, which is provided by the Arduino UNO to both the MQ6 sensor and the SIM900A module.

Component List

Arduino UNO

  • Description: A microcontroller board based on the ATmega328P.
  • Purpose: Acts as the central processing unit for the circuit, reading sensor data and controlling the GSM module.

SIM900A

  • Description: A complete Quad-band GSM/GPRS module that can provide SMS and voice communication.
  • Purpose: Used to send SMS alerts when the gas level exceeds the threshold.

MQ6

  • Description: A gas sensor designed for detecting LPG, butane, propane, methane, alcohol, hydrogen, and smoke.
  • Purpose: Monitors the gas levels in the environment and provides an analog output proportional to the detected gas concentration.

Wiring Details

Arduino UNO

  • 5V: Provides power to the MQ6 sensor and SIM900A module.
  • GND: Common ground for the circuit.
  • A1: Receives the analog output from the MQ6 gas sensor.
  • D8: Connected to the RXD pin of the SIM900A module for serial communication.
  • D7: Connected to the TXD pin of the SIM900A module for serial communication.

SIM900A

  • GND: Connected to the common ground of the circuit.
  • DB9-3 (RXD): Receives data from the Arduino UNO's D8 pin.
  • DB9-2 (TXD): Transmits data to the Arduino UNO's D7 pin.

MQ6

  • VCC: Powered by the 5V output from the Arduino UNO.
  • GND: Connected to the common ground of the circuit.
  • A0: Analog output connected to the A1 pin of the Arduino UNO.

Documented Code

/*
 * Gas Detector with SMS Alert
 * This Arduino sketch reads gas levels from an MQ6 sensor and sends an SMS alert
 * using the SIM900A module if the gas level exceeds a predefined threshold.
 */

#include <SoftwareSerial.h>

// Pin definitions
const int gasSensorPin = A1; // MQ6 sensor analog output connected to A1
const int sim900RxPin = 8;  // SIM900A RX pin connected to D8
const int sim900TxPin = 7;  // SIM900A TX pin connected to D7

// Threshold for gas level
const int gasThreshold = 300;

// Create a SoftwareSerial object for SIM900A communication
SoftwareSerial sim900(sim900RxPin, sim900TxPin);

void setup() {
  // Initialize serial communication for debugging
  Serial.begin(9600);
  // Initialize SIM900A serial communication
  sim900.begin(9600);
  // Wait for SIM900A to initialize
  delay(1000);
  // Send initialization commands to SIM900A
  sim900.println("AT");
  delay(1000);
  sim900.println("AT+CMGF=1"); // Set SMS to text mode
  delay(1000);
}

void loop() {
  // Read gas level from MQ6 sensor
  int gasLevel = analogRead(gasSensorPin);
  // Print gas level to serial monitor
  Serial.print("Gas Level: ");
  Serial.println(gasLevel);
  // Check if gas level exceeds threshold
  if (gasLevel > gasThreshold) {
    // Send SMS alert
    sendSMSAlert(gasLevel);
  }
  // Wait for a second before next reading
  delay(1000);
}

void sendSMSAlert(int gasLevel) {
  // Send SMS command
  sim900.print("AT+CMGS=\"");
  sim900.print("+1234567890"); // Replace with your phone number
  sim900.println("\"");
  delay(1000);
  // Send SMS message
  sim900.print("Gas level exceeded! Current level: ");
  sim900.print(gasLevel);
  sim900.println();
  // End SMS with Ctrl+Z
  sim900.write(26);
  delay(1000);
}

Note: The phone number in the sendSMSAlert function should be replaced with the actual number where the SMS alert is intended to be sent.