Showcase energy consumption monitoring project

Home News Showcase energy consumption monitoring project Back

Looking for a way to easily monitor the power consumption of your house and the regular electric meter is not enough? With a combination of function blocks and UniPi controllers, you can easily create a system to get an overview of power consumption.

Programs for energy consumption monitoring can be created in various software solutions supporting the FBD programming method; such solution will allow you to keep track of not only the total power consumption but also the weekly or daily consumption. In this article you can find one of the possible solutions using the Mervis software - a professional, officially supported platform for programming the UniPi PLCs. 

If you are Mervis beginners, visit our First steps in the Mervis article - here, you can find a brief manual to starting up the system and first programming tasks. Alternatively, you can check out tutorials on the UniPi Knowledge Base. Just to remind you - UniPi Axon controllers are by default shipped with Mervis already installed, while the UniPi 1.1 and the UniPi Neuron controllers require you to burn the OS image to a memory card first. 

Connecting the electric meter

Setting up the total consumption monitoring is easy - all it takes is to connect the electric meter variable with the output variable representing the consumption; for the purpose of this article, a Modbus electric meter was used. But if you want to monitor daily and weekly consumption as well, the Mervis function block library will be useful for it. 

Daily consumption monitoring

The picture above shows five function blocks you will need for the task - getlocaltime, decomposetime, eq, Integer Memory (B106) and sub blocks. 

The getlocaltime block returns current local time, while the decomposetime decomposes the local time into individual time segments (hours, minutes, seconds, milliseconds) for further processing. In this project, an hour value is used, represented in integers.   

The eq block compares the time value from decomposetime with a pre-defined value; in this project, the block is set to 0. When getlocaltime returns a zero value (eg. midnight), a rising edge is detected on the eq's output.

When the rising edge is detected on the ClockRising input of Integer Memory (B106), the block returns a current value of the electric meter. 

Last is the sub block, which subtracts the value returned by Integer Memory (B106) from the total consumption value. The resulting value represents a power consumption for a single day

Weekly power consumption monitoring

Function blocks used in the weekly consumption monitoring are nearly the same as in the daily consumption monitoring with two differences. Decomposetime block is replaced by the decomposedate block which returns a number representing a current day in the week (number 1 represents Monday). The eq block function stays the same with the exception of its value being set to 1. That means if Monday is detected by decomposedate, Integer Memory (B106) again returns a current electric meter value and sub block subtracts it from the total consumption value. The resulting value represents a power consumption for the previous week. 


The result and further steps

The resulting project will allow you to keep track of daily, weekly and total power consumption at once. Using the Mervis integrated HMI editor, you can then display all three values in a custom-built interface accessible through a regular web browser using a tablet, smartphone or your computer.

You can also use the Mervis DB cloud database to store measured data. The database is also accessible through any internet browser. Additionally, you can use the proxy server to remotely access the controller itself. A license for both Mervis DB and the proxy server is by default a part of each UniPi Neuron and UniPi Axon package, while with the UniPi 1.1/1.1 Lite controllers, the license is available either individually or as a part of an UniPi 1.1/1.1 Lite complete set. 

Other interesting articles

7 tips and tricks for PLC programming
7 tips and tricks for automation network installation
First steps in the Mervis
UniPi e-shop

Our parts

Unipi Extension xS10
(out of stock)

Unipi Axon S105
More than 20 items in stock

Unipi Axon S205
Less than 20 items in stock

Unipi Axon S505
More than 20 items in stock

Unipi Axon M205
Less than 20 items in stock

Unipi Axon L205
More than 20 items in stock

Add to cart
Subscribe to our newsletter

Show more