ESP32 correspondence

I get a lot of suggestions from well meaning folks, but unfortunately, they frequently do not seem to do any investigation as to the practicality or even possibility of many of them. While I respect the sincerity of the authors, I feel it’s futile to answer when the suggestion is in an email because nobody else sees the response and I just keep spending time trying to be courteous with one off responses. So here is one such email that pretty much covers the gist of most of the popular suggestions with my response:


You are developing a new ESP32 energy monitor.

I’d like to make some suggestions to improve your new project.


1 - You have 2 ADCs, but the voltage and current are not acquired at the same time. For better precision those 2 values should be synchronized, in three phase mode, but also in single phase mode.

This results in a precise value for COS(phi) and SEN(phi) to calculate active power and reactive power. It also has the advantage of better accuracy in apparent power calculation (VA) because the samples are taken precisely at the same time.

Example of a 3 phase operation (volts and amps):

Instant 1: Read V1 and A1

Instant 2: Read V2 and A2

Instant 3: Read V3 and A3

If you have more 3 CTs on a second 3 phase channel:

Instant 4: Read V1 and A4 (A4 associated to V1)

Instant 5: Read V2 and A5 (A5 associated to V2)

Instant 6: Read V3 and A6 (A6 associated to V3)

And so on…

Do you think it’s possible to do this improvement?

It doesn’t make sense to have 2 parallel ADCs and not “try” to do this operational procedure.

I think there will be some kind of cons or tradeoffs to be made, but I’m not getting into those details.

ADCs are multiplexed, so with only one ADC it’s impossible to do this, but if you have 2 ADCs there is a possibility.

If you have a lot of CT inputs and feel it’s not possible to do this, maybe you can try using a third ADC only dedicated to VTs (V1, V2, V3) while the other 2 ADCs are reading the CTs.

What do you think?

Yes, the IoTaWatt has two (or more) ADCs, unfortunately it only has one SPI bus to read them. Modern high speed ADC use SAR technology where they essentially stream the output over SPI as the digits develop. Reading simultaneously would require hardware that just isn’t there.

But this suggestion is also a solution looking for a problem. If you were to read the comments of the open-source code, you would see that there is no sampling shift introduced by the sampling algorithm. The successive voltage samples are about 26us apart with the current sample between. IoTaWatt averages the sample prior to and following each current sample to effectively get a time synchronized voltage sample through linear interpolation. Operating on the voltage sine-wave, the variation is less than the resolution of the ADC.

Moreover, with the ESP32 development, those two voltage samples can be from different voltage references making it possible, for instance, to get the actual 240V split-phase voltage using two 120V references, or the phase-phase voltage in a three-phase setup where there are three phase-neutral VTs. This is not possible with the approach you suggest.

2 - The IoTaWatt lithium battery could be a popular format like CR2032.

It’s much easier to find a replacement battery when it runs out, and it will last longer.

If not, you can try using a little larger battery, like CR1225 instead of CR1220, both are harder to find, but at least the CR1225 lasts longer.

Can we use a CR1225 in the same battery connector of the CR1220?

I was not aware that the CR1220 was a problem. Units have been in the field for 5 years and never had anyone report a battery failure. Nevertheless, most of the units will report low battery long before it’s a problem.

The battery does not drain while the unit is powered up, so what we are talking about, for most users is shelf life. With a quality battery, the shelf life of a larger battery would probably be the same.

But moving forward, I’m investigating eliminating the external RTC and using the internal low-power mode RTC of the ESP32 to keep time during an outage. Possibilities are a battery to bridge the gap, possibly rechargeable, or even a super capacitor. Waiting for samples to get empirical data.

3 - The new ESP32 IoTaWatt could have an ethernet RJ45 network port. Cables are always more reliable than WiFi.

I read all the text available on this link Latest on ESP32 and I understand it’s difficult to insert an ethernet port on this solution. However, I must say, it’s much better to have an expansion board with more 14 CTs input (28 total) than an ethernet port and only 14CTs total (without expansion board). 28 CTs are very important.

Ethernet is a non-starter. I’ve covered this over and over. The pins required to connect the required interface are just not available.

4 - What about using VT (voltage sensors) like the ones used in the new emonTx V4? I think they have better precision and they don’t need 3 plugs (one for each phase) inside the circuit breaker box (electrical service panel). This also saves some space and maybe could also power the IoTaWatt with DC current, which is great in cramped spaces. This makes a total of 4 plugs that we don’t need anymore.

Do you think you can use the project voltage sensor / power supply from openenergymonitor and adapt the circuit to IoTaWatt voltage levels requirements? After all these projects are all open source, which is a real advantage in sharing ideas. Everyone should help each other. I think that is the philosophy behind open source. Am I wrong?

You can also do the opposite, which is to adapt IoTaWatt to the EmonVs voltage levels.

Just because somecalls their voltage sensing device a “high-precision” sensor doesn’t mean others are not. What makes you say they “have better precision” and if I may ask better than what? They both use a simple transformer. You might better ask the question how the signal is processed. If you are sampling the voltage at less than 100 samples per cycle, you will not be able to distinguish harmonics. At 600+ samples per cycle, the significant harmonics are measured accurately, or more precisely, they are not measured inaccurately. Not that it really matters that much when you are shooting for a 1% accuracy class.

Yes, they don’t need three plugs, but that is just how they connect to the source. At the end of the day, they both need to be wired somehow to the three phases. In the case of single-phase, I think folks generally find the wall-wart to be more convenient than running wires to a breaker. Most three-phase IoTaWatt users are very satisfied with the accuracy of it’s derived reference technology anyway and use a single voltage reference. For all the talk about three references being more accurate, I’ve not seen anyone actually do an empirical test. That is except me. I ran an extended test on a very large 277V three-phase manufacturing plant using both direct and derived reference, with the exact same CTs at the same time, and found no significant difference. Both yielded results that were well within 1% of the revenue meter.

All that said, I am considering switching to those VTs, but not for any accuracy consideration. For the past few years I’ve been buying up surplus 9VAC wall-warts until now I can’t find anymore. The glut was caused by changing efficiency standards for power supplies and now there are very few companies producing new ones. They are also better suited to a wide voltage range, as the 5VDC switching supplies have been for some time now. If I am to go with recertifying a product, I would put the VT and DC supply onboard and simply use different cords for the various plugs worldwide. With the right wire, it might also be possible to have a direct connect to a breaker.

5 - What do you think about using CTs (current sensors) with voltage output of 333mV (or other value)? Do you think they are a better solution compared to current output models? Maybe they are more accurate, have better flexibility between different brands and models, etc.

You can use voltage output CTs if you simply remove the internal burden resistors. The ESP32 version is currently designed so that the it can be built to use either. In fact the inputs associated with each ADC can be made to do either.

We get the versatility to change the CTs between a very large scale, for example from 5A to 2500A, as long the voltage output is 333mV.

What do you think about this solution?

How is this more versatile than having various range CTs that all output 50mA?

Do you think a CT with voltage output of 1V is better than a CT with voltage output of 250mv? (As long as the measure circuit and ADC are fine tuned to those voltages). Greater output voltage means more resolution and consequently more precision? Any experience in this field? (using 12 bits ADCs in both situations, fined tuned to the desired voltage level )

Not at all. As long as the reference voltage of the ADC matches the possible maximum CT output.

6 - Is it possible to stack more than one expansion board with 14 > CTs? How many?
It would be great to have 2 or 3 expansion boards with 14CTs each, making a total of 4 x 14CTs = 56 CTs

As a practical matter, no. The round robin sampling has its limitations and the more inputs the less frequently each is sampled. I am experimenting with a method to sample two channels at the same time at a lower effective sample rate, and that could perhaps allow for another 14 or 16 inputs, but there are issues with available ADC chip select pins and also the diminishing usefulness for many users. Perhaps it would be better to provide a cloud influx solution to aggregate multiple base units.

Does the ESP32 have enough power for all this load?

If you mean processor speed, definitely. Most of the limitations are reated to the SOC packaging with limited I/O pins.

7 - Do you think it makes any sense to include a RS-485 ModBus connector in IoTaWatt?

No, that involves an RJ45 connection and has similar requirements to ethernet.

Thank you very much for your attention.