Setup 3-phase emonTX with emonESP using emoncms.org

Thanks lots for the reply Robert, with a little bit of additional research it solved my issue.
If someone got the same issue, i want to keep my documentation for this issue here:

use case: 3 phase, 4 wire, 230V, country:Austria, use of emonTX with emonESP and emoncms.org (without emonPi or emonBase)

emonTX

  1. Download Firmware for emonTx V3.4.x GitHub - openenergymonitor/emontx3: EmonTx V3.4.x Hardware and older discreet firmware, see EmonTxV3CM repo for latest
  2. Download emonTx V3 3-phase Firmware https://github.com/openenergymonitor/emontx-
  3. Download and install platformIO Atom (see “Firmware Modification” Firmware Modification - Guide | OpenEnergyMonitor)
    3.1 Install “platformio-ide” Package
    3.2 then I had to remove the c:\Users\Username.platformio\penv Directory and restart platformIO
    3.3 I also had to check and uncheck “Use built-in Platform IO Core” within the platformio-ide package settings in platformIO
  4. “Open Project” in platformIO, point to directory “firmware” of the previously downloaded Firmware for emonTx
    4.1 Remove files from src directory
  5. Move files from previously downloaded “emonTx V3 3-phase Firmware” to the empty “src” folder of the project created
  6. Edit file emonTx_3Phase_PLL.ino
    6.1 change “#define RFM69CW” to “#define EMONESP”
    6.2 consider my installation in Austria, one also changes “double vCal = 268.97” to value 260
    6.3 make sure occurence of “Serial.begin(” has value 9600 (necessary due to use of 3phase with emonESP)
  7. Build the project, connect the emonTX via “UART to USB programmer” and “Upload”

emonESP

  1. Download firmware for emonESP GitHub - openenergymonitor/EmonESP: ESP8266 WIFI serial to emoncms link
  2. Open Project in platformIO IDE, use folder EmonESP-master from previous download
  3. Edit file src.ino, change ocurrences of “Serial.begin(115200” to value 9600 - matching the setting from the emonTX
  4. Edit file platformio.ini, change -DWIFI_LED=0 to value 2 (0=rst!) (EmonESP keeps rebooting)
  5. Following the guide GitHub - openenergymonitor/EmonESP: ESP8266 WIFI serial to emoncms link
    5.1 connect the emonESP via UART to USB progammer
    5.2 Upload src via command “pio run -t upload”
    5.3 Upload spiffs via command “pio run -t uploadfs”

(
I dont know if the following was really necessary in my case, since the recurring reboot problem of the emonESP was solved following 4.)(DWIFI_LED=2)
Anyhow, if reboots persist, try to erase all flash memory following the guide GitHub - openenergymonitor/EmonESP: ESP8266 WIFI serial to emoncms link. “esptool.py write_flash 0x000000 blank_1MB.bin 0x100000 blank_1MB.bin 0x200000 blank_1MB.bin 0x300000 blank_1MB.bin”. Use “esptool” (GitHub - espressif/esptool: Espressif SoC serial bootloader utility), satisfy depenence “pyserial”(pyserial for Python 2.7.2 - Stack Overflow
)

1 Like

I cannot recommend platformio. Although it appeared to work for you, when I installed it on my machine, it moved several directories and their contents, and thereby broke my system.
Consequently, I consider it malware and I am unable to support it.

I’ve said it before, I don’t think that an appropriate term to use. It might not have done what you expected or wanted, but that does not make it ‘malware’.

And I’ve said it before too: if an application moves pre-existing files and directories without asking or warning, and without explicit permission, that is the behaviour of malware.

Or, at the very minimum, a poorly designed app. I vaguely recall at least one other person
saying the same thing Robert did about PIO moving files on their machine.

It wouldn’t be quite so bad if one got a warning about any impending filesystem changes
and a chance to halt the install process.

Hello Peter, that looks like a very useful guide. I want to end up with exactly what you have done but in the UK - that is 3-phase, emontx-EmonESP-emoncms.org. I currently have the standard emontx 3.4 and shop supplied WiFi add on setup for single phase with 4x CTs. I discovered that this does not give correct results on 3-phase (see EmonTx Input labels - confused new user - #10 by borpin )
Is there some easy (ie lazy and needing very limited technical knowledge!) way to get my hardware loaded with the necessary firmware to operate correctly on 3-phase?

I can only say, use platformio at your own risk. I won’t be able to help you if you have problems with it.

Note there is a pre-compiled 9600 baud version of the ESP8266 sketch:

https://community.openenergymonitor.org/uploads/short-url/zegtvp5lICQT1w6J7ZoTXRnsiw3.bin

@Borpin says he uses Release 1.4.0 · esphome/esphome-flasher · GitHub to flash anything to ESP8266 devices.

1 Like

I appreciate you are trying to be helpful here Robert but each time I follow one of these links I end up somewhere where things are written in a language I’ve never seen before- it looks like English but I’ve no idea what it means.
I guess I’m just nowhere near qualified to be trying to use OEM offerings and I’m not really prepared to put the time in to learn this language.

I think I’d rather thought that from what you’d written in the other thread. I’ve been using computers for some years, starting with a remote mainframe running Fortran 4 and programming on punched paper tape - this was 40 years ago. I’ve come across a fair few operating systems, compilers and desktops in my time and never, ever, had something screw things up like platformio did. It took me a couple of hours to put everything back. I hate to think of the mess you’d be in if it did that to you.

If only for that reason, I advise you to stay with the tried and tested Arduino IDE.

FORTRAN, Algol, ICL 1900, IBM 1130 etc

That was 50 years ago for me - I hoped things had progressed!

I have followed all the steps and I am getting wrong data in ESP mini D1.
At the beggining I was using continous monitoring firmware + EmonESP 2.3 and everything works great.
Now I changed to

OpenEnergyMonitor.org
ct1:0.00,ct2:0.00,ct3:0.00,ct4:0.00,vrms:0.00,t1:23.75,t2:300.00,t3:300.00,t4:300.00,t5:300.00,t6:300.00,pulses:1
ct1:-0.00,ct2:-0.88,ct3:-1.75,ct4:0.00,vrms:0.65,t1:23.75,t2:300.00,t3:300.00,t4:300.00,t5:300.00,t6:300.00,pulses:1

I also modified this

Then I downloaded last EmonEsp and I changed the baudrate from 115200 to 9600.

And now I am getting:


Which is quite weird

In my MQTT broker I receiving this kind of data CT measures are in W and I expected Amps ( I have change the coils directions), voltage looks nice.


I dont have any temp probe connected so the are equal to 300. And then this extrange message Saving…
Any help is welcome I spent all the morning with this issue.
Best regards

As far as I am aware, the sketch as published in the forum here is correct and works (it reports V1.4, but it is really V1.6):

Any changes made by someone else, without referring it to me, are their responsibility.

OEM has always sent the output in watts. You can change the sketch if you wish, it is lines 942 - 951. The variables you want are I1rms, etc. But it means you will NOT know the real power, which is what you pay for, unless your send both power and current.

I’m afraid I don’t have an ESP8266, so I can’t investigate that side for you.

Thank you again, so probably my problem is in the EmonESP firmware cause I am using last release of emonTx_3phase

Looking at the data the ESP is getting - you have NOT edited the sketch to say you want the ESP output.

Read line 82 and all of the comment:

#define RFM69CW                                  // The type of Radio Module, or none.
                                                 // Can be RFM69CW 
                                                 //   or SERIALOUT if a wired serial connection is used 
                                                 //   or EMONESP if an ESP WiFi module is used (see https://github.com/openenergymonitor/
                                                 //     emonTxFirmware/blob/master/emonTxV3/noRF/emonTxV3_DirectSerial/emonTxV3_DirectSerial.ino) 
                                                 //   or don't define anything if neither radio nor serial connection is required - in which case 
                                                 //      the IDE serial monitor output will be for information and debugging only.
                                                 // The sketch will hang if the wrong radio module is specified, or if one is specified and not fitted.
                                                 // For all serial output, the maximum is 9600 baud. The emonESP module must be set to suit.

I think that the 3-phase sketch has the “EMONESP” well defined,
WhatsApp Image 2020-02-25 at 8.30.32 AM

I think that my issue is that my ESP thinks somehow that I want to change the EEPROM configuration.
Can be one of this 3 things
1- I am using esp8266mod core (same than huzza) mounted in a mini D1 dev board.
2- I also have a LCD mounted but I didn’t add the libraries yet, maybe any pin is HIGH and the board is understanding that it have to save any value in the EEPROM getting:

Got '15 1 210 20 110 118 67 205 204 181 66 102 102 134 64 205 204 181 66 102 102 134 64 205 204 181 66 102 102 134 64 41 92 133 65 0 0 128 63 Done. New config saved to EEPROM'
Got 'ct1:0.01,ct2:2.48,ct3:4.98,ct4:-0.00,vrms:3.36,t1:300.00,t2:300.00,t3:300.00,t4:300.00,t5:300.00,t6:300.00,pulses:0'
Got 'Saving...'
Got '15 1 210 20 110 118 67 205 204 181 66 102 102 134 64 205 204 181 66 102 102 134 64 205 204 181 66 102 102 134 64 41 92 133 65 0 0 128 63 Done. New config saved to EEPROM'

edit I saw this message comes from save_config() config.ino in emonTX side
edit2 Maybe the emonTX is taking the emonesp as confing input parameters

3- Something involved with the 3-PHASE firmware for emontx because with the last release of single phase continuous monitoring everything works well.

I am going to check these issues

Okey!! now work!!!
The trick was remove the getCalibration function in emonTx_3phase_PLL.ino

Last question, I would like more info in the payload:
can I modify this struct?
from

typedef struct { int power1, power2, power3, power4, Vrms, temp[MAXONEWIRE] = {UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,
                  UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE,UNUSED_TEMPERATURE};
                  unsigned long pulseCount; } PayloadTx; 

to

typedef struct {
    int Vrms,power1, power2, power3, power4; // W
    float powerFactor1, powerFactor2,powerFactor3,powerFactor4; // cosphi
    float Vrms, I1rms, I2rms, I3rms, I4rms; // Amps
    unsigned long sumPeriodSamples; // Wh
} PayloadTX;

Best regards and thanks for the support

edit I got it work adding to void sendResults()

   #if defined EMONESP && !defined SERIALOUT
    #if WIRES == 3-WIRE
    Serial.print(F("ct1:")); Serial.print(realPower1+realPower2);            // These for compatibility, but whatever you need if the receiver is configured to suit. 
    Serial.print(F(",ct2:0.0"));
    #else
    Serial.print(F("ct1:")); Serial.print(realPower1);
    Serial.print(F(",ct2:")); Serial.print(realPower2);
    #endif    
    Serial.print(F(",ct3:")); Serial.print(realPower3);
    Serial.print(F(",ct4:")); Serial.print(realPower4);
    Serial.print(F(",vrms:")); Serial.print(Vrms);
    Serial.print(F(",I1rms:")); Serial.print(I1rms);
    Serial.print(F(",I2rms:")); Serial.print(I2rms);
    Serial.print(F(",I3rms:")); Serial.print(I3rms);
    Serial.print(F(",I4rms:")); Serial.print(I4rms);
    Serial.print(F(",pf1:")); Serial.print(powerFactor1);
    Serial.print(F(",pf2:")); Serial.print(powerFactor2);
    Serial.print(F(",pf3:")); Serial.print(powerFactor3);
    Serial.print(F(",pf4:")); Serial.print(powerFactor4);

That is the correct place. “Payload” is only for the RFM radio.

1 Like

getCalibration does nothing and returns immediately unless there is serial input. The emonESP should NOT be sending anything back to the emonTx.
With getCalibration( ) removed, you will not be able to calibrate the sketch using the serial adapter and your Arduino IDE.

1 Like

Hello, first post here. Got my emontx v3.4 yesterday and spent a lot of time to make 3 phase reporting work with emonesp before finding this thread. I was able to compile both the emonesp and the emontx firmware with platformio, they already talk to each other, but for some reason, I’m unable to flash the emontx via the UART headers (I get this error message: avrdude: stk500_recv(): programmer is not respondingavrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00 and it continues until it reaches 10) so I had to flash via another Arduino using the ICSP headers. Anyone has an idea how to fix that? Perhaps a working bootloader for the emontx? I was searching through the github site but couldn’t find one (emonupload pulls a bootloader and I flashed that but it didn’t work - I also tried flashing an Uno bootloader from the Arduino IDE but that didn’t work either). I hope I don’t have to flash very often but not having to use ICSP for flashing would be a big advantage :slight_smile:

Welcome, Zolan, to the OEM forum.

Unfortunately, I can’t help you with platformio. I am only able to support you when you use the Arduino IDE.

The documentation that you downloaded along with the 3-phase sketch does tell you, on page 3, what you need to do to get it working with an ESP8266, so any problem there must be due to platformio.

avrdude: stk500_recv(): programmer is not responding is sadly a very general message and it just means that it cannot communicate. It could be the wrong port on your computer, or a cable, or a problem with your FTDI to USB programmer (some programmers do not use the RTS line, which would mean the emonTx did not get reset at the correct instant, so did not enter programming mode). You should not need to use ICSP, the emonTx came to you with a bootloader and a working sketch installed.