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

Arduino UNO Based Environmental Monitoring System with OLED and LCD Displays

Image of Arduino UNO Based Environmental Monitoring System with OLED and LCD Displays

Circuit Documentation

Summary

This circuit integrates various sensors and displays with an Arduino UNO microcontroller to measure environmental parameters such as temperature, humidity, soil moisture, and raindrop detection. The data collected from the sensors is displayed on an OLED display and an LCD I2C display. The Arduino UNO serves as the central processing unit, interfacing with the DHT11 temperature and humidity sensor, a rain sensor, a soil moisture sensor, and two displays (OLED and LCD) via I2C and digital/analog connections.

Component List

Arduino UNO

  • Microcontroller board based on the ATmega328P
  • It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.

128x64 OLED Display (I2C IIC SPI Serial)

  • A small display screen that uses OLED technology for high contrast and visibility.
  • It communicates with the Arduino via the I2C protocol.

LCD I2C Display

  • A 16x2 character LCD display with an I2C interface for easy communication with the Arduino.

DHT11

  • A basic, ultra low-cost digital temperature and humidity sensor.
  • It uses a capacitive humidity sensor and a thermistor to measure the surrounding air and outputs a digital signal on the data pin.

RAIN SENSOR

  • A weather sensing device capable of detecting raindrop presence.
  • It provides both analog and digital outputs.

SparkFun Soil Moisture Sensor

  • A simple breakout for measuring the moisture in soil and similar materials.
  • It outputs an analog signal that can be read by the Arduino's analog input pins.

Wiring Details

Arduino UNO

  • 5V: Connected to VCC of all other components for power supply.
  • GND: Connected to GND of all other components to complete the circuit.
  • A0: Connected to the AO pin of the RAIN SENSOR for analog raindrop detection.
  • A1: Connected to the SIG pin of the SparkFun Soil Moisture Sensor for analog soil moisture detection.
  • A4 (SDA): Connected to the SDA pin of the LCD I2C Display and 128x64 OLED Display for I2C data communication.
  • A5 (SCL): Connected to the SCL pin of the LCD I2C Display and 128x64 OLED Display for I2C clock communication.
  • D2: Connected to the DATA pin of the DHT11 for digital temperature and humidity readings.

128x64 OLED Display (I2C IIC SPI Serial)

  • GND: Connected to the common ground.
  • SDA: Connected to the SDA (A4) pin of the Arduino UNO.
  • SCL: Connected to the SCL (A5) pin of the Arduino UNO.
  • VCC: Connected to the 5V output of the Arduino UNO.

LCD I2C Display

  • GND: Connected to the common ground.
  • VCC: Connected to the 5V output of the Arduino UNO.
  • SDA: Connected to the SDA (A4) pin of the Arduino UNO.
  • SCL: Connected to the SCL (A5) pin of the Arduino UNO.

DHT11

  • DATA: Connected to the D2 pin of the Arduino UNO.
  • GND: Connected to the common ground.
  • VCC: Connected to the 5V output of the Arduino UNO.

RAIN SENSOR

  • AO: Connected to the A0 pin of the Arduino UNO.
  • DO: Not connected in this configuration.
  • GRD: Connected to the common ground.
  • VCC: Connected to the 5V output of the Arduino UNO.

SparkFun Soil Moisture Sensor

  • SIG: Connected to the A1 pin of the Arduino UNO.
  • GND: Connected to the common ground.
  • VCC: Connected to the 5V output of the Arduino UNO.

Documented Code

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <DHT.h>
#include <LiquidCrystal_I2C.h>

// OLED display settings
#define OLED_RESET -1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

// DHT11 sensor settings
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

// LCD I2C display settings
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD I2C address

// Soil Moisture Sensor settings
#define SOIL_MOISTURE_PIN A1 // Analog pin connected to the soil moisture sensor

// Raindrop sensor settings
#define RAINDROP_SENSOR_PIN A0 // Analog pin connected to the raindrop sensor

void setup() {
  // Initialize OLED display
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Initialize with the I2C addr 0x3C
  display.display();
  delay(2000);
  display.clearDisplay();

  // Initialize DHT sensor
  dht.begin();

  // Initialize LCD display
  lcd.init();
  lcd.backlight();

  // Set up the analog pins for soil moisture and raindrop sensors
  pinMode(SOIL_MOISTURE_PIN, INPUT);
  pinMode(RAINDROP_SENSOR_PIN, INPUT);
}

void loop() {
  // Read temperature and humidity from DHT11
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Read soil moisture level
  int soilMoistureValue = analogRead(SOIL_MOISTURE_PIN);

  // Read raindrop sensor value
  int raindropValue = analogRead(RAINDROP_SENSOR_PIN);

  // Display temperature and humidity on OLED
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Temp: ");
  display.print(temperature);
  display.print(" C");
  display.setCursor(0,10);
  display.print("Humidity: ");
  display.print(humidity);
  display.print(" %");
  display.setCursor(0,20);
  display.print("Soil Moisture: ");
  display.print(soilMoistureValue);
  display.display();

  // Display raindrop sensor information on LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Raindrop:");
  lcd.setCursor(0, 1);
  lcd.print(raindropValue);

  // Wait a bit before reading again
  delay(2000);
}

This code initializes and reads data from the DHT11 sensor, soil moisture sensor, and raindrop sensor, displaying the results on the OLED and LCD displays. The OLED display shows temperature, humidity, and soil moisture levels, while the LCD display shows the raindrop sensor value. The code includes initialization of the displays and sensors, as well as the main loop where sensor readings are taken and displayed.