An important step towards optimizing energy consumption is knowing your actual consumption. My house was built during the oil crisis in the 1970s, and due to the lack of a natural gas connection, the builders decided to use electricity to do all of the heating (water and home heating). This is not unusual for this area of Germany, and it remains an appropriate solution in countries that depend highly on nuclear power.
Electricity prices here are quite high (around € 0.28/kWh), so I decided to monitor my home's energy consumption to get a feel for areas where I could save some energy.
I used to work for a company that sold energy-monitoring systems for industrial customers. While this company mostly used proprietary software, you can set up a similar smart monitoring and logging solution for your home based on open source components. This article will show you how.
In Germany, the grid operator owns the electricity meter. The grid operator is obliged to provide an interface on its metering device to enable the customer to access the meter reading. Here is the metering device on my home:
Generally, almost every metering device has at least a dry contact—as my electricity meter does—that you can use to log metering. As you can see, my electricity meter has two counters: The upper one is for the day tariff (6am to 10pm), and the lower one is for the night tariff (10pm to 6am). The night tariff is a bit cheaper. Two-tariff meters are usually found only in houses with electric heating.
A reliable energy-monitoring solution for private use should meet the following requirements:
- Logging of metering impulses (dry contact)
- 24/7 operation
- Energy-saving operation
- Visualization of consumption data
- Long-term recording of consumption data
- Connectivity (e.g., Ethernet, USB, WiFi, etc.)
I choose the Siemens SIMATIC IOT2020 as my hardware platform. This industrial-proven device is based on an Intel Quark x86 CPU, has programmable interrupts, and is compatible with many Arduino shields.
The Siemens device comes without an SD card and, therefore, without an operating system. Luckily, you can find a current Yocto-based Linux OS image and instructions on how to flash the SD card in the Siemens forum.
In addition to the hardware platform, you also need some accessories. The following materials list shows the minimum components you need. Each item includes links to the parts I purchased, so you can get a sense of the project's costs.
- Siemens SIMATIC IoT2020 unit
- Siemens I/O Shield for SIMATIC IoT2000 series
- microSD card (2GB or more)
- CSL 300Mbit USB-WLAN adapter
- 24V power supply (I used a 2.1A TDK-Lambda DRB50-24-1, which I already owned). You could use a less expensive power supply with less power: the SIMATIC IOT2020 has a maximum current of 1.4A, and the dry contact needs an additional 0.1A (24V / 220Ω).
- 5 terminal blocks (Weidmueller WDU 2.5mm)
- 2 terminal cross-connecting bridges (Weidmueller WQV)
- DIN rail (~300 mm)
- 220Ω / 3W resistor
Here is the assembled result:
Unfortunately, I didn't have enough space at the rear wall of the cabinet; therefore, the DIN rail with the mounted parts lies on the ground.
The connections between the meter and the Siemens device look like this:
How it works
A dry contact is a current interface. When the electricity meter triggers, a current of 0.1A starts flowing between s0+ and s0-. On DI0, the voltage rises to 24V and triggers an interrupt. When the electricity meter disconnects s0+ and s0-, DI0 is grounded over the resistor.
On my device, the contact closes 1,000 times per kWh (this value varies between metering devices).
To count these peaks reliably, I created a C program that registers an interrupt service routine on the DI0 input and counts upwards in memory. Once a minute, the values from memory are written to an SQLite database.
The overall meter reading is also written to a text file and can be preset with a starting value. This acts as a copy of the overall metering value of the meter in the cabinet.
The data is visualized using Node-RED, and I can access overviews, like the daily consumption dashboard below, over a web-based GUI.
For the daily overview, I calculate the hourly costs based on the consumption data (the large bar chart). On the top-left of the dashboard you can see the actual power; below that is the daily consumption (energy and costs). The water heater for the shower causes the large peak in the bar chart.
A reliable system
Aside from a lost timestamp during a power failure (the real-time clock in the Siemens device is not backed by a battery by default), everything has been working fine for more than one-and-a-half years.
If you can set up the whole Linux system completely from the command line, you'll get a reliable and flexible system with the ability to link interrupt service routines to the I/O level.
Because the I/O Shield runs on standard control voltage (24V), you can extend its functionality with the whole range of standardized industrial components (e.g., relays, sensors, actors, etc.). And, due to its open architecture, this system can be extended easily and applied to other applications, like for monitoring gas or water consumption or as a weather station, a simple controller for tasks, and more.