EmonTxV3 Continuous Monitoring Firmware (v1.0-beta)

The EmonTxV3 Continuous Monitoring firmware is now available to download on github here: GitHub - openenergymonitor/EmonTxV3CM: EmonTxV3 Continuous Monitoring Firmware (Default shipped EmonTxV3 firmware) (version 1.0-beta).

The firmware is a replacement for the standard EmonTxV3 Discrete Sampling firmware that comes pre-programmed on the EmonTxV3 units that we send out. It uses the EmonLibCM library maintained by @Robert.Wall, available here:

EmonTxV3CM provides better results than the discrete sampling firmware which uses the emonLib library, especially where PV Diverters or other fast changing loads are in use. The EmonLibCM library continuously measures in the background the voltage and all the current input channels in turn and calculates a true average quantity for each.

Features

  • Continuous Monitoring on all four EmonTxV3 CT channels and ACAC Voltage input channel.
  • Real power (Watts) and cumulative energy (Watt-hours) measurement per CT channel.
  • RMS Voltage measurement.
  • Support for 3x DS18B20 temperature sensors.
  • Support for pulse counting.
  • Resulting readings transmitted via RFM radio and printed to serial.
  • Serial configuration of RFM radio and calibration values.

How to use

  1. Either download directly or use ā€˜git cloneā€™ to download this repository into a directory called EmonTxV3CM in your Arduino Sketchbook directory. Ensure that both EmonTxV3CM.ino and config.ino are in the same folder.

  2. Either download directly or use ā€˜git cloneā€™ to download the EmonLibCM library into your Arduino Libraries directory.

  3. Either download directly or use ā€˜git cloneā€™ to download the JeeLib library into your Arduino Libraries directory.

  4. Open the Arduino IDE (or restart, to reload the libraries). Open the EmonTxV3CM firmware, ensure that both EmonTxV3CM.ino and config.ino are present as two tabs in the IDE when the firmware is open.

  5. Use a 5v USB to UART cable to upload the firmware to emonTx.

  6. Configure EmonHub on the receiving base station to decode the RFM data packet using the decoder below, note data whitening setting.

Todo: PlatformIO compilation and upload instructions.

EmonHub Decoder

To decode the data packet sent by this firmware, add the following emonhub node configuration to /etc/emonhub/emonhub.conf (configurable via the web interface on an EmonBase or EmonPi).

Note: This firmware uses data whitening to improve the reliability of the data transmission. A standard pattern of 1s and 0s is overlayed on the underlying data, this prevents sync issues that result from too many zero values in a packet. When the packet is received it is decoded by emonhub. The ā€˜whitening = 1ā€™ is required to tell emonhub to decode the packet correctly.

[[8]]
  nodename = emontx8
  [[[rx]]]
    names = MSG, Vrms, P1, P2, P3, P4, E1, E2, E3, E4, T1, T2, T3, pulse
    datacodes = L,h,h,h,h,h,L,L,L,L,h,h,h,L
    scales = 1,0.01,1,1,1,1,1,1,1,1,0.01,0.01,0.01,1
    units = n,V,W,W,W,W,Wh,Wh,Wh,Wh,C,C,C,p
    whitening = 1

Further Development

Serial configuration currently supports configuration of the RFM radio and current & voltage channels. Serial configuration of temperature sensors, pulse input and data log period is currently disabled. See commented sections of code. Further work and testing is required to enable these features.

Licence

This firmware example is open source, licensed under GNU General Public License v3.0.


We will be switching over to using this firmware as standard on the EmonTx units that we send out in due course after a period of open beta testing.

2 Likes

Thanks for this, @TrystanLea You mention a couple of directories:

  • Arduino Sketchbook directory
  • Arduino Libraries directory

What are these and where is the documentation that describes this environment, please?

You also mention ā€œSupport for 3x DS18B20 temperature sensorsā€. I believe the original firmware supports six DS18B20, so why the reduction? Has the packet format changed somehow?

edit:oh and what is ā€œSerial configurationā€ please?

Hello @djh, the best place to start with the Arduino IDE is their get started page here https://www.arduino.cc/en/Guide/HomePage we also have additional notes here that may be useful Learn | OpenEnergyMonitor.

This firmware includes 4x cumulative energy values (as 4 byte longs) in the radio payload which makes it longer than the discrete sampling firmware, a longer payload requires more transmit energy and increases chance of collisions. Reliability has been generally better with shorter radio payloads, especially if a lot of zeros are in the packet, that said we have since introduced a data whitening feature which addresses that issue. It may be able to support 6x temperature sensors without a significant issue. DS18B20 temperature sensor configuration including number of sensors, sensor addresses etc is something we will consider for future versions.

Serial configuration is the ability to configure the EmonTx without uploading new firmware via the serial port, typically using the serial monitor in the Arduino IDE. When you start an EmonTx with a USB to UART cable connected, and the Serial monitor open, it prints out the instructions to enter serial configuration mode as well as all the configuration options currently supported.

1 Like

Iā€™m running an older firmware version that I modified years ago with 8 sensors. It actually delays the data sending I think (I get data every 11 seconds). I keep meaning to load ESPHome onto an ESP8266 and just get the data using that and reset the EmonTX to a standard firmware just never get around to it. For the cost I think using a separate ESP for the temperature data is probably a better solution and so simple now with ESPHome.

1 Like

Its relatively straightforward to modify the firmware to support more temperature sensors. In EmonTxV3CM.ino: https://github.com/openenergymonitor/EmonTxV3CM/blob/master/EmonTxV3CM.ino change as required:

Line 55:

int T1,T2,T3;

Line 61:

DeviceAddress allAddresses[3]; 

Line 69:

int allTemps[3];

Line 213:

EmonLibCM_setTemperatureMaxCount(3); 

and lines 280 to 282:

emontx.T1 = allTemps[0];
emontx.T2 = allTemps[1];
emontx.T3 = allTemps[2];

Thereā€™s also lines 326 to 328 for printing to serial :slight_smile:

Then add the additional temperature sensors to the emonhub decoder, add T4, T5 etc to names and corresponding datacodes (h), scales (0.01) and units (C) - to reflect the desired number of sensors.

Iā€™ve added making the configuration of the number of temperature sensors easier to the issue list for a future version Add configurable number of temperature sensors Ā· Issue #2 Ā· openenergymonitor/EmonTxV3CM Ā· GitHub

Thanks for the explanations, @TrystanLea I hadnā€™t realized those terms were standard IDE things.

What is the purpose of the cumulative energy values? How do they reconcile with the values held on an emonBase? (and backed up from there).

Thanks for the suggestion @borpin but homebrew hardware is well beyond my goals :slight_smile:

1 Like

I donā€™t really know what Iā€™m doing but Iā€™ve tried to follow the instructions above as far as the downloading. I then tried Verify

EmonLibCM-master/emonLibCM.cpp:44:21: fatal error: OneWire.h: No such file or directory

It seems I need a Onewire library. The Library Manager offers me v2.3.4 of a library called exactly that, so I presumed thatā€™s what I need. But after adding it I see:

EmonLibCM-master/emonLibCM.cpp:45:159: fatal error: DallasTemperature.h: No such file or directory

So I suppose I need some other library?

edit: So I looked in the CM lib code and went to Dallas Temperature Control Library - Miles Burton - Innovative engineering for pretty much anything but that says to use github for download GitHub - milesburton/Arduino-Temperature-Control-Library: Arduino plug and go library for the Maxim (previously Dallas) DS18B20 (and similar) temperature ICs (and that has a version that was last updated 5 days ago) and to use a Onewire library from OneWire Arduino Library, connecting 1-wire devices (DS18S20, etc) to Teensy rather than the standard one, which in turn points to GitHub - PaulStoffregen/OneWire: Library for Dallas/Maxim 1-Wire Chips . That has a version of 2.3.4 set sometime last year and a latest update 19 days ago. So Iā€™m even more concerned and confused now about what version of libraries I should be using?

Correct. You need both of them.

After you install the Onewire library via the Library Manager,
download the Temperature Control Library zip file from Miles Burtonā€™s github page.
(You donā€™t need to unzip it)

https://github.com/milesburton/Arduino-Temperature-Control-Library/archive/master.zip

To install the library:

  • Start the Arduino IDE.
  • Pull down the Sketch menu
  • Select Include Library
  • From the sub-menu that pops up, select Add .ZIP Library
  • Select the zip file you downloaded

The Arduino IDE will need to be restarted in order to recognize the changes.

N.B. - the steps above are for the Arduino IDE running on Windows.

1 Like

FWIW, I didnā€™t need to restart the IDE; just including it from the menu seems to be enough. Iā€™m on linux. I am a bit concerned about version control. Iā€™ve essentially just got a random selection of versions.

So Iā€™m not missing header files now, instead I get:

EmonTxV3CM/config.ino: In function ā€˜void getCalibration()ā€™:
config:343:53: error: ā€˜EmonLibCM_ReCalibrate_VChannelā€™ was not declared in this scope
case 0 : EmonLibCM_ReCalibrate_VChannel(k2);
^
config:347:60: error: ā€˜EmonLibCM_ReCalibrate_IChannelā€™ was not declared in this scope
case 1 : EmonLibCM_ReCalibrate_IChannel(1, k2, k3);
^

1 Like

Dave, as a new user, it might be worth you updating the readme.md file to expalin what is needed when starting from scratch. It is often difficult for those using it all the time to know what is needed for new users.

Yes, that sounds sensible. Iā€™ll be happy to do that once I actually get it to compile!

2 Likes

6 posts were split to a new topic: 3-phase in Austria

Hi Dave,

I have the same issue, did you get to the bottom of it?

Best Regards

James

Not yet. I believe weā€™re waiting for @Robert.Wall to update emonCM lib.

Ah OK, Thankyou!

edit, thanks to your hint, i now have this compiling. the 2 problems were i was using version 1 continuos sampling, not version 2.got it here.EmonLibCM - Version 2.2.1 (Released 30/10/2021)

The compiler was also using the wrong one wire librarys.

Hope this helps!

Best Regards,

James

Hi trystan,

After I uploaded the sketch, I loaded default calibration to eeprom (entering config mode) but sketch does not detect any power consumption.
> Calibration:
> vCal = 268.97
> i1Cal = 90.90
> i1Lead = 4.20
> i2Cal = 90.90
> i2Lead = 4.20
> i3Cal = 90.90
> i3Lead = 4.20
> i4Cal = 16.67
> i4Lead = 1.00
> Temperature Sensors found = 0 of 1
> Temperature measurement is NOT enabled.
values printed:

CT1 detected, i1Cal:90.90
AC missing
MSG:1,Vrms:2.01,P1:0,E1:0,T1:23.50,pulse:1
MSG:2,Vrms:0.00,P1:0,E1:0,T1:23.50,pulse:1
MSG:3,Vrms:0.00,P1:0,E1:0,T1:23.37,pulse:1
MSG:4,Vrms:0.00,P1:0,E1:0,T1:23.50,pulse:1

Is something Iā€™ve missed?

Note: with sketch emonTxV3.4 Discrete Sampling it does show values of consumption:
ct1:73,ct2:0,ct3:0,ct4:0,vrms:536,pulse:0,t0:235
ct1:67,ct2:0,ct3:0,ct4:0,vrms:536,pulse:0,t0:235
ct1:65,ct2:0,ct3:0,ct4:0,vrms:536,pulse:0,t0:235
ct1:64,ct2:0,ct3:0,ct4:0,vrms:536,pulse:0,t0:235

Thatā€™s your problem. You canā€™t calculate power without knowing the voltage.

Trystanā€™s sketch (or more precisely, the version Iā€™m looking at) doesnā€™t allow the possibility of using a nominal assumed voltage to show an estimate of apparent power, which might be what your DS sketch is doing.

(Should I be guessing that your emonTx is running on battery power? If so, you cannot expect the battery to last very long using the CM sketch, because - like the name suggests - itā€™s working continuously, not for just 200 ms every 10 s as the DS sketch does.)

It seems to me that the EU voltage adapter calibration value is missing from the sketch. Is it the same as for the non-CM version, maybe?

The CM library default calibration constants are as detailed in the accompanying documentation.

The nominal calibration values are the same, because the hardware is the same.

The sketch can override those starting values, if necessary. I didnā€™t create that sketch, Iā€™m not sure what the values incorporated in it are. I believe it does include the on-line serial calibration, but not all the possible variables are catered for.