#include < Wire.h >
#include < Adafruit_GFX.h >
#include < Adafruit_SSD1306.h >
// OLED display setup (change the screen address if needed)
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET - 1 // Reset pin # (or -1 if unused)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, & Wire, OLED_RESET);
// Pin definitions
const int voltagePin = A0; // ZMPT101B module output
const int currentPin = A1; // ACS712 module output
// Voltage and current sensor calibration
float voltageCalibration = 5.0 / 1024.0; // Analog voltage calibration (5V/1024)
float currentCalibration = 0.185; // ACS712 output voltage to current (185mV per amp)
// Constants for calculation
const float rmsVoltage = 230.0; // AC RMS voltage (adjust according to your region)
const float powerFactor = 0.9; // Assuming a typical power factor