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

Arduino UNO Based Gas Level Detector with SMS Alerts Using SIM900A

View and Edit Project In Cirkit DesignerImage 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

SIM900A

MQ6

Wiring Details

Arduino UNO

SIM900A

MQ6

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.