Please explain as clearly as possible what you want to do. If you want to monitor energy consumption of individual appliances, post links to the sensors you will be using.
Do you have an Arduino question? The code you linked runs on a Raspberry Pi 3, and ESP32 is not an Arduino.
There are web sites that describe using the PZEM-004 with Arduino. Studying those would be the place to start.Hint: google "arduino pzem-004"