Community
OpenEnergyMonitor

Community

Alert before power is tripping (calculating averages over last x minutes)

Hello,

sorry, if a similar question was asked before, i was not able to find anything alike.

I don’t own an emonPi yet, but I plan to get one, if what I want to to is possible without too many troubles.
What I want to implement is an early alert system, that warns me, before my power turns off due to overconsumption.

Short explanation of how it works with my power provider.
My contract includes a power of 3 kW.

First rule:
If the average usage over the last 2 minutes exceeds 4,2 kW, it turns off.

Second rule:
At any times, an average of the power consumption over the last 182 minutes is calculated. If this exceeds 3,3 kW, the power goes out.

How I’d like to solve it:
For the first case i would like to calculate the average over the last ~30sek and create an alert when this exceeds 4,2 kW. This should give me some time to react an turn off some devices.

Same for the second rule. Here I would need to calculate the average of the last ~90 minutes, and create a warning if it exceeds 3,3 kW.

Is this possible without too much effort? Maybe those features are already existing.

PS:
I will look later at how to implement the alert system. I have another general purpose PI running and some arduino nano and RGB Leds waiting to be used. First I have to think about what exactly I want.

Thanks in advance and best regards.

Welcome @Derb to OEM.

Is your supply single phase or 3-phase?

Why do you want an emonPi? Is it to record and view your electricity consumption generally, or only to operate this warning/control system?

If you have a Raspberry Pi, and you are not using the serial port, then you can connect an emonTx to your Pi and do almost all of the things that an emonPi will do.

Have you thought about remotely controlled sockets for the devices you are able to turn off? Then your Pi could turn those devices off automatically.

1 Like

Hi Robert,

My supply is single phase.

Well, the initial idea was to implement an alarm system, but i definitely want to go for a complete monitoring solution that’s also open to implement any possible ideas i might get in the future.

My current Raspberry Pi’s (actually there is two of them) are already busy doing other things, and they both have some specific distros installed, so i’d prefer to leave them alone for the most part and have a dedicated PI for monitoring purposes.

Yes, I thought about having remotely controlled sockets, but I don’t believe automatic turning off devices would be very practical in this case.
Most of the times, when the power goes out, it’s because somebody turned on the dishwasher, because he forgot that the washing machine was still running, and so on.
So, a short acoustic reminder, that the limit is reached would be sufficient and it should always be decided manually, what shoud be switched off.

So, calculating the average over last x minutes, each time a new value is measured, would this be possible?
And then I’d have to create an event, for example, one that makes an http request to another system, or something similar, whenever one of the thresholds is exceeded.

OK, that’s all understood.

I still think a Raspberry Pi and an emonTx would offer you greater flexibility - the emonTx might have a digital output available that you could use for your audible alarm, and the Pi has the GPIO available. That would be possible but difficult with an emonPi.

It’s doubtful that the emonTx has enough memory available to store enough data to be able to give you a running average over the last 180 minutes, even if you condensed it into 1 minute averages. That would not be a problem with the Pi.

I’m not an expert on programming the Pi, if you installed emonCMS on it, you would be able to access the database to extract the values and calculate the averages or maxima over whatever period you wanted. I believe there is an API to access the database, or you could query the database direct - the format is available here in the ‘Learn’ section.

Ok, that makes sense.

My missassumption was that the emonPi would offer me the same possibilities as a normal raspberry Pi.
I see emonCMS stores its data in a MySQL database. So it would definitely be easy to run a cronjob every x minutes, that calculates my averages.

EDIT: Ok, I see, by default the data is not stored in MySQL, but i guess it’s still possible to query the data from the default engines like phptimeseries/phpfina… I will have to play around a bit with this to see how it works.

So this is clear now and I will go for a emonTx + raspberryPi as you suggested.

The only new “problem” that arises is, that the emonTx has more CT inputs. So I would prefer to place it in the cellar, instead of my apartment, where I can measure not only my consumption, but also that of my parents.
Unfortunately there is no WiFi and RF will definitely not reach from the cellar to my appartment. So I guess the best bet would be to pull a cable and run a serial connection between emonTx an rPi GPIO. Maybe a CAT5 cable, as it would run parallel to the power cables that go to my appartment for about 10-20 meters.

Do you think, this would be feasible?

As it stands, the signal levels are 0 - 3.3 V and RS232 protocol, so you might have difficulties with 20 m. If you have problems with the serial link, the first step would be to reduce the baud rate, then I’d suggest a balanced RS485 line (with suitable converters each end) would be the solution.

I suggested the emonTx + RPi only because the emonPi is in a box and connections to the outside are difficult.

Ok, i’ll go for it and test it with emonTx + RPi (over RS232 as a first attempt).

Thank you very much, for your help :slight_smile: