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

Arduino UNO-Based Smart Weather Station with GSM and I2C LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Smart Weather Station with GSM and I2C LCD Display

Circuit Documentation

Summary

This document provides a detailed overview of a circuit that integrates various sensors, an LCD display, a servo motor, a GSM module, and an ESP32-CAM module, all controlled by an Arduino UNO. The circuit is designed to monitor environmental conditions such as temperature, humidity, motion, sound, and rain, and to display the data on an LCD screen. Additionally, it can send SMS alerts using the GSM module and control a servo motor.

Component List

  1. Arduino UNO

    • Description: 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
  2. 16x2 I2C LCD

    • Description: 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  3. RAIN SENSOR

    • Description: Sensor to detect rain.
    • Pins: AO, DO, GRD, VCC
  4. SIM 800L

    • Description: GSM module for sending SMS.
    • Pins: NFT, RING, VCC, DTR, RST, MIC +, RXD, MIC-, TXD, SPK+, GND, SPK-
  5. DHT11 Humidity and Temperature Sensor

    • Description: Sensor to measure temperature and humidity.
    • Pins: VDD, DATA, NULL, GND
  6. Servo

    • Description: Servo motor for mechanical movement.
    • Pins: GND, VCC, PWM
  7. Buzzer

    • Description: Simple buzzer for sound output.
    • Pins: PIN, GND
  8. KY 038

    • Description: Sound sensor module.
    • Pins: +, G, A0, D0
  9. PIR/Motion Sensor

    • Description: Sensor to detect motion.
    • Pins: GND, OUTPUT, VCC
  10. ESP32-CAM

    • Description: Camera module with ESP32.
    • Pins: 5V, GND, IO12, IO13, IO15, IO14, IO2, IO4, VOT, VOR, VCC, IO0, IO16, 3V3

Wiring Details

Arduino UNO

16x2 I2C LCD

RAIN SENSOR

SIM 800L

DHT11 Humidity and Temperature Sensor

Servo

Buzzer

KY 038

PIR/Motion Sensor

ESP32-CAM

Documented Code

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

// Pin Definitions
#define PIR_PIN 7
#define SOUND_SENSOR_PIN 6
#define RAIN_SENSOR_PIN A0
#define DHT_PIN 5
#define GSM_RX 10
#define GSM_TX 11
#define LCD_ADDRESS 0x27
#define SERVO_PIN 9

// Setup for DHT11 sensor
DHT dht(DHT_PIN, DHT11);

// Setup for LCD display
LiquidCrystal_I2C lcd(LCD_ADDRESS, 16, 2);

// Setup for Servo motor
Servo myServo;

// Setup for GSM module
SoftwareSerial gsmSerial(GSM_RX, GSM_TX);

// Setup for other components
int pirState = 0; 
int soundThreshold = 500;  // Threshold for sound sensor
int rainThreshold = 500;   // Adjust depending on your rain sensor readings

void setup() {
  // Initialize Serial Monitor
  Serial.begin(9600);
  
  // Setup DHT sensor
  dht.begin();
  
  // Setup LCD
  lcd.begin(16, 2);
  lcd.print("System Initializing...");
  
  // Setup PIR Sensor
  pinMode(PIR_PIN, INPUT);
  
  // Setup sound sensor
  pinMode(SOUND_SENSOR_PIN, INPUT);
  
  // Setup GSM Module
  gsmSerial.begin(9600);
  
  // Setup Servo motor
  myServo.attach(SERVO_PIN);
  
  // Setup Rain Sensor
  pinMode(RAIN_SENSOR_PIN, INPUT);
  
  delay(2000);  // Wait for sensor setup
}

void loop() {
  // Read PIR sensor
  pirState = digitalRead(PIR_PIN);
  if (pirState == HIGH) {
    lcd.clear();
    lcd.print("Motion Detected!");
    delay(1000);
  }

  // Read Sound Sensor (KY-038)
  int soundValue = analogRead(SOUND_SENSOR_PIN);
  if (soundValue > soundThreshold) {
    lcd.clear();
    lcd.print("Sound Detected!");
    delay(1000);
  }
  
  // Read Rain Sensor
  int rainValue = analogRead(RAIN_SENSOR_PIN);
  if (rainValue > rainThreshold) {
    lcd.clear();
    lcd.print("Rain Detected!");
    sendSMS("Rain Detected!");
    delay(1000);
  }

  // Read DHT11 sensor for temperature and humidity
  float temperature = dht.readTemperature();
  float humidity = dht.readHumidity();
  
  if (isnan(temperature) || isnan(humidity)) {
    lcd.clear();
    lcd.print("Failed to read DHT!");
  } else {
    lcd.clear();
    lcd.print("Temp: ");
    lcd.print(temperature);
    lcd.print("C");
    lcd.setCursor(0, 1);
    lcd.print("Humidity: ");
    lcd.print(humidity);
    lcd.print("%");
    delay(2000);
  }

  // Control Servo motor (e.g., swing the cradle)