#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// ACS712 5A Current Sensor
const int currentSensorPin = A0; // ACS712 output
// ZMPT101B Voltage Sensor
const int voltageSensorPin = A1;
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup() {
lcd.init();
lcd.backlight();
}
void loop() {
// --- CURRENT (ACS712 5A) ---
int adcCurrent = analogRead(currentSensorPin);
// Convert ADC to voltage
float voltageCurrent = (adcCurrent * 5.0) / 1023.0;
// ACS712 5A: sensitivity = 0.185 V/A
float current = (voltageCurrent - 2.5) / 0.185;
// --- VOLTAGE (ZMPT101B) ---
int adcVoltage = analogRead(voltageSensorPin);
float voltage = (adcVoltage / 1023.0) * 250.0;
// --- LCD DISPLAY ---
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Voltage: ");
lcd.print(voltage, 2);
lcd.print(" V");
lcd.setCursor(0, 1);
lcd.print("Current: ");
lcd.print(current, 2);
lcd.print(" A");
delay(1000);
}