Firmware

The emonTx v4 firmware can be edited and compiled using PlatformIO (recommended) or Arduino IDE with DxCore installed. DxCore is an Arduino core for the AVR-DB microcontroller range, developed by SpenceKonde.

Available Firmware

EmonTxV4: Single phase, 6 CT channel, continuous sampling, cumulative energy persisted to EEPROM, LowPowerLabs RFM69 radio format (JeeLib also supported via #define), 3x DS18B20 temperature sensors supported by default, serial configuration and data output.

Pre-compiled hex: https://github.com/openenergymonitor/emontx4/releases/tag/1.5.7

EmonTxV4_6x_temperature: As above but configured to read and transmit 6x DS18B20 temperature sensor readings. Please see EmonTx4 DS18B20 Temperature sensing & firmware release 1.5.7 for note on performance implications that also apply to the above 3x temperature sensor example.

EmonTxV4_heatpump: Single phase, 3 CT channel, continuous sampling, cumulative energy persisted to EEPROM, LowPowerLabs RFM69 radio format (JeeLib also supported via #define), 4x DS18B20 temperature sensors supported by default, serial configuration and data output. Designed for use with Sika VFS flow meter, measures the analog voltage output to calculate flow rate, which combined with flow and return temperature measurements allow calculation of heat pump heat output.

EmonTxV4_DB_3phase_6CT: 3-phase 6 CT channel firmware using the emonLibDB library, continuous sampling, cumulative energy persisted to EEPROM, LowPowerLabs RFM69 radio format (JeeLib also supported via #define). Serial configuration and data output. Please note that temperature sensing is not supported.

EmonTx4_DB_12CT_serial: 12 CT channel firmware using the emonLibDB library, continuous sampling. Serial output only for use with EmonESP ESP8266 WiFi module or direct USB connection to an emonBase/emonPi.

Upload pre-compiled using EmonScripts emonupload2 tool

On the emonPi/emonBase ensure EmonScripts is updated to latest version then run emonupload2 tool

/opt/openenergymonitor/EmonScripts/emonupload2.py

Select hardware then firmware version

Select hardware:
  1. emonTx4
  2. emonPi
  3. emonTx3
  4. rfm69pi
  5. rfm12pi
  6. emonTH2
  7. emonTH1
Enter number:1

Select firmware:
1. emonTxV4_LPL
2. emonTxV4_JeeLib_Native
3. emonTxV4_JeeLib_Classic
4. EmonTxV4_DB_3phase_6CT

emonupload2 tool can also be run on any other linux computer by cloning the EmonScripts repo then running the emonupload2.py python script. Python3 required

git clone https://github.com/openenergymonitor/EmonScripts

Upload pre-compiled manually using avrdude

Alternatively to upload the same pre-compiled firmware via command line on emonPi / emonBase:

avrdude -C/opt/openenergymonitor/EmonScripts/update/avrdude.conf -v -pavr128db48 -carduino -D -P/dev/ttyUSB0 -b115200 -Uflash:w:EmonTxV4_LPL.hex:i 

Or using differant computer, ensure avrdude.conf has avr128db48 entry i.e DxCore see below instructions

avrdude -Cavrdude.conf -v -pavr128db48 -carduino -D -P/dev/ttyUSB0 -b115200 -Uflash:w:EmonTxV4_LPL.hex:i 

You will need avrdude installed (tested on version 6.3-2017) and the custom DxCore avrdude.conf. This can be downloaded here: DxCore avrdude.conf.

How to compile and upload firmware

Compile and Upload using Arduino IDE

If you don’t already have the Arduino IDE it can be downloaded from here:
https://www.arduino.cc/en/software

Once you have the IDE installed, you then need to install Spence Konde’s DxCore. This can be done by first pasting the following board manager URL in Arduino IDE > File > Preferences:

http://drazzy.com/package_drazzy.com_index.json

Then navigating to: Tools > Boards > Boards Manager, Select “DxCore by Spence Konde” and click Install.

install_dxcore.png

For more information on DxCore installation see: https://github.com/SpenceKonde/DxCore/blob/master/Installation.md.

Libraries

Locate or create your Arduino Sketchbook directory (location found in Arduino preferences). If it doesnt already exist, create a directory called libraries in the Sketchbook directory and install the following libraries:

1. Download EmonLibCM library (avrdb branch)
https://github.com/openenergymonitor/EmonLibCM/tree/avrdb

2. Download EmonLibDB library (main branch)
https://github.com/openenergymonitor/emonLibDB

2. Download emonEProm library (avrdb branch)
https://github.com/openenergymonitor/emonEProm/tree/avrdb

3. Download RFM69_LPL library (main branch)
https://github.com/openenergymonitor/RFM69_LPL

4. Download RFM69_JeeLib library (avrdb branch)
https://github.com/openenergymonitor/RFM69_JeeLib/tree/avrdb

5. Download DxCore SpenceKonde OneWire library:
https://github.com/SpenceKonde/OneWire

Compilation settings:

With DxCore and the libraries installed the firmware should then compile.

Under Tools, select the following configuration options:

  • Select Board “AVR DB-series (Optiboot)”

  • Select Chip: AVR128DB48

  • Clock Speed: 24 MHz Crystal

  • Bootloader serial port: UART3: TXPB0, RXPB1

Select Board “AVR DB-series (Optiboot)”

firmware_dxcore_option.png

Select Chip: AVR128DB48

firmware_core_option.png

Bootloader serial port: UART3: TXPB0, RXPB1

firmware_uart_option.png