Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Three Phase kWh data logger using emon tx- base

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.

Cheers

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)

Advantages

  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)

Disadvantage

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

For UPS, depending on time off, I’d use a LiPo setup. PiJuice HAT - A Portable Power Platform For Every Raspberry Pi – Pi Supply

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 - #119 by haffle

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.

2 Likes

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 PiJuice HAT - A Portable Power Platform For Every Raspberry Pi – Pi Supply.

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 Raspberry Pi Documentation - Raspberry Pi Hardware 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

Here:
https://wiki.openenergymonitor.org/index.php/EmonTx_V3.4#Direct_connection_emonTx_V3_.3E_Raspberry_Pi_GPIO
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?

Then @Barnaby_King would need to specify all his set-up options and the shop would need to compile and load his custom version in each of his emonTx’s. Have you made sure the shop is willing to do that? There would be hundreds of pre-compiled versions if every option were to be catered for. That’s why I don’t supply a compiled version, but always recommend that the user has a programmer and the Arduino IDE. They can then choose exactly the correct set of options for their application. Even when using the on-line settings, only a change of the NodeID and calibration is catered for, in accordance with the original specification.

I believe it is @Barnaby_King’s intention to configure and compile the sketch himself anyway - he already has seen the sketch and its documentation.

Yes i will manage to compile the sketch my self- it seems the instructions here are good. and i have friends i can lean on.

OK thanks - ill look into this on the Pi Juice sites -
Also is it not also the Emon TX which will need to shut down? also when the power comes back on - the Pi and Emon TX will need to be automatically turned on- is this possible?

Shutting down the emonTx isn’t a problem - you’ll lose the accumulated pulse count, that will start from zero again when power comes back, but simply removing the power won’t hurt it. If you use the recommended connection, then it derives its power from the Pi anyway, what I don’t know is how the PiJuice UPS switches the power to the Pi - that’s possibly another question for the PiJuice team, but I’d guess that it feeds it via the GPIO, so if the emonTx is also fed from the same pin, that’s the problem solved.

When power is restored, the Pi and emonCMS will normally restart automatically, and by the time the Pi has booted and emonCMS has started, the emonTx will be running and sending data. It means that you’ll miss the initial few tens of seconds, but unless the Pi and emonTx continued throughout the outage, or somehow knew to start up just before power was restored, that can’t be helped.