Community
OpenEnergyMonitor

Community

Setup 3-phase emonTX with emonESP using emoncms.org

Tags: #<Tag:0x00007f78e39eb048> #<Tag:0x00007f78e39eaf80>

Hello, my accountname ist peterneubauer

Configuration:
Hardware: emonTx with 3 CTs, 5V-DC and AC-AC-adapter, emonESP
Version: In my order I mentioned that i want to monitor 3-phase system. I don’t know if this was considered to the deployed versions of the emonTX or emonESP. so currently the versions are unknown to me.
As mentioned I want to monitor 3-phases. (according to the forum, using just one AC-AC adapter and one emonTX, I will need to use the 3-phase-voltage-estimation-firmware for the emonTX)

Installation:
Assuming the correct firmwares preinstalled I followed the guide for 3phase usage. I disconnected power from the emonTX, then 1.) connected emonESP 2.) all 3 CTs 3.) connected 5V DC power via USB and 9V AC-AC adapter simultaneously.
(Here I have to mention, previously I sucessfully ran the HW-configuration with the EmonPi (as base) and the emonTX, means the emonESP was not attached to the Tx. The Tx sent the data via Emonpi to emoncms.org)

Issue 1: Cannot connect emonTX to Emoncms.org server
I followed the guide regarding the emonTX-web-configuration: “Emoncms Server*” with value:“emoncms.org”, “Emoncms Node Name*” value:“0”, and the “Write apikey*” copied from emoncms.org Account information (copy/paste). Still the emontx tells me “Saved - Connected: No”.
Information: Within the home-Wifi connected, the emontx/emonesp has a default route to the internet (Standard provider Wifi-Router/DHCP), however similar IP-clients autoconfig and have access to the internet via the network connected.

Issue 2: “Latest Data” on the emonESP seems wrong.
Section “Latest Data” on the emonTX-webinterface displayes (Key Value) T1: 3935, CT2: 325W, T0: 20.5C
(http://192.168.1.130/input?string=CT1:3935,CT2:325,T0:20.5)
I have to say, that running the previous hardware-configuration with the emonpi as base, the correct values for CT1,2 and 3 were collected sent to emonpi and further to emoncms.org.
Reading through the openenergymonitor-forum, I think the current version of my emontx may not be recent enough. Capturing 3-phases with emontx and using emonesp as Wifi-connection needs recent firmware version for emontx and maybe some configuration like baudrate (max 9600) to both emonTX and emonESP. (But I don’t know how to archieve this currently)
current Version Information emontx (emonESP Menue: “7.System”) is v2.3.0. (is this the emontx firmware? or the emonESP’s?)

As you can see I need some help :slight_smile:
I would appreciate related instructions on my issues 1 and 2. Willing to provide any further necessary information!
Maybe I only need the right links into the openenerymontor-forum.

(I am willing to obtain an USB to UART adapter in order to upload the appropriate firmware for my scenario. I would appreciate a guide or some kind of checklist for that, maybe just the right links in the forum).

Thanks in advance
Best Regards
Peter

Welcome, Peter, to the OEM forum.

I do not have access to the records from the shop. I have asked the question for you.

[Edit]
It appears that you have the 3-phase sketch, but the standard software in your ESP. That will explain why it is not communicating.
[/Edit]

That is correct. The 3-phase sketch will give a good estimate of real power (Wirkleistung), the standard sketch will give the incorrect values for real power, but it does calculate - but not show - apparent power (Scheinleistung) correctly.

I am sorry, but I cannot answer this. I do not have an ESP8266 module, therefore I have no experience of this.

Because the emonTx is very busy when running the 3-phase sketch, it is not possible for it to communicate with the ESP8266 module at the default baud rate. It therefore needs the baud rate in the ESP8266 to be reduced to 9600 baud.

It is always good to have this adapter (“programmer”). If you do obtain one, be warned that some do not work with our system. If you buy from the OEM shop, that one is guaranteed to work.

If you do buy the programmer, you can adjust and load the 3-phase sketch in your emonTx, and calibrate it for your system if necessary, and you can load the software for the ESP8266 that has the correct baud rate:(https://community.openenergymonitor.org/uploads/short-url/zegtvp5lICQT1w6J7ZoTXRnsiw3.bin)

If you download the 3-phase sketch Update to 3-Phase PLL sketch
then you must read the documentation that comes with it, and choose the options that are right or you. (I’m sorry it is in English only - your English is much better than my German.)

I wrote the sketch for a fellow countryman of yours, @Simsala. He uses the 3-phase sketch and emonESP and he might be able to help you.

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 https://github.com/openenergymonitor/emontx3
  2. Download emonTx V3 3-phase Firmware https://github.com/openenergymonitor/emontx-
  3. Download and install platformIO Atom (see “Firmware Modification” https://guide.openenergymonitor.org/technical/compiling/)
    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 https://github.com/openenergymonitor/EmonESP
  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 https://github.com/openenergymonitor/EmonESP#installation
    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 https://github.com/openenergymonitor/EmonESP#erase-flash. “esptool.py write_flash 0x000000 blank_1MB.bin 0x100000 blank_1MB.bin 0x200000 blank_1MB.bin 0x300000 blank_1MB.bin”. Use “esptool” (https://github.com/espressif/esptool), satisfy depenence “pyserial”(https://stackoverflow.com/questions/8491111/pyserial-for-python-2-7-2
)

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 )
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 https://github.com/esphome/esphome-flasher/releases/latest 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

  • Update to 3-Phase PLL sketch
    Where I modified the necessary lines to stablish communication with the esp getting the following serial readings:

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