Skip to content

Connecting PZEM to ESP8266

vortigont edited this page May 13, 2018 · 1 revision

Tips on connecting PZEM power meter to ESP8266-based boards

Level conversion:

PZEM's serial port requires 5 volts to operate reliably, but ESP8266 uses 3.3 volts level logic. So there are 3 options

  • run PZEM serial at 5v and ESP8266 at 3.3v and hope it wont burn (not recommended option, but possible for prototiping)
  • use external level-converter board, any simple FET-based board from aliexpress woud do just fine
  • modify PZEM to be 3.3v tolerant (soldering skills required). This page may help

Using hardware serial with ESP

ESP8266 Software-serial on arbitrary pins may have issues with stabilty because of the blocking during IO and interrupts for WiFi operation, especially under an updated ESP-Core 2.4. For reliable operation it's better to use hardware serial but it may not be that easy.

ESP8266 has two UART ports - UART0, UART1.

UART1 is capable of output only and can not be used for bidirectional communication.

UART0 uses gpio1,3 pins, which on many boards usually connected to an onboard USB2serial converter. It may affect communication with PZEM serial port, it's better not to share USB2serial pins for PZEM communication. If you use one of those boards there is an option to swap UART0 pins from default gpio1,3 to gpio13,15 For details, see docs.

And the last trick - when esp8266 boots up after power-up or reset it's gpio15 pin must be pulled LOW to boot from SPI flash. When connected to PZEM's rx this pins becomes always pulled HIGH via optocoupler's internal LED and it prevent's ESP from bootstraping. To work arond it gpio15 colud be connected to PZEM via PNP transistor using emitter follower mode.

Simple sketch to test hwserial connection with PZEM could be found here.

Example connection diagram:


You can’t perform that action at this time.