EMONTX_SHIELD - Need help to configure sketch - ESP Easy Mega

Hi everyone,

i need your help because i don’t find how to configure my device.


i have :

  • 1* EmonTxShield
  • 1* Wemos® UNO + WiFi R3

i use this sketch :

Update to 3-Phase PLL sketch - Hardware / emonTx - OpenEnergyMonitor Community

i read the manual but i thing that i miss something …

My question is how to send information to my ESP easy mega interface ?



The sketch and the Shield were designed specifically for the Arduino Uno. The Shield has an ISM band radio, and by design, this is the mechanism whereby the data is sent to the emon base station (emonBase or emonPi).

As it is, the sketch also sends data to the serial programming FTDI interface of the Uno, in one of several formats, chosen by you at compile time. You will probably need to take the output values, convert their format to whatever your WiFi interface requires (maybe numeric values as text, similar to the EMONESP or SERIALOUT formats) and send the text string to the WiFi interface. EMONESP is the format used for the ESP8266 Wi-Fi adapter used with the emonTx. The documentation for your WiFi interface will surely give you the details you need. I have no knowledge of the particular components you intend to use, so I can only give you general guidance.

1 Like

ok so i need to adapt this sketch and add this :
Serial.print(“TaskValueSet,1,1,”); Serial.println(realPower1);
Serial.print(“TaskValueSet,1,2,”); Serial.println(realPower2);
Serial.print(“TaskValueSet,1,3,”); Serial.println(realPower3);
Serial.print(“TaskValueSet,1,4,”); Serial.println(realPower4);
Serial.print(“TaskValueSet,2,1,”); Serial.println(Vrms);

i test this solution , thanks :slight_smile:

i use this sketch, it works but only for 1 phase.

i forgot to explain but i have 3 phase :slight_smile:

and on my phase 2 , i have my solar pannel so the voltage is not the same.

how can i separate the voltage because on phase1 and 3 it works but not on phase 2 ?



The emonTx, the emonPi and the emonTx Shield are all the same in that there is only one voltage input available. In the 3-phase sketch, the software is phase locked to that voltage and the reference voltages used in the power calculation for the other two phases are derived from that, but with the fundamental assumption that the amplitude is the same.

Therefore, unless the Phase 2 voltage is different by a known proportion (and always the same proportion), which you can correct by changing the calibration for the current, there’s nothing you can do about it other than having a second setup for Phase 2.

The WEMOS R3 UNO is based on the ESP8266, and from what I have seen, it only brings out the single ADC channel of the EXP8266 board.
the UNO with the ATMEL/MICROCHIP 328 has 6 ADC channels.
the EMON SHEILD is designed to connect to 4 ADC channels.

Is there a WEMOS R3 UNO that has a multi-channel ADC Chip ?

is there a tested combination of ESP8266 and external ADC chips?

This page: Wemos UNO+WiFi R3 ATmega328P+ESP8266 Module 32Mb Memory USB-TTL CH340G Compatible For Arduino Uno – Arduino Tech, specifically the top view photo, shows there are 6 analogue inputs, and I can in fact see an Atmel Mega328P on there.

I’d suggest therefore that this one at least is a genuine Uno Shield that’s using the ESP8266 only for comms.
(Functionally, if not exactly, like the EmonESP.)

the wemos R3 has two cpu the ATMEL 328 and the esp8266 and they work independently of each other - they only communicate at the serial port if desired via a switch so you have all uno ports(21) and 12 esp so ~33 total – you can use the serial to communicate back and forth but i also use pwm on the ESP an interrupt/pulsein on the uno to measure pwm width and then generate a type input that way on/off - up/down etc …as found it more reliable

Thanks for your responses.

So i need an other Emontx shield for my Phase 2 to calculate the volatage correctly right ?



I don’t know. Only you know your system, what you need to tell us is how much different the Phase 2 voltage is, and why it is different - because on any “normal” 3-phase system, the 3 line voltages should be exactly the same. In the real world, we know that will happen only rarely, but they should be nearly the same, to within a few percent of each other.

Are you trying to say that, when the Solar is generating, the Phase 2 voltage rises to such an extent that there is a big difference between it and the other two phases? And when it is not, the three voltages are much closer together?

Je ne sais pas. Vous seul connaissez votre système, ce que vous devez nous dire, c’est à quel point la tension de la phase 2 est différente et pourquoi elle est différente - car sur tout système triphasé “normal”, les 3 tensions de ligne doivent être exactement les mêmes. Dans le monde réel, nous savons que cela n’arrivera que rarement, mais ils devraient être presque identiques, à quelques pour cent près l’un de l’autre.

Essayez-vous de dire que, lorsque le solaire génère, la tension de la phase 2 augmente à un point tel qu’il y a une grande différence entre elle et les deux autres phases ? Et quand ce n’est pas le cas, les trois tensions sont beaucoup plus proches ?

not really a big difference.

On phase 1 and 3 : 235V
On phase 2 : 235 - 240V (depend if solar is generating).

maybe i need to more calibrate my sketch.

i check when i come home :slight_smile:



I would say that is fairly normal- as i see the same when I am generating solar the voltage on that side is slightly higher on that line usually 3-4 volts . just the same as when you put a high current load on the other side will drop the voltage to that side in comparison to the other … it comes down whether it is pushing ( pushing current in the voltages goes up as in generating ) or pulling ( pulling current and voltage drops as in usage) you probably could create a mathematical equation to compensate for that by measuring the output at the inverter and the measurement at the main fuse panel- to calculate the difference in load sharing between either inputs to give estimated value of what voltage would be in the line –

If the difference is about 5 V in 240, that’s about 2%. If you adjust the current calibration for Phase 2 by about 1%, then it will distribute the error between generating and consuming, so it will tend to average out and come closer overall.

If you want to be really clever, then as @stephen says, you can detect the sign of the power on Phase 2 and change the current calibration constant in the sketch accordingly.

The place to do it is after line 820, when the real power is calculated. You need to check if realPower2 is negative, and if so, multiply it by a fixed value (say 1.02) - or if you want to be really, really clever, make it proportional to the power itself (so the correction becomes proportional to power², which sounds wrong but we’re actually using power as an alias for current), and you must do the same to apparentPower2, otherwise you will have wrong power factors calculated. Ideally, you should make the proportionality a variable and store it in EEPROM along with the rest, to save recompiling if you want to adjust the value.

so, i make test.

when i use the sketch : Howto --emonTx - Shield ESPEASY and WEMOS R3 UNO

i have correct voltage but the W was not correcte.

if i use a W metter i see 1500W but with my arduino i see 750W. ( i test with an electrical heater)

i put this for calibration :

if (CT1) ct1.current(1, 60.606); // Setup emonTX CT channel (ADC input,calibration)
if (CT2) ct2.current(2, 60.606); // Calibration factor = CT ratio / burden resistance
if (CT3) ct3.current(3, 60.606); // emonTx Shield Calibration factor = (100A /0.05A) / 33 Ohms
if (CT4) ct4.current(4, 60.606);

if (CT1) ct1.voltage(0, 253.755, 1.7); // New calibration = existing calibration × (correct reading ÷ emonTx reading)
if (CT2) ct2.voltage(0, 253.755, 1.7);
if (CT3) ct3.voltage(0, 253.755, 1.7);
if (CT4) ct4.voltage(0, 253.755, 1.7);

my clamp : 100A/0.05A

but i don’t understand why i don’t have the same value.



I live in Canada my power is different - it split phase mine is 120V/240 in my local condition

To understand the implications of Stephen’s comment, read the page in Learn about using the emonTx in North America (USA & Canada share the same system: 120 - 0 - 120 V, so their a.c. adapter normally measures one 120 V leg and assumes the voltage on the other leg is matched (they aren’t phases, it’s one winding of a 240 V transformer secondary with an earthed centre tap).

Your current calibration is obviously wrong.

There are two parts to the calibration - the ratio of mains input voltage (or mains current) to the voltage presented to the ADC, and the ratio of the number out of the ADC to that voltage.

What is the ADC input range of your processor’s analogue input?

If that is not the value that emonLib uses in the calibration, then both current and voltage measurements will be wrong by the same proportion.

I suspect it is that which is wrong. What you’ve probably done is corrected the voltage calibration to get that part correct, but not done the same with the current.

ok so i need to check calibration.

if i see in sketch :
ADC input, calibration,phase_shift)
ADC input => 235.5 (check with multimeter)
Calibration => 260 for EU
Phase_Shift => ??

where can i find information, i check in learn but i can’t find solution.

What is the ADC input range of your processor’s analogue input? => where can i find this info ?

For information i’m from Belgium.

My AC adaptor :



I have no information about the ESPEASY and what the ADC reference voltage is. Without that, I cannot calculate the correct Current Calibration Constant.

What you can do - and this will calibrate your Shield to your “W metter” - is adjust the current calibration constant so that the power to your heater as measured by the Shield is the same as the W metter reports.

This is the page you need: Learn→Electricity Monitoring→Current & Voltage→1. Calibration Procedure→Calibration Procedure

If you cannot measure current, then if you have calibrated the voltage correctly, adjusting the current calibration to give the same power is equivalent. But you must first adjust the phase angle calibration as this will affect the power measurement. Then go back and check the phase calibration - go from one to the other and back again until everything is correct.

i find this page before, thanks :slight_smile:

but i don’t find how to calculate correct value .

this is my ADC:

in the sketch i find to line for calibration :

(CT1) ct1.current(1, 60.606) => i have clamp 100A/0.05 and i check the burden resistance on the Shield and i have 33 Ohms so i thing that this calibration was correct.

if (CT1) ct1.voltage(0, 253.755, 1.7) => this is the line for voltage calibration right ?

on my ADC i see 230-240VAC, this is the information that i need to calculate ?

But you must first adjust the phase angle calibration

it’s possible to calculate this information ?