Connect an EmonTx v3 to RaspberryPI via serial

The standard OEM system setup is to use a RaspberryPI base station next to your internet router connected via Ethernet, and an emonTx near your meter cabinet with a wireless link between them. In some instances it may make sense to connect the emonTx directly to the RaspberryPI via a serial link.

Both the RaspberryPI and emonTx v3 run at 3.3V, so the serial RX and TX lines can be connected without issue. The RaspberryPI can power the emonTx as well.

In the picture below, the RaspberryPI's 5V supply is connected via the red wire to the emontx 5V input, which is then regulated by the emonTx to 3.3V. The ground connection is the black wire, and the data going from the emonTx to the RaspberryPI is the green wire. An additional wire could be connected to allow the RaspberryPI to send data to the emonTx, but in this example, it's not needed.

Note: connecting the emonTx via serial to the RaspberryPI is not part of the standard configuration, so this documentation may go out of date as changes are made to the emonTx and RaspberryPI over time, and may be a bit more involved than the wireless rfm12/69 approach.

Useful hardware pin-out reference documentation

Reference design for the RaspberryPI adapter board which connects via serial to the RaspberryPI

RaspberryPi GPIO pinout:

EmonTx v3.2 schematic

EmonTx v3.4 schematic
Note: The FTDI connector Tx and Rx pins are reversed on the EmonTx v3.4 PCB legend and on the Schematic. Data is received by the emonTx on the Tx pin and transmitted by the emonTx on the Rx pin.

EmonTx Firmware

A simple, direct serial output Arduino sketch/firmware for the emonTx v3 can be found here:

This prints power values and mains voltage to the serial port as space separated values:

100 100 200 240
105 100 200 242


Where the values are: CT1 Power, CT2 Power, CT3 Power, CT4 Power, Mains Voltage

The direct serial output Arduino sketch/firmware for the emonTx v3 can be uploaded with a USB-to- serial adapter. Once uploaded, use the Arduino IDE serial monitor - set to 9600 bps - to verify the emonTx is printing values to the serial port.

RaspberryPI to emoncms link

If you just want to forward the emonTx data to a remote emoncms, thiat can be done with emonHub on the RaspberryPi

To install emonHub on the RaspberryPi run:

git clone ~/dev-emonhub && ~/dev-emonhub/install

See the emonHub Github page if the above does not work.

The next part involves setting up emonHub in a manner similar to the way emonHub is used in the HomeEnergyMonitor documentation here:

If you have an pre-built OpenEnergyMonitor sd card, you will find the emonHub configuration file on the boot partition. To edit it, enter:

sudo nano /boot/emonhub.conf

If you installed emonHub yourself on a generic raspbian install, the emonhub.conf file can be found in the /etc/emonhub directory.

sudo nano /etc/emonhub/emonhub.conf

Add the serial config to the emonhub.conf interfacers section:

    type = EmonHubSerialInterfacer
        com_port = /dev/ttyAMA0
        com_baud = 9600

Next, add the location and apikey of the emoncms server you're posting to in the reporters section.

    type = EmonHubEmoncmsReporter
        url = http://localhost/emoncms
        apikey = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

It's worth noting the standard emonTx firmware which has all the rfm12b radio packet sending code, also prints a space separated string to its serial port which should work the same as the cut down serial only example above, although you'll still be transmitting radio packets.

Here's a picture of both units in their cases, connected, a tidy system!

Pi case: