FAQ
TL;DR: ESP32 talks to PZEM-004T V3 at 9600 bps; “You need two UARTs. One UART for one PZEM monitor.” Map Serial1 off GPIO9/10 and avoid Serial0; use Serial2 on 16/17 and remap Serial1 (e.g., 22/23). [Elektroda, khoam, post #19390835]
Why it matters: This FAQ helps Arduino IDE users stop Guru Meditation resets and get dual PZEM-004T V3 meters stable alongside TFT displays on ESP32.
Quick facts:
- Serial0 is tied to the USB bridge; keep it for logging, not for the PZEM bus. [Elektroda, khoam, post #19390006]
- Serial1 defaults to GPIO9/10, which are wired to flash; remap to safe GPIOs. [Elektroda, khoam, post #19390364]
- PZEM-004T V3 runs at 9600 baud, 8N1; example begin(9600, SERIAL_8N1, RX, TX). [Elektroda, globalinfo, post #19390167]
- Proven mapping here: Serial1 on 22/23 and Serial2 on 16/17 after library pin support. [Elektroda, globalinfo, post #19391220]
- TFT_eSPI used 40 MHz SPI_FREQUENCY in User_Setup; lower if unstable. [Elektroda, globalinfo, post #19392034]
Quick Facts
- Serial0 is tied to the USB bridge; keep it for logging, not for the PZEM bus. [Elektroda, khoam, post #19390006]
- Serial1 defaults to GPIO9/10, which are wired to flash; remap to safe GPIOs. [Elektroda, khoam, post #19390364]
- PZEM-004T V3 runs at 9600 baud, 8N1; example begin(9600, SERIAL_8N1, RX, TX). [Elektroda, globalinfo, post #19390167]
- Proven mapping here: Serial1 on 22/23 and Serial2 on 16/17 after library pin support. [Elektroda, globalinfo, post #19391220]
- TFT_eSPI used 40 MHz SPI_FREQUENCY in User_Setup; lower if unstable. [Elektroda, globalinfo, post #19392034]
Why does ESP32 crash on Serial1 with PZEM-004T V3?
Serial1 defaults to GPIO9 and GPIO10 on ESP-WROOM-32. Those pins connect to the internal flash. Using Serial1 without remapping causes conflicts and resets. Remap Serial1 to free GPIOs or use Serial2 instead. The original library began Serial with default pins, so Serial1 would not work as-is. [Elektroda, khoam, post #19390364]
Can I use Serial (UART0) for PZEM while keeping Serial Monitor open?
No. UART0 (Serial) is also connected to the USB bridge on most ESP32 boards. Your code uses Serial for logging, so the port is busy. Put PZEM on Serial1 or Serial2 and leave Serial for debugging. [Elektroda, khoam, post #19390006]
How do I set up two PZEM-004T V3 modules on one ESP32?
Use two UARTs and a library that accepts custom pins. 1) Replace PZEM004Tv30.cpp/.h with the modified versions that add pin arguments. 2) Declare PZEMs like: PZEM004Tv30 pzem1(&Serial1, 22, 23); and PZEM004Tv30 pzem2(&Serial2); 3) Wire and build; no end()/begin() tricks needed. This avoids Serial1 on GPIO9/10. [Elektroda, khoam, post #19390835]
Do I need SerialX.end() before reassigning UART pins?
Yes. The PZEM constructor may start Serial with default pins. Call SerialX.end() to clear mappings. Then call SerialX.begin(9600, SERIAL_8N1, RX, TX) to set your GPIOs. This applies to both Serial1 and Serial2. [Elektroda, khoam, post #19390364]
What Serial2 pins worked reliably in this build?
Use the defaults: RX2 on GPIO16 and TX2 on GPIO17. The poster saw errors on other pins but got stable readings on 16/17. [Elektroda, globalinfo, post #19390381]
Which Serial1 pins worked after remapping?
GPIO22 (RX1) and GPIO23 (TX1) worked once the library supported pin arguments. That ran alongside Serial2 on 16/17. [Elektroda, globalinfo, post #19391220]
Can I use GPIO2 and GPIO21 for Serial1 with PZEM?
Yes. The code compiled with PZEM004Tv30 pzem1(&Serial1, 2, 21). This remap helped integrate the TFT later. [Elektroda, globalinfo, post #19392034]
What baud and frame should I use with PZEM-004T V3 on ESP32?
Use 9600 baud and 8N1 framing. For example, Serial2.begin(9600, SERIAL_8N1, RX, TX). This matched the working configuration in the thread. [Elektroda, globalinfo, post #19390167]
Will one UART handle two PZEMs with this Arduino library?
No. "You need two UARTs. One UART for one PZEM monitor." Plan for Serial1 to one module and Serial2 to the other. [Elektroda, khoam, post #19390835]
Does Tasmota or ESPeasy support multiple PZEMs on one ESP?
Yes. A member confirmed Tasmota can do this and ran three PZEMs on one ESP. Reviewing Tasmota or ESPeasy code can help. [Elektroda, xury, post #19390576]
Why does adding TFT_eSPI make my ESP32 reset?
“There must be a conflict in pin selection between TFT (SPI) and Serial.” If SPI shares pins with UART TX/RX, the buses collide and reset occurs. Move SPI pins to free GPIOs and rebuild. [Elektroda, khoam, post #19391825]
Which pins conflicted here, and how do I avoid it?
MOSI used GPIO23 and CS used GPIO17. TX1 was also 23 and TX2 was 17. That overlap caused resets. Move CS and MOSI off those TX pins. [Elektroda, khoam, post #19392072]
What specific change fixed the TFT + PZEM resets here?
Changing TFT CS to GPIO14 resolved the resets. After this change, the setup worked reliably. A poor contact was also suspected. [Elektroda, globalinfo, post #19395818]
How can I confirm my PZEM link is working?
Print measured values and check for plausible numbers. Example output: 238.10 V, 0.07 A, 0.90 W, 0.029 kWh, 50.0 Hz, PF 0.05. This verified a good connection. [Elektroda, globalinfo, post #19390381]
How can I isolate the cause of ESP32 crashes quickly?
Comment out pzem1 first, then test only pzem2. Use the EspExceptionDecoder plugin in Arduino IDE. Decode the stack trace to find the faulting code. [Elektroda, khoam, post #19392095]
Do I need to change SPI speed or driver in TFT_eSPI?
This build used ILI9481_DRIVER and SPI_FREQUENCY 40 MHz. It worked after fixing pin conflicts. If instability remains, reduce SPI_FREQUENCY in User_Setup. [Elektroda, globalinfo, post #19392034]