OpenEnergyMonitor Community

Three Phase kWh data logger using emon tx- base

I need a Kwh data logger which will record half-hourly kWh data for a period of 6 months or more to local storage.

This will be for a number of different solar PV projects in West Africa, so the system must not require any internet connectivity. in some locations, there won’t even be a cellular connection.

I am happy to manually retrieve the data from the site so do not require any remote monitoring.

Some sites are three-phase, 4 wire I believe but would be good to have 3 wire capabilities.

Can someone provide advice on the best solution please? im new to the open energy monitor kit, and not handy with a Raspberry Pi.

Our standard offering is unlikely to fit your requirements exactly, but with a few small modifications I think we could solve your problem.

I would propose an emonTx V3.4, with a wired serial connection to a Raspberry Pi.

The emonTx with the standard software is most likely not capable of averaging over a 30 minute period - our normal averaging period is 10 s, but our standard single-phase sketch already sends the accumulated Wh values every 10 s, and with a small addition to the code, the 3-phase sketch can do likewise. The 3-phase sketch can be set up for 3-wire (treating the supply as 2 phases & neutral) or 4-wire systems.

The Raspberry Pi would run our logging and display software emonCMS, and record the data to its SD card (and, if an Internet connection is available, to a base server somewhere in the world also running emonCMS). emonCMS is already capable of recording data at ½-hourly intervals, so you would have on record the accumulated value every half hour. emonCMS is available from the shop on an SD card, or you can download an image and flash your own SD cards, as you prefer.

So for each installation I think you need:
1-off emonTx
1-off a.c. adapter to suit the local voltage - line-neutral for single phase and 4-wire 3-phase, or line-line for 3-wire 3-phase,
1-off, 2-off or 3-off current transformer as appropriate,
1-off Raspberry Pi & case
5 V Raspberry Pi power supply
1-off emonCMS on a SD Card
You will need to make up a 3-wire serial connection to connect the emonTx to the Raspberry Pi.

To load and configure the emonTx’s and set up emonCMS
A portable computer with the Arduino IDE loaded,
1-off Programmer & lead.

Depending on the quality of the electricity supply you are monitoring, you might like to consider a battery backup/UPS for the Raspberry Pi. I’m afraid I have no experience of those, so I cannot advise you, but I think one of my colleagues here might be able to help in that regard.

As Internet time won’t be available, you might also want a real-time clock on the Raspberry Pi too.

The EmonCMS Agile App, generates half-hour data. I was going to suggest to @TrystanLea, that there could be a means of downloading this half hour data which would then suit this need (although the 6 months may be a challenge as it will be a large data set).

Perhaps a post-process method @TrystanLea?

1 Like

Thanks a lot for your considered reply,

yes, 10 second data would be fine I can post-process, what file format does the data come in on the SD card?

OK, so I would need a to modify a raspberry PI so it has an internal clock and a backup power supply?

Could you provide the rasbery PI with the software preloaded, or do i need to buy this separately?

The power on-site is unreliable so will be turning off several times a day, what impact would this have on the raspberry pi if there is no backup power supply? obviously, data is only required when the Raspberry Pi is on, but i guess if no internet time is available then the time stamp will be incorrect.

I’m not too great with raspberry Pis and all that more a power systems engineer. How much knowledge will i need to set this up and working,

Also, once it has been set up once, how easy will it be for others to use, if given instructions? as several different people will use this kit with varying knowledge.

Thanks again

Ah, I didn’t realise that you could do that, in which case an absolutely standard installation (as far as the emonTx and emonCMS itself is concerned) will be fine. Given power values, emonCMS can process those into accumulated Wh or kWh and store those. The data format is our own, fully documented in the ‘Learn’ section here. Learn→Electricity Monitoring→Timeseries

That is what I anticipated. “what impact” - in short, I think a very bad one - quite possibly fatal for the card and any data on it, so a UPS that can do an orderly shutdown of the Pi would be a very sensible precaution, probably necessary. And I presumed that accurate time stamps would be at least desirable, if not necessary also.
I’m not sure how the PHPFINA database would cope, I suspect you would need the timeseries one. @TrystanLea ?

I was drives and controls principally, before I retired. Some knowledge is the honest answer. Setting up emonCMS is reasonably straightforward once you’ve cracked the basic thinking, but I’m not an emonCMS expert, so I can’t tell you too much about the niceties and details. And a basic knowledge of the ‘C’ language will help when customising the emonTx.

As for others using - it depends on how good the instructions are and what they will be doing! If it’s a matter of taking the SD card out of the Pi and putting a new one in, then all they really need to know is not to pull the card out until the Pi’s been shut down properly, which can be done from the Web interface, or which an intelligent UPS should do for you.

Would i need to customize the emon Tx for this application?

For the single-phase installations, the default sketch should work ‘out of the box’.

For the three-phase, there are just too many variables for that to work. The way the software is written, it’s the same program for all options. You need to choose which you need, edit a setting and then compile and upload to the emonTx.

E.g. for 3-wire or 4-wire, that particular switch is

#define WIRES 4-WIRE      // either 4-WIRE (default, measure voltage L1 - N) or 3-WIRE (no neutral, measure voltage L1 - L2)

so for a 3-wire supply, you change it to

#define WIRES 3-WIRE      // either 4-WIRE (default, measure voltage L1 - N) or 3-WIRE (no neutral, measure voltage L1 - L2)

(Any other way, and it could be a case of which one to choose out of many dozen (if not more), if all the possible combinations were each a separate sketch.)

Thanks again for your support,

So in summary I could use the EmonTX + Pi solution. but I would need to add an internal clock and UPS to the Pi my self (you cant support on this)

and the user would need a laptop and basic C programming skills to set it up at each site, selecting between 2 wire 3 wire or 4 wire supply.


I think a real-time clock would dispense with any doubts about the time period that a set of samples belonged to. I don’t know anything about that nor the UPS, but there are people here who have done that - maybe not the same person though.

and many other parameters - some might always be correct for all sites, some might not. Will the same set of equipment travel around, or will you have several sets? If the latter, a “3-wire” set and a “4-wire” set could make things easier, and of course you could set up any number of sketches and just load the right one -assuming you know the conditions at each monitoring site.

Search on this forum for “RTC” for idea’s there. There are serial and I2C based RTC’s, the gpio serial port is used on both an emonpi and emonbase. The I2C is also used on a emonpi, but it is still possible to do. There is a header on the emonpi board specifically for a I2C RTC and a guide in the wiki on how to fit.

Some I2C RTC can be fitted over pin’s 1,3,5,7,9 of the Pi’s gpio directly or piggy backing a rfm2pi type board with a bit of soldering. I’ve done it and there was also a more recent discussion on here to about fitting “stacking” headers to an RFM2pi to accommodate an RTC.

Regards UPS you can again search on here, many people use a variety of devices. For many years I have used a Yuasa burglar alarm type lead 12v battery and mains trickle charger to power my 5v devices via a voltage dropper and my main WiFi router via 12v so I stay connected in a power cut. I also only charge the battery during off peak or spare pv production :grin:

1 Like

I would suggest using a serial connected setup rather than an RFM one and the 2IC version of an RTC alongside.

I’d suggest powering the Pi and the EmonTX separately so the UPS only drives the Pi (Zero)


  1. you could edit, complie and load the Firmware locally (need to do it the first time with internet connection)
  2. Cheaper (no RFM board)


  1. None I can think of (but could be wrong)

For UPS, depending on time off, I’d use a LiPo setup.

This comes with an RTC as well so it would be perfect.

Julian posted a good write up of what he did. Avoiding wireless connections - EmonTX serial RPiZero solution

The only difference is not connecting ground and power via the UART.

1 Like

Agreed, unless there’s a requirement to know the behaviour of the supply as it dies and comes back.

1 Like

As mine does, I get a notification if the power is off more than 20mins, but no point in doing that unless there is a route out, e.g. gsm or the lan is still up as is the case with mine. Still, keeping record of outages may come in useful if they ever become too frequent.

Except you would have that as there would be no data recorded by EmonCMS and I think that PiJuice sends messages to the Pi telling it, which again could be logged.

The main downside I was thinking of was that powering both would shorten how long the UPS ran for.

That is only really an issue if you have limited UPS battery, many “PI UPS” only have enough juice to run the Pi alone for a few minuets, just enough time to do a proper shutdown. In that case yes. But the emontx draws so little that if you have a decent size battery not powering the emontx will only add a few more minuets maybe an extra 10% if you’re lucky. With mine powering the router too, it makes next to no difference if an emontx is connected. I matters of course what the emontx is doing, if it’s got 6 temp sensors and pulse counting with RFM then possibly an issue, but serial connected CT/VT monitoring only, with no rfm is negligible. If the emontx is serially connected, it would be better to treat them as a pair (one unit) or the emontx powering down might upset emonhub, plus that would mean separate supplies too.

That isn’t a good habit unless confirmed by something else (eg if PiJuice does send notice etc) because any missing data would then suggest a power outage and become less reliable.

But much of this might be considered OTT it depends on your needs/wishes and how much you are willing to put into it (effort and expense).

I only went the route I did because it seems forever for the LAN to comeback up after a micro outage and I was running a Pi + hdd emoncms server for many sites, so downtime was a consideration. I have since moved the server to the cloud and used the UPS setup for my IoT.

The current drawn by the emonTx, using…

Absolutely. The emonTx will draw about 8.5 mA continuously, add about 1.5 mA while the LED is flashing, assuming you don’t use the radio. If you do add the radio, add a further 16 mA for the 8 ms while it transmits the data once every 10 s.


Many thanks, everyone for your support- i think I’m ready to give this ago as the other alternatives are the market are way too expensive. if possible i will need a bit of support from this community as i haven’t got a clue with Pis, serial connects etc, im sorry in advance for any stupid questions

I am happy to purchase a fairly large UPS -12,000 mAh - if I understand you correctly the whole system draws very low power ( <20mA) on average therefore am I safe to assume that the system would theoretically last 24 days on the UPS. This should be comfortably fine for most of the applications I plan to use it.

Just a thought on this, I don’t actually need the Pi to do anything when there is no power from the grid (as there won’t be anything to measure). so could I set it up so that when the system losses power the Pi goes into standby or turns off and only turns its self back on when the grid powers up again?

as I am using the UPS and RTC from Pijuice, will I need to make any changes to the firmware to make this work?

and can someone please point me in the right direction with what I need for the three-wire serial connection?

Finally, see the list of material below, i would be very grateful if someone could check these for me?

1 x emonTx
1 x AC-AC voltage sensor (UK Plug) 240 V 50 Hz (Ghana uses UK plug system, and all the networks we will be monitoring will be 4 wire.
4 x current transformer 100A
1-off Raspberry Pi & case ( do i buy this from this website or separately i couldn’t see it in the shop)
1 x 5 V Raspberry Pi power supply
1 x emonCMS on a SD Card
1 x three-wire serial connection between tx and pi ( could someone point me in the right direction for this?)
1 x 12Ah UPS from

Thanks again

No, I’m afraid I think you’ve got that wrong. The emonTx will draw that sort of current in addition to the current that the Pi needs, which will be a lot more than that - see and note those are “typical” numbers, so not guaranteed. So if you turn the radio transmitter off, the emonTx current at 8 - 10 mA is negligible compared to the Pi’s. But, as long as the battery lasts long enough to do a controlled shutdown and leave enough to run its own controller and the RTC until power is restored for long enough to recharge the battery, that should be satisfactory.

Indeed you could - if the UPS and the Pi are willing to talk to one another, and that looks to be the case as the link says it will do a managed shut-down. It might be worth confirming that with PiJuice.

I can’t answer that. I think it’s one for @pb66 or @borpin


Note a very big problem that continues to confuse everyone: Tx and Rx are swapped on the emonTx pcb, so as I’ve written so many times here, the emonTx is sending data on the pin labelled “Rx”, and it’s looking for data coming in on the pin labelled “Tx”. That’s contrary to convention (unless the emonTx is a modem!).

Nope. There’s no need for a c.t. on the neutral - all it tells you is the imbalance current (i.e. the vector sum of the 3 line currents) unless there’s an earth fault. And you shouldn’t be using the emonTx for protection. So 3-off only.

Most people will make this up themselves, or use the jumper leads illustrated.

Will you want a box to enclose and protect everything?
Will you want a programmer and lead to set up the emonTx - although adding more wires means you could use the emonPi as a serial programmer - with a slightly increased “social distancing” as you’ll presumably be working from a laptop via the Pi to the emonTx. It’s easy enough once set up and you know what you’re doing, until then (like everything else), it can be confusing.

I don’t think our shop sells the Raspberry Pi by itself, and I think it will definitely not sell a case suitable for the Shield and the UPS, and if you’re battery charging as well as running the Pi, you probably need the higher-rated official Raspberry 5 V PSU.

Other than that, I think your list is OK.

Assume nothing. I suspect the only way of knowing is to try one and see what happens - perhaps report back so others will then know.

Not to the firmware, but you may need to configure something in the OS for the Pi to do a controlled shutdown. There may be something on the PiJuice site about that - I doubt it is difficult to do though and will not interfere with EmonCMS

As I posted previously (read the thread). Actually you will need a minimum of 4 wire (TX/RX/Pwr/Gnd) and 5 (+RTS) if you wish to be able to program the EmonTX from the Pi.

If power consumption is an issue, look at using a PiZero and not a Pi3 (avoid a Pi4). You will need some sort of case for that and the PiJuice module.

One other thing, when ordering, make sure to specify 3 phase sketch.

@Robert.Wall, can the RF be switched off in the configuration or does that need to be compiled in?