Here is my simple but yet working PZEM-004t script to read AC measured parameters and reset energy counter.
https://github.com/pidou46/uPZEM-004t
I hope it could help.
Note: it's the first repository I publish, please warn me if there is something wrong. (license, ect...)
PZEM-004t_V3.0
PZEM-004t_V3.0
nodemcu V2 (amica)
micropython firmware Daily build 05/31/2016
micropython firmware Daily build 05/31/2016