3 phase - 3 wire monitor using ESP32

Hey folks, another guy from Belgium here, only running my own hardware with ESP32. I see now I have unnecessarily designed it with three inputs while I need only two, but I can always use 3rd one to measure PV output:) I hope the sketch will work with my hw, or at least provide directions on how to modify mine. Of course, my wires entering meter are all the same color, so I guess I will have to find out the sequence myself.

I am glad I stumbled upon this thread, and thanks to Robert for great site and support!

If you are using the ADC inside the ESP32, then I suspect you might have problems. Most people who use an ESP32 use it only to process the numbers, and have a separate ADC.

It has been done a few times, so a search should bring some results.

Thanks for the suggestion. Raw numbers seem ok to me for now, but computation is definitely off.

You must look for differences between your ESP32, and the Atmel ATMega328P, which the library and sketch were written for; then check to see if the differences point you towards something you must change.

Where can I find the sketch that I can use for 3-phase monitoring?

Have you tried searching the forum? Did you not find this?

Can’t I just use emonlib for measuring 3phase voltages? I don’t see that this sketch uses it.

Correct, it does not use emonLib. It actually monitors the voltage and currents simultaneously, which emonLib (as distinct from emonLibCM) does NOT do.

You cannot measure 3-phase voltages (i.e. more than one) with a single emonTx or emonPi because both have only one voltage input available.

That’s fine, I have my own hardware with 3 voltage and 3 current inputs. Will that work?

You can only use emonLib. EmonLibCM is specifically for a single phase system, but it could no doubt be altered/expanded to read 3 voltages and 3 currents, and it would not be very difficult.

You will of course need to write your own sketch around emonLib to get the correct pairing of voltage & current inputs for each instance of the EnergyMonitor class.

Thanks. I am using EmonLib and the voltage values seem to fluctuate a bit more than expected. For measurement of the voltage, I have installed these devices:

In my other module which measures single phase PV power output with hard coded voltage value of 238V everything seems more stable and inline with my AC meter.

If that ZMPT101B uses the same circuit diagram and the same components that I saw and analysed - and it appears to be the same, it is not suitable for measuring real power. It introduces a very large phase shift into the voltage measurement, which emonLib cannot compensate for. Your power reading will be incorrect, possibly by a very large amount, depending on the overall power factor of your loads.

The ZMPT101 transformer on its own with only the correct voltage multiplier resistors in the primary circuit and the burden resistor in the secondary is fine, and it is what we are using with the new emonTx V4. The problem is someone thought it was a good idea to include an op.amp and filter; it is the filter that causes the phase shift, making it useless for real power measurements. I have written about this before, it is not something new.

Here is my voltage for the last 24 hours. it varies from 6.4 V below the nominal 240 V to 2.7 V above.

Thanks Robert, that should be an easy mod - remove everything from secondary circuit except the burden resistor:) Which value should I use?

You need to calculate everything. The ratio of the ZMPT itself is 2 mA : 2 mA according to the data sheet, however the data sheet also gives the operating range as going up to 10 mA, with a 100 Ω burden. You need to look at the data sheet and what you have, and find out the voltage swing that your ESP32 expects, and choose the appropriate values for the multiplier resistor (to set the primary current) and the burden (to set the input voltage to the ADC). However, the phase error curves stop at 8 mA, so I’d suggest running at about 6 - 7 mA at your nominal mains voltage, which should keep you within the ZMPT101’s VA rating (which you get from 10 mA & 100 Ω = 10 mVA). Beware the power rating of the multiplier resistor - it’s likely to be at least 2 W.

You mentioned emonTxV4 is using the same transformer. In my code there’s a line:

#define emonTxV3

Should this be changed to emonTxV4 since I am using ZMPTs as well?

No - nothing final has been published yet for that, and I’m almost certain that emonLib won’t be changed to make it suitable for use with the emonTx V4. If you look at the emonLib code, #define emonTxV3 sets up the correct voltage reference. As you’re using an ESP32, even that might be wrong, you need to check.

Info on the ESP32 ADC: