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

ESP32-Based Voltage and Current Monitoring System with Wi-Fi Connectivity

View and Edit Project In Cirkit DesignerImage of ESP32-Based Voltage and Current Monitoring System with Wi-Fi Connectivity

Circuit Documentation

Summary

This circuit is designed to measure voltage and current using a voltage sensor and a current sensor, interfaced with an ESP32 microcontroller. The circuit also includes a power supply system that converts AC to DC using a power transformer and a bridge rectifier. The measured values are processed and displayed by the ESP32.

Component List

  1. Voltage Sensor DC 25V

    • Pins: +, -, output, gnd, vcc
    • Description: Measures DC voltage up to 25V.
    • Purpose: To measure the voltage in the circuit.
  2. Current Sensor 5A

    • Pins: 1, 2, GND, OUT, VCC
    • Description: Measures current up to 5A.
    • Purpose: To measure the current in the circuit.
  3. Bridge Rectifier

    • Pins: Source_in-, source_out-, source_out+, source_in+
    • Description: Converts AC to DC.
    • Purpose: To rectify the AC voltage from the transformer to DC.
  4. Power Transformer (220V to 24V)

    • Pins: 2 - Primary, 1 - Primary, 3 - Secondary, 4 - Secondary
    • Description: Steps down 220V AC to 24V AC.
    • Purpose: To step down the high voltage AC to a lower voltage suitable for rectification.
  5. ESP32

    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, VIN, 3V3, D15, D2, D4, RX2, TX2, D5, D18, D19, D21, RX0, TX0, D22, D23, BOOT
    • Description: A microcontroller with Wi-Fi and Bluetooth capabilities.
    • Purpose: To process and display the voltage and current measurements.
  6. Electrolytic Capacitor

    • Pins: -, +
    • Description: 0.00047 Farads
    • Purpose: To filter the rectified DC voltage.
  7. AC Supply

    • Pins: +ve, -ve
    • Description: Provides AC voltage.
    • Purpose: To supply AC voltage to the transformer.

Wiring Details

Voltage Sensor DC 25V

Current Sensor 5A

Bridge Rectifier

Power Transformer (220V to 24V)

ESP32

Electrolytic Capacitor

AC Supply

Code Documentation

ESP32 Code

/*
 * This Arduino Sketch is designed for an ESP32 microcontroller to read and 
 * display voltage and current measurements from a voltage sensor and a 
 * current sensor, respectively. The voltage sensor is connected to GPIO34 
 * (D34) and the current sensor is connected to GPIO32 (D32). The code 
 * initializes the sensors, reads the analog values, converts them to 
 * meaningful voltage and current values, and prints the results to the 
 * Serial Monitor.
 */

const int voltagePin = 34;  // Voltage sensor connected to GPIO34 (D34)
const int currentPin = 32;  // Current sensor connected to GPIO32 (D32)

// Constants for sensor calibration (you may need to adjust these)
const float voltageConversionFactor = 3.3 / 4095.0;  // ESP32 ADC conversion
const float currentConversionFactor = 3.3 / 4095.0;  // Same for current sensor

// ACS712 characteristics
const float zeroCurrentVoltage = 2.5;  // The voltage at 0A for ACS712
const float currentSensitivity = 0.185; // The sensitivity for ACS712

void setup() {
  Serial.begin(115200);
  pinMode(voltagePin, INPUT);  // Set voltage sensor pin as input
  pinMode(currentPin, INPUT);  // Set current sensor pin as input
}

void loop() {
  // Read the raw analog values from the voltage and current sensors
  int voltageRaw = analogRead(voltagePin);
  int currentRaw = analogRead(currentPin);

  // Convert the raw readings to voltage
  float voltage = voltageRaw * voltageConversionFactor;  // Voltage in Volts

  // Convert the raw current readings to current (for ACS712)
  float currentVoltage = currentRaw * currentConversionFactor;  // Current sensor voltage
  float current = (currentVoltage - zeroCurrentVoltage) / currentSensitivity;  // Current in Amperes

  // Output the results to the Serial Monitor
  Serial.print("Voltage: ");
  Serial.print(voltage, 2);  // Print voltage with 2 decimal places
  Serial.print(" V | ");

  Serial.print("Current: ");
  Serial.print(current, 2);  // Print current with 2 decimal places
  Serial.println(" A");

  delay(1000);  // Wait for 1 second before taking the next reading
}

AC Supply Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Documentation File

This documentation provides a comprehensive overview of the circuit, including the components used, their wiring details, and the code running on the microcontroller.