Setup 3-phase emonTX with emonESP using emoncms.org

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.

It could be the wrong port on your computer,

Or a data rate mismatch. e.g. 115200 bps is needed, but 38400 bps is selected.

No, that is automatically selected for programming mode. It is different to the data rate for serial communication done by the sketch.

Thanks both for the responses. I have tried it with the Arduino IDE and also with avrdude manually (even tried from a Mac besides my Linux box), but neither worked. My USB UART was successful in flashing the ESP, so I think the UART & cables are working fine - also, I was successful flashing the emontx via the UART earlier in the day but something must have happened that “killed” the UART. I was looking for a way to restore the thing to a factory default state (including the boot loader), do you know if that’s possible at all?
EDIT: Forgot to mention that I have had the same error message in each case.

Gotcha. :wink:

I don’t. Some of our sketches do come in binary form with the bootloader. If that is your problem, I would guess (I’m not an expert in this area) that loading one of those would then mean that you could use the FTDI port once more. There’s one on Github at emonTxFirmware → emonTxV3 → RFM → emonTxV3.4 → emonTxV3_4_DiscreteSampling → compiled

I don’t know that this will work, if it does, I think you will have the same bootloader that we use normally.

Thanks again! Let me see how it works, if all is well I won’t bother but if I need to flash again, I’ll try flashing that image first. Appreciate the help!

1 Like

So I think it works, thanks again for your help. I connected everything, just validated if the ct1-4 numbers increase when the load increases and it seems to me everything is fine. CT1 & 4 are on the same phase where the AC adapter is plugged to and I guess everything is all right. The values are feeding both into my MQTT server and also into emoncms.org (see below screenshot).

emonesp

The part I’m having trouble with is what to do with these numbers :slight_smile: I have read through the 3phase measurement document and I’m trying to educate myself, but would appreciate any pointers in the right direction how can I get to kW values from these CT numbers.

My aim with EmonTX was to figure out how the 3 phases are being utilised because 1 keeps getting overloaded, so I’d like to monitor power usage in order to rewire my house for a more even power distribution - I also wanted to identify devices that consume large amounts of power during standby so I can disconnect them when they are not being used.

You multiply by 0.001 – because those numbers from ct1 - ct4 are the power in watts.
CT1 is showing a little less than 200 W - 0.2 kW.

The temperature of 300 °C is an error value, it means you did not have a sensor connected when you powered up.

pulses is the count of pulses from your meter (if you are using that). The units of each pulse will be kWh, but the scale will depend on your meter - it will be printed on the front, for example 1000 pulses per kWh is a common value.

1 Like

Thanks, I was actually preparing for some sinus cosinus voodoo magic, but that’s great news! I just need to drop yesterday’s data from the database because I had 1 ct sensor connected the wrong way, but I’ll keep collecting then.

Really, really appreciate the help @Robert.Wall & the 3phase firmware you have developed.

My meters are outside, so I’m not using pulses - I may recompile the firmware with pulsecount disabled & the rest of the temperature sensors disabled, since I only use one. Will let you know if I can get the UART fixed.

1 Like

Hi guys,
How do I create a feed to have the 3 inputs summed (ct1+ct2+ct3) in order to see the total power consumption with my 3-phase (4 wires) Emontx + emonESP at Emoncms.org, please?

For reasons connected with timing, I’m told the best way is to send the first two powers to feeds, then in the processing for the third power, add the first and second feeds and send the total to Total_Power.

But, if the cost of the extra feeds is a concern, you could try adding the first and second inputs to the third, and then send the sum to a feed.

Or, as you probably have a programmer, you could edit the sketch to add the three powers in there and send the total - either instead of the three separate values, or as well as, to emoncms.org.
Around line 952, you’d need to add something like:

    Serial.print(F(",total:")); Serial.print(realPower1 + realPower2 + realPower3);

Thanks a lot! :slight_smile:

1 Like