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

Arduino UNO-Based Smart Weather Station with Soil Moisture and Rain Detection

Image of Arduino UNO-Based Smart Weather Station with Soil Moisture and Rain Detection

Circuit Documentation

Summary

This circuit is designed to monitor environmental conditions using various sensors and control a servo motor based on the detected conditions. The circuit includes an Arduino UNO microcontroller, a DHT11 temperature and humidity sensor, a SparkFun Soil Moisture Sensor, a rain sensor, and a servo motor. The Arduino UNO reads data from the sensors and controls the servo motor based on the sensor readings.

Component List

  1. Arduino UNO

    • Description: A 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. SparkFun Soil Moisture Sensor

    • Description: A sensor used to measure the moisture level in the soil.
    • Pins: VCC, GND, SIG
  3. DHT11

    • Description: A sensor used to measure temperature and humidity.
    • Pins: DATA, GND, VCC
  4. RAIN SENSOR

    • Description: A sensor used to detect the presence of rain.
    • Pins: AO, DO, GRD, VCC
  5. Servo

    • Description: A motor used for precise control of angular position.
    • Pins: gnd, vcc, pulse

Wiring Details

Arduino UNO

  • GND: Connected to GND of DHT11, Servo, RAIN SENSOR, and SparkFun Soil Moisture Sensor.
  • 5V: Connected to VCC of DHT11, Servo, RAIN SENSOR, and SparkFun Soil Moisture Sensor.
  • A0: Connected to AO of RAIN SENSOR.
  • A1: Connected to SIG of SparkFun Soil Moisture Sensor.
  • D5: Connected to pulse of Servo.
  • D4: Connected to DATA of DHT11.

SparkFun Soil Moisture Sensor

  • VCC: Connected to 5V of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • SIG: Connected to A1 of Arduino UNO.

DHT11

  • DATA: Connected to D4 of Arduino UNO.
  • GND: Connected to GND of Arduino UNO.
  • VCC: Connected to 5V of Arduino UNO.

RAIN SENSOR

  • AO: Connected to A0 of Arduino UNO.
  • DO: Not connected.
  • GRD: Connected to GND of Arduino UNO.
  • VCC: Connected to 5V of Arduino UNO.

Servo

  • gnd: Connected to GND of Arduino UNO.
  • vcc: Connected to 5V of Arduino UNO.
  • pulse: Connected to D5 of Arduino UNO.

Documented Code

// Including all Libraries
#include <Adafruit_Sensor.h>
#include <Servo.h>
#include <dht.h>

// Defining pins as variables
#define rsp A0
#define sp 5
#define smp A1
#define DHT11PIN 4

Servo servo;
dht DHT;

// Defining variables for later
int rainState;
int moi;
float hum;
float temp;

void setup() {
    // Beginning the serial monitor
    Serial.begin(9600);

    // making pins inputs
    pinMode(rsp, INPUT);

    // servo init settings
    servo.attach(sp);
    servo.write(0);

    // defining rain state as the rain sensor value
    rainState = digitalRead(rsp);
}

void loop() {
    int chk = DHT.read11(DHT11PIN);

    // Defining the previous variables
    moi = analogRead(smp);
    hum = DHT.humidity;
    temp = DHT.temperature;

    // If-else statement for Rain Sensor - Servo Arrangement
    if (rainState <= 600) {
        servo.write(90);
        Serial.println("RAIN!!!");
    } else {
        servo.write(0);
        Serial.println("NO RAIN!!");
    }

    Serial.print(temp);
    Serial.print("x");
    Serial.println(hum);
    delay(2000);
}

This code initializes the sensors and servo motor, reads data from the sensors, and controls the servo motor based on the rain sensor's readings. The temperature and humidity data are also printed to the serial monitor.