Circuit Documentation
Summary
This circuit is designed to interface an ESP32 microcontroller with a PZEM004T power monitoring module, a current sensor, and multiple LED bulbs through a 4-channel 5V relay module. The ESP32 is responsible for controlling the relay channels and communicating with the PZEM004T module to monitor power usage. The current sensor is used to measure the current flowing through the circuit, and the relay module switches the LED bulbs on and off. The circuit is powered through a socket connection, and the ground connections are shared among the ESP32, PZEM004T, and relay module.
Component List
ESP32 (30 pin)
- A microcontroller with WiFi and Bluetooth capabilities, featuring a variety of digital and analog I/O pins.
PZEM004T
- A power monitoring module capable of measuring voltage, current, power, and energy usage.
Relay 4 Channel 5v
- A 4-channel relay module that allows the ESP32 to control higher power devices such as LED bulbs.
LED bulb AC / Bombillo AC
- Standard AC-powered LED bulbs that are controlled by the relay module.
Current Sensor
- A sensor used to measure the electric current in the circuit.
Socket
- The power source for the circuit, providing the necessary AC voltage.
Wiring Details
ESP32 (30 pin)
D12connected to Relay 4 Channel 5vIN2D13connected to Relay 4 Channel 5vIN1GNDconnected to PZEM004TGNDand Relay 4 Channel 5vGNDVinconnected to PZEM004TVCCand Relay 4 Channel 5vVCCD18connected to Relay 4 Channel 5vIN3TX2connected to PZEM004TRXRX2connected to PZEM004TTX
PZEM004T
GNDconnected to ESP32GNDand Relay 4 Channel 5vGNDVCCconnected to ESP32Vinand Relay 4 Channel 5vVCCRXconnected to ESP32TX2TXconnected to ESP32RX2INconnected to LED bulbs-and SocketneutralOUTconnected to Current SensorIn_currentandBurden
Relay 4 Channel 5v
GNDconnected to ESP32GNDand PZEM004TGNDIN1connected to ESP32D13IN2connected to ESP32D12IN3connected to ESP32D18VCCconnected to ESP32Vinand PZEM004TVCCCOM1,COM2,COM3connected to Current SensorOut_currentNO1connected to LED bulb+(Instance 1)NO2connected to LED bulb+(Instance 2)NO3connected to LED bulb+(Instance 3)
LED bulb AC / Bombillo AC
-connected to PZEM004TINand Socketneutral+connected to Relay 4 Channel 5vNO1,NO2,NO3(one bulb per channel)
Current Sensor
Outconnected to PZEM004TINIn_currentconnected to PZEM004TOUTand SocketlifeBurdenconnected to PZEM004TOUTOut_currentconnected to Relay 4 Channel 5vCOM1,COM2,COM3
Socket
neutralconnected to PZEM004TINand LED bulbs-lifeconnected to Current SensorIn_current
Documented Code
ESP32 Microcontroller Code (sketch.ino)
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
Note: The provided code is a template and does not include specific functionality. It should be expanded to initialize the hardware interfaces and implement the control logic for the relay module and communication with the PZEM004T module.
