EmonTx4 Configuration by Direct Serial - notes

I wanted recently to alter the wireless node ID on my emonTx4. I had a few hiccups before I succeeded so I thought I would add some notes here for other Linux users.

Altering the configuration of the EmonTx4 by using the serial port is documented at:

https://docs.openenergymonitor.org/emontx4/configuration.html#using-the-web-tool

It can be done by using the web tool, which requires a WebSerial compatible internet browser. I use the Firefox browser, which is not WebSerial compatible, so this method was unsuitable for me.

The second method is the direct serial method. This means connecting the USB-C port on the emonTx to a USB-A port on the computer, as described in the above Docs page (including getting the USB-C connector the right way round). You also need to run a suitable terminal program on the computer. I use Cutecom on Linux. My settings are:

Port: /dev/ttyUSB0, Baud rate: 115200, 8 data bits, 1 Stop bit, no Flow control, no Parity

When you open communications from the computer to the emonTx4, the DTR signal from the computer resets the emonTx4, so you should see the start-up configuration information from the emonTx4 in the terminal (my emonTx4 has three DS18B20 temperature sensors attached) :

emonTx V4 CM Continuous Monitoring V1.5.7
OpenEnergyMonitor.org
No EEPROM config
Settings:
Band 433 MHz, Group 210, Node 17, 7 dBm
Calibration:
vCal = 807.86
assumedV = 240.00
i1Cal = 300.30
i1Lead = 3.20
i2Cal = 150.15
i2Lead = 3.20
i3Cal = 150.15
i3Lead = 3.20
i4Cal = 60.06
i4Lead = 3.20
i5Cal = 60.06
i5Lead = 3.20
i6Cal = 60.06
i6Lead = 3.20
datalog = 9.80
pulses = 1
pulse period = 100
RF on
temp_enable = 1
JSON Format Off
RFM69CW  Freq: 433MHz Group: 210 Node: 17 
RadioFormat: LowPowerLabs
Reference voltage calibration: 1.0259
Temperature Sensors found = 3 of 3, with addresses...
28 CC 36 75 D0 01 3C 0D 
28 36 5A 75 D0 01 3C 80 
28 49 DD 75 D0 01 3C A6 

Temperature measurement is enabled.

AC missing - Apparent Power calc enabled, assuming 240.00 V

then the emonTx4 will start measuring:

MSG:1,Vrms:240.00,P1:432,P2:216,P3:217,P4:86,P5:87,P6:87,E1:0,E2:0,E3:0,E4:0,E5:0,E6:0,T1:14.75,T2:14.50,T3:14.50,pulse:0
MSG:2,Vrms:240.00,P1:12,P2:5,P3:5,P4:2,P5:3,P6:2,E1:0,E2:0,E3:0,E4:0,E5:0,E6:0,T1:14.62,T2:14.50,T3:14.50,pulse:0
MSG:3,Vrms:240.00,P1:11,P2:5,P3:5,P4:2,P5:3,P6:2,E1:0,E2:0,E3:0,E4:0,E5:0,E6:0,T1:14.75,T2:14.50,T3:14.50,pulse:0
MSG:4,Vrms:240.00,P1:11,P2:5,P3:5,P4:2,P5:3,P6:2,E1:0,E2:0,E3:0,E4:0,E5:0,E6:0,T1:14.75,T2:14.50,T3:14.50,pulse:0

Then you can start entering the configuration commands as listed in the above Docs page. This is where my hiccup occurred!

Using the correct command terminator is necessary.
\n is the new line character, also known as LF (line feed).
\r is the return character, also known as CR (carriage return).
The line terminator(s) are usually sent when the computer’s Enter key is pressed.

The emonTx4 commands need to be in the following format, eg for the ‘list the settings’ command l:

l\n (two characters, “l” then “\n” (LF), no spaces)

By default terminal programs will often send \r \n (CR LF) as a line terminator when the Enter key is pressed, so would send:

l\r\n

The emonTx4 command parser will see l\r and ignore it as being invalid.

So you need to set your line terminator in the terminal program to be \n (LF) for the commands to be accepted. It is easy to do this in Cutecom - choose “LF” on the Input line.

Note: If using the putty terminal program, it seems you need to type l cntrl+J (without an Enter) to send l/n. Setting “Local Echo” (in the Terminal category) to “Force on” allows you to see the transmitted characters (not including control characters) in the terminal window.

Apologies to all if I have got something wrong, or missed the obvious!