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

ESP32-Based Environmental Monitoring System with I2C LCD Display

View and Edit Project In Cirkit DesignerImage of ESP32-Based Environmental Monitoring System with I2C LCD Display

Circuit Documentation

Summary

This circuit is designed to interface an ESP32 microcontroller with an I2C LCD screen, a DHT11 temperature and humidity sensor, a current sensor, and a power supply system that includes a 5V battery, a 220V power source, a Miniature Circuit Breaker (MCB), a power transformer (220V to 24V), a bridge rectifier, and an electrolytic capacitor. The ESP32 reads data from the DHT11 sensor and the current sensor and displays information on the I2C LCD screen. The power supply system converts 220V AC to a regulated 5V DC supply for the ESP32 and other components.

Component List

ESP32 (30 pin)

I2C LCD 16x2 Screen

5V Battery

MCB (Miniature Circuit Breaker)

Current Sensor

DHT11

Power 220V

Bridge Rectifier

Power Transformer (220V to 24V)

Electrolytic Capacitor

Wiring Details

ESP32 (30 pin)

I2C LCD 16x2 Screen

5V Battery

MCB

Current Sensor

DHT11

Power Transformer (220V to 24V)

Bridge Rectifier

Electrolytic Capacitor

Documented Code

/*
 * ESP32 Interface with I2C LCD and IR Sensor
 * This code reads the status of an IR sensor and displays it on an I2C LCD.
 */

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

// Define the I2C address for the LCD
#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2

// Initialize the LCD
LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);

// Define the IR sensor pin
const int irSensorPin = 2;

void setup() {
  // Initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("IR Sensor Status:");

  // Initialize the IR sensor pin
  pinMode(irSensorPin, INPUT);
}

void loop() {
  // Read the IR sensor value
  int irValue = digitalRead(irSensorPin);

  // Display the IR sensor status on the LCD
  lcd.setCursor(0, 1);
  if (irValue == HIGH) {
    lcd.print("Object Detected ");
  } else {
    lcd.print("No Object       ");
  }

  // Small delay to avoid flickering
  delay(200);
}

Note: The code provided is for interfacing an IR sensor with the ESP32 and displaying its status on an I2C LCD. However, the IR sensor is not listed in the components provided. The pin irSensorPin is defined as 2, which does not correspond to any pin labels on the ESP32 provided in the parts list. This discrepancy should be addressed for proper functionality of the circuit.