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

ESP32-Based Voltage Monitoring System with LCD Display

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

Circuit Documentation

Summary

This circuit integrates an ESP32 microcontroller with a voltage sensor, a 9V battery, and an LCD display module for voltage monitoring purposes. The ESP32 reads the analog voltage level from the voltage sensor and displays the voltage on the LCD. The LCD display is interfaced with the ESP32 via the I2C protocol. The circuit is powered by a 9V battery connected to the ESP32 and the voltage sensor.

Component List

ESP32 (30 pin)

Voltage Sensor DC

9V Battery

16X2 LCD

LCM1602 IIC

Wiring Details

ESP32 (30 pin)

Voltage Sensor DC

9V Battery

16X2 LCD

LCM1602 IIC

Documented Code

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

// Set the LCD I2C address, usually it's 0x27 or 0x3F
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Voltage sensor connected to GPIO 32 (Analog input)
const int voltageSensorPin = 32;

void setup() {
  // Initialize the LCD
  lcd.init();
  // Turn on the backlight
  lcd.backlight();
  
  // Initialize serial communication for debugging
  Serial.begin(115200);
}

void loop() {
  // Read the analog value from the voltage sensor
  int sensorValue = analogRead(voltageSensorPin);
  
  // Convert the analog reading (which goes from 0 - 4095) to a voltage (0 - 3.3V):
  float voltage = sensorValue * (3.3 / 4095.0);

  // Print the voltage to the Serial Monitor
  Serial.print("Voltage: ");
  Serial.print(voltage);
  Serial.println(" V");

  // Display the voltage on the LCD
  lcd.setCursor(0, 0); // Set the cursor to column 0, row 0
  lcd.print("Voltage: ");
  lcd.print(voltage);
  lcd.print(" V");

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

This code is designed to run on the ESP32 microcontroller. It initializes the LCD display and reads the voltage from the voltage sensor connected to pin D32. The voltage is then displayed on the LCD and printed to the Serial Monitor for debugging purposes. The analog-to-digital conversion assumes a reference voltage of 3.3V. The code includes a delay of 1 second between readings.