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

Arduino UNO Based Environmental Monitoring System with SMS Alerts

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Environmental Monitoring System with SMS Alerts

Circuit Documentation

Summary

The circuit is designed to monitor environmental parameters such as temperature, humidity, smoke levels, and detect obstructions using an IR sensor. It includes a microcontroller (Arduino UNO) that interfaces with a DHT11 temperature and humidity sensor, an MQ6 gas sensor, an IR sensor, and an LCD I2C display for output. The system can control a DC motor via an L298N motor driver and has the capability to send SMS alerts using a SIM800L GSM module. Power is supplied by 9V batteries, regulated by a buck converter, and supplemented by a solar panel with a charge controller. The Arduino UNO also manages the motor's operation based on temperature readings and sends alerts when predefined thresholds are exceeded.

Component List

Wiring Details

9V Battery

Sim800l

MKE-S14 DHT11 Temperature And Humidity Sensor

MQ6

IR Sensor

LCD I2C Display

L298N DC Motor Driver

DC Motor

Buck Converter

Arduino UNO

Solar Panel

Charge Controller

Documented Code

#include <DHT.h>
#include <SoftwareSerial.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Pin Definitions
#define DHTPIN 4             // DHT11 Data pin connected to Arduino pin 4
#define DHTTYPE DHT11        // Define the type of DHT sensor
#define SIM800_RX 3          // SIM800L RX pin connected to pin 3
#define SIM800_TX 2          // SIM800L TX pin connected to pin 2
#define MQ2_PIN A0           // MQ2 Smoke Sensor analog pin connected to A0
#define IR_SENSOR_PIN 7      // IR Sensor digital pin connected to pin 7
#define LED_PIN 13           // LED pin connected to pin 13

// L298N Motor Driver Pin Definitions
#define ENA 9                // Enable pin for motor A (connected to a PWM pin on Arduino)
#define IN1 10               // Control pin 1 for motor A
#define IN2 11               // Control pin 2 for motor A

// Constants
#define PREDETERMINED_TEMP 28  // Predetermined temperature value in °C
#define SMOKE_THRESHOLD 20     // Predefined smoke level threshold

#define PHONE_NUMBER_1 "+447909488634" // First phone number
#define PHONE_NUMBER_2 "+447909488634" // Second phone number (changed for clarity)

// Create instances
SoftwareSerial mySerial(SIM800_RX, SIM800_TX);
DHT dht(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd(0x21, 16, 2); // Initialize the LCD with I2C address 0x27 and size 16x2

// Flags to track if messages have been sent for temperature, smoke, and obstruction
bool messageSentTemp1 = false;
bool messageSentTemp2 = false;
bool messageSentSmoke1 = false;
bool messageSentSmoke2 = false;
bool messageSentObstruction = false;

// Motor state
bool motorRunning = false;

// Variables for LED blinking detection
unsigned long lastBlinkCheck = 0;
const unsigned long blinkInterval = 3000; // 3 seconds
bool connectionEstablished = false;

void setup() {
  Serial.begin(9600); // Start the Serial Monitor
  mySerial.begin(9600); // Start Software Serial for SIM800L

  dht.begin(); // Initialize DHT sensor
  pinMode(IR_SENSOR_PIN, INPUT); // Set IR sensor pin as input
  pinMode(LED_PIN, OUTPUT); // Set LED pin as output

  // Initialize L298N Motor Driver pins
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);

  // Initialize I2C LCD
  lcd.init();
  lcd.backlight();
  lcd.print("UP2165711...");

  Serial.println("Initializing...");
  delay(1000);

  // Initialize the SIM800L module
  sendATCommand("AT"); // Test communication
  sendATCommand("AT+CMGF=1"); // Set SMS mode to text
  sendATCommand("AT+CSMP=17,167,0,0"); // Set SMS text mode
}

void loop() {
  unsigned long currentMillis = millis();

  // Check SIM800L network registration status
  checkNetworkStatus();

  // Check if 3 seconds have passed to update connection status
  if (currentMillis - lastBlinkCheck >= blinkInterval) {
    if (connectionEstablished) {
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Connection");
      lcd.setCursor(0, 1);
      lcd.print("Established");
    }
    lastBlinkCheck = currentMillis