Column: Electronics design
Developing a Mains Power Monitor with Flowcode
Figure 1: The Power Monitor setup
By Martin Whitlock, Applications Engineer, Matrix TSL
as stated. Since he has no smart meter (even if he did, it won’t be logging every second), he asked me to fi nd a solution. He wanted it Wi-Fi linked, so the PC doesn’t have to be situated next to the monitoring device. Hence, the Mains Power Monitor was developed. T is monitor uses an ESP32 module
A GND
with integrated Wi-Fi. I am using a Wroom version, but the Lolin will work just as well. T e Power Monitor’s hardware is a PZEM-004T; the version I bought has a plastic enclosure (vital to prevent mains shock) and a 100A split transformer; see Figure 1. T e connections are as follows:
PZEM-004T connections (isolated 3V3 side) ESP32 Wi-Fi board 5V RX TX
3V3 27 14
GND
PZEM-004T connections (mains side, on the right, from top to bottom) Live Neutral Current transformer (any connection) Current transformer (any connection)
Figure 2: Flowcode app developer for the Mains Power Monitor
As always, it’s important to be careful with the mains, which can kill, so only
12 October 2021
www.electronicsworld.co.uk
friend of mine wanted to keep logs of his power consumption and also wanted to make sure the wattage of his appliances is
attempt this project if you are competent at mains wiring. I would recommend the mains of PZEM-004T to be wired to a 3A-fused mains plug, and only purchase a PZEM-004T with plastic casing. You will notice that 5V of PZEM-004T
connects to 3V3 of ESP32 – this is not a mistake. T e Wi-Fi board supplies the power to the PZEM-004T, not the other way around. Since the ESP32 pins are only 3V3 tolerant, the PZEM-004T works just as well at 3V3. Since not a lot of hardware is involved,
there’s no need to level shiſt . T e hardware work sends data via Wi-Fi to the PC, where log fi les of the power consumption are saved. I am not an expert in C or MODBUS, so
I need a nice, simple solution to program the ESP32. I chose Flowcode; see Figure 2. With it, you just create fl owcharts of what you want to do, and the program does the rest.
Programming the ESP32 module 1. Register for a Flowcode account. 2. Aſt er receiving a conformation email, download the ESP32 tool chain and Flowcode.
3. Install the ESP32 tool by carefully following the instructions.
4. Download and install the correct drivers for the ESP32 board you have depending on which ESP module you use. T e CP210x Universal Windows Driver or the CH340 Driver will require installing fi rst. I’m using ESP32- Wroom-32, which uses CP210x. I’d recommend restarting the PC aſt er the drivers are installed.
5. Make sure you have the ESP32 board
Page 1 |
Page 2 |
Page 3 |
Page 4 |
Page 5 |
Page 6 |
Page 7 |
Page 8 |
Page 9 |
Page 10 |
Page 11 |
Page 12 |
Page 13 |
Page 14 |
Page 15 |
Page 16 |
Page 17 |
Page 18 |
Page 19 |
Page 20 |
Page 21 |
Page 22 |
Page 23 |
Page 24 |
Page 25 |
Page 26 |
Page 27 |
Page 28 |
Page 29 |
Page 30 |
Page 31 |
Page 32 |
Page 33 |
Page 34 |
Page 35 |
Page 36 |
Page 37 |
Page 38 |
Page 39 |
Page 40 |
Page 41 |
Page 42 |
Page 43 |
Page 44 |
Page 45 |
Page 46