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

ESP32-Based Smart Energy Monitor with LCD Display and Telegram Integration

View and Edit Project In Cirkit DesignerImage of ESP32-Based Smart Energy Monitor with LCD Display and Telegram Integration

Circuit Documentation

Summary

The circuit in question is designed to monitor and display electrical parameters such as voltage, current, and power consumption. It also calculates the cost of energy consumed and can send this information to a Blynk application and a Telegram bot. The circuit utilizes an ESP32 microcontroller for processing and communication, an LCD screen for display, a ZMPT101B module for voltage sensing, an ACS712 current sensor for current measurement, and a couple of bulbs as a load. The ESP32 communicates with the LCD over I2C and reads sensor data from the ZMPT101B and ACS712 modules. The AC supply powers the bulbs and provides input to the sensors.

Component List

LCD Screen 16x2 I2C

ESP32 - Expansion Board

AC Supply

Bulb

ZMPT101B

ACS712 Current Sensor 5A 20A 30A

Wiring Details

LCD Screen 16x2 I2C

ESP32 - Expansion Board

AC Supply

Bulb

ZMPT101B

ACS712 Current Sensor 5A 20A 30A

Documented Code

The code for the ESP32 microcontroller is written in C++ and is designed to be compiled and uploaded using the Arduino IDE. The code includes several libraries for handling various functionalities such as energy monitoring, WiFi connectivity, Blynk communication, I2C communication, and LCD display control.

// Include necessary libraries
#include "EmonLib.h"
#include <EEPROM.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <HTTPClient.h>
#include <ArduinoJson.h>

// Initialize LCD with I2C address
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Define constants for calibration and credentials
const float vCalibration = 42.5;
const float currCalibration = 1.80;
const char auth[] = "BlynkAuthToken";
const char ssid[] = "YourSSID";
const char pass[] = "YourPassword";
const float ratePerkWh = 6.5;

// Create instances for energy monitoring and timers
EnergyMonitor emon;
BlynkTimer timer;

// Variables for energy calculation and EEPROM storage
float kWh = 0.0;
float cost = 0.0;
unsigned long lastMillis = millis();
const int addrKWh = 12;
const int addrCost = 16;
int displayPage = 0;
const int resetButtonPin = 4;

// Function prototypes
void sendEnergyDataToBlynk();
void readEnergyDataFromEEPROM();
void saveEnergyDataToEEPROM();
void updateLCD();
void changeDisplayPage();
void sendBillToTelegram();
void resetEEPROM();

// Setup function
void setup() {
  // Initialize serial, WiFi, Blynk, LCD, EEPROM, and pins
  // Read stored data from EEPROM
  // Setup voltage and current inputs
  // Setup timers
}

// Main loop function
void loop() {
  // Run Blynk and timers
  // Check if the reset button is pressed
}

// Function definitions for sending data to Blynk, reading/saving EEPROM data,
// updating the LCD, changing display pages, sending bills to Telegram, and resetting EEPROM

The code is structured with a setup function to initialize the system and a loop function that runs continuously. It includes functions to send data to Blynk, read and save data to EEPROM, update the LCD display, change the display pages, send bills to Telegram, and reset EEPROM data. The actual implementation of these functions is omitted for brevity but would include the logic for each operation as described in the function prototypes.