ESP32 and PZEM004T-Based Smart Light Control with Current Sensing
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit involves an ESP32 microcontroller, a 4-channel relay module, a PZEM004T energy meter, a current sensor, and several LED bulbs connected to an AC socket. The ESP32 controls the relays, which in turn control the LED bulbs. The PZEM004T monitors the energy consumption, and the current sensor measures the current flowing through the circuit.
Component List
ESP32 (30 pin)
- Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
Relay 4 Channel 5v
- Description: A relay module that allows control of high voltage devices using low voltage signals.
- Pins: GND, IN1, IN2, IN3, IN4, VCC, COM1, COM2, COM3, COM4, NO1, NO2, NO3, NO4, NC1, NC2, NC3, NC4
PZEM004T
- Description: An energy meter module for measuring voltage, current, power, and energy.
- Pins: VCC, RX, TX, GND, IN, OUT
Current Sensor
- Description: A sensor for measuring the current flowing through a circuit.
- Pins: Out, Burden, In_current, Out_current
LED Bulb AC / Bombillo AC
- Description: An AC-powered LED bulb.
- Pins: +, -
Socket
- Description: An AC socket for connecting to the power supply.
- Pins: Earth, Life, Neutral
Wiring Details
ESP32 (30 pin)
- D12 connected to Relay 4 Channel 5v IN2
- D13 connected to Relay 4 Channel 5v IN1
- GND connected to PZEM004T GND and Relay 4 Channel 5v GND
- Vin connected to PZEM004T VCC and Relay 4 Channel 5v VCC
- D18 connected to Relay 4 Channel 5v IN3
- TX2 connected to PZEM004T RX
- RX2 connected to PZEM004T TX
Relay 4 Channel 5v
- IN2 connected to ESP32 D12
- IN1 connected to ESP32 D13
- GND connected to ESP32 GND and PZEM004T GND
- VCC connected to ESP32 Vin and PZEM004T VCC
- IN3 connected to ESP32 D18
- COM1, COM2, COM3 connected to Current Sensor Out_current
- NO1 connected to LED Bulb AC +
- NO2 connected to LED Bulb AC +
- NO3 connected to LED Bulb AC +
PZEM004T
- GND connected to ESP32 GND and Relay 4 Channel 5v GND
- VCC connected to ESP32 Vin and Relay 4 Channel 5v VCC
- RX connected to ESP32 TX2
- TX connected to ESP32 RX2
- IN connected to Current Sensor Out and Socket Neutral
- OUT connected to Current Sensor Burden and Socket Life
Current Sensor
- Out connected to PZEM004T IN
- Burden connected to PZEM004T OUT
- In_current connected to Socket Life
- Out_current connected to Relay 4 Channel 5v COM1, COM2, COM3
LED Bulb AC / Bombillo AC
- - connected to Socket Neutral
- + connected to Relay 4 Channel 5v NO1, NO2, NO3
Socket
- Neutral connected to LED Bulb AC - and PZEM004T IN
- Life connected to Current Sensor In_current and PZEM004T OUT
Code Documentation
ESP32 Code
sketch.ino
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
documentation.txt