Tracking the energy use of household appliances
Guzzler Check
Want to bring down your electric bill? Investigate your favorite household appliances with a consumption meter and a Raspberry Pi.
Understanding energy consumption is more important now than ever, and the tools of the smart home provide some interesting possibilities for energy monitoring. This article shows how to use an energy consumption meter to answer practical questions about the power usage of home appliances.
A consumption meter is a device that sits between the appliance and the socket outlet. Some versions include a graphic display to show the current power consumption and the total consumption. Other models support some form of networking to transmit data to a hub or computer system for viewing and further processing. I'll look at two consumption meters that transmit wireless data output. The Voltcraft SEM6000 uses the low-energy Bluetooth variant known as Bluetooth LE to transmit the data, and the Delock 11827 supports WiFi (Figure 1). A Raspberry Pi acts as the data logger, recording the measured values over several days. Simple Python scripts handle the task of evaluating the profiles. This article was written for the 230-volt European electrical environment, but alternative consumption meters are available for the 120-volt North American market, and, with a little ingenuity, you can adapt these techniques to address other energy consumption questions in other settings.
Getting a Reading
Active current and active power are proportional to each other, which means you only need to record the active power and the time of measurement. Emitted interference from the mains current and the tiny antennas limit the radio range of the devices in Figure 1 to a few meters. The Voltcraft measuring connector therefore expects to find a computer nearby with which it can pair. Delock's version tries to log onto an existing WiFi network. If the signal at the measurement location is too weak, you can use a mobile router to log the computer and measuring device onto its WiFi network.
Voltcraft does not disclose the protocol of the SEM6000, but on GitHub you will find the sem6000 [1] library, which was probably developed via reverse engineering. Listing 1 summarizes the essential calls. Listing 1 uses the bluepy libraries for Bluetooth LE communication and sem6000 for pairing. The MYMAC
variable in line 6 points to the device-specific Bluetooth MAC address.
Listing 1
Read SEM6000
01 #!/usr/bin/env python3 02 import time 03 from sem6000 import SEMSocket 04 import bluepy 05 PW = "0000" 06 MYMAC = 'B0:B1:B2:B3:B4:B5' 07 socket = None 08 while True: 09 time.sleep(1) 10 try: 11 if socket == None: 12 print("Connecting... ", end="") 13 socket = SEMSocket(MYMAC) 14 print("Success!") 15 print("You're now connected to: {} (Icon: {})".format(socket.name, socket.icons[0])) 16 if socket.login(PW) and socket.authenticated: 17 print("Login successful!") 18 socket.getSynConfig() 19 socket.getStatus() 20 print("=== {} ({}) ===".format(socket.mac_address, "on" if socket.powered else "off")) 21 print("\t{}V {}A ? {}W@{}Hz (PF: {})".format(socket.voltage, socket.current, socket.power, \ 22 socket.frequency, socket.power_factor)) 23 except (SEMSocket.NotConnectedException, bluepy.btle.BTLEDisconnectError, BrokenPipeError): 24 print("Restarting...") 25 if socket != None: 26 socket.disconnect() 27 socket = None
If the computer and the device find each other and connect, the continuous loop outputs the measured values to the console, starting at line 8. The measurement times are missing from the output; the script has to generate and record the time itself using built-in Python resources. If the login attempt with the password PW
is successful, the socket can be switched on using the socket.setStatus(1)
command and switched off again using socket.setStatus(0)
. (Note that the password in Listing 1 is 0000
by default – you'll want to change this.)
You control the Delock connector with a simple web API. On first use, or after pressing the button four times, a hotspot named Delock
is launched. The website on address http://192.168.4.1 accepts the configuration data for the network that the device will connect to later on. Once logged in, the router assigns the socket an IP address. After that you can reach the Delock connector's web server on http://IP_address. The graphical interface makes testing far easier. You can type API commands directly when calling the address; the syntax looks like this:
http://IP_address/cm?cmnd=command
The Power toggle
command lets you toggle the actual state, whereas Power on
and Power off
switch the socket on and off. To query the status and read the measured values, just use status 8
. EnergyReset3 0
lets you reset the internal counter; TelePeriod 30
sets the measuring period to 30 seconds.
A minimal Python program for the Delock will look something like Listing 2. Using base_url
and ivp_data
, the requests.get
command builds the query for the measurement socket (line 6). The socket responds with a JSON string; check out Listing 3 for the structure. The remaining lines of Listing 3 decompose the JSON string into the variables power
, for the power measurement, and rtime
, for the time of measurement. Unlike the SEM6000 Bluetooth device, the Delock itself provides the measurement timestamps.
Listing 2
Reading the Delock
01 import matplotlib.pyplot as plt 02 import requests 03 import json 04 base_url = "http://IP address/cm?" 05 ivp_data = {"cmnd": "status 8"} 06 result = requests.get(base_url, params = ivp_data) 07 x = json.loads(result.text) 08 factor = x["StatusSNS"]['ENERGY']['Factor'] 09 current = x["StatusSNS"]['ENERGY']['Current'] 10 voltage = x["StatusSNS"]['ENERGY']['Voltage'] 11 power = x["StatusSNS"]['ENERGY']['Power'] 12 rtime = x["StatusSNS"]['Time'] 13 energy= x["StatusSNS"]['ENERGY']['Total']
Listing 3
JSON string
{"StatusSNS":{"Time":"2022-10-01T20:03:20", "ENERGY":{"TotalStartTime":"2022-10-01T18:47:41", "Total":0.000,"Yesterday":0.000,"Today":0.000, "Power":0,"ApparentPower":0, "ReactivePower":0,"Factor":0.22, "Voltage":229,"Current":0.002}}}
If the Delock connector returns incorrect results, the problem could be due to a lack of calibration. You can address the problem by letting the device measure a consumer with known power consumption. The example shown in Table 1 uses a light bulb rated at 40 watts, although its actual power is 37 watts. The voltage only deviates slightly from 230 volts. The quotient of the power and voltage gives you the current, which is 161mA. The commands from the table change the display to the new values. Once you have made this adjustment, the power meter should measure not only the bulb, but also all other consumers correctly.
Table 1
Calibrating Delock
Command | Meaning |
---|---|
PowerSet 37 |
Power: 37 watts |
VoltageSet 230 |
Voltage: 230 volts |
CurrentSet 161 |
Current: 161mA |
To analyze the energy demand of household appliances, you only need the time of measurement and the active power as measured variables. As practical examples, I'll consider a refrigerator, a washing machine, and a waterbed. I will also determine the efficiency of a microwave and answer the question of which heats water more economically: a kettle or a microwave.
Refrigerator
According to the plate attached to the device, the refrigerator whose data is shown in Figure 2 has a power consumption of 90 watts. According to the measurement, the compressor makes do with 70 watts (blue curve). On and off phases alternate with an interval of approximately 30 minutes. The load reserve ensures that a refrigerator provides sufficient cooling capacity even in warm environments by shortening the pauses. A look at the second-to-last time window in Figure 2 shows what happens when the refrigerator door is opened. You can see the power draw of a few watts for the interior lighting, and the loss of cool air causes the refrigeration unit to start up prematurely.
The program in Listing 4 will help you develop your own evaluation program. The listing expects a CSV file with the columns Time in seconds and Power in Watts. The SciPy cumulative_trapezoid
command integrates the power over time and writes the value to the new consump
column (line 7). Dividing by 3,600 converts watt-seconds into watt-hours. The values are logged by the red line in Figure 2 (right-hand scale). The second-to-last line of the script computes the average power. The average power consumption of 30 watts per year costs EUR100 (~$110), at 40 cents/kWh.
Listing 4
Python Evaluation Script
01 import pandas as pd 02 import numpy as np 03 import matplotlib.pyplot as plt 04 import scipy.integrate 05 df = pd.read_csv('mydata.csv') 06 df = df.set_index(df.iloc[:,0]) 07 df.assign(consump=scipy.integrate.cumulative_trapezoid(df.iloc[:,0], df.index, initial=0)/3600) 08 print('Mean power (W): ', dg.iloc[:,0].sum()/dg.shape[0]) 09 print('Total Energy (Wh): ', dg.iloc[-1,1])
Figure 3 shows a section of the profile depicted in Figure 2. The inrush currents here exceed the nominal value several times over. A current generator with limited power interprets this as a short circuit and switches off.
You could optimize a refrigerator to run on solar panels by making it produce more cold during the day. During the night, its door remains largely closed so that the cooler temperature is maintained until the next day.
Washing Machine
The performance profile for one washing machine cycle is shown in Figure 4. The machine rinses and spins twice, starting at time 1,000 seconds and again 10 minutes later. Although the motor makes do with a few hundred watts, the heater has a power draw of 1,700 watts over a six-minute period. Unsurprisingly, this is precisely where the savings potential lies. In the past, you had to boil laundry. The first breakthrough was detergents, which dissolved grease and cleaned at 60 degrees Celsius (140 degrees Fahrenheit). Modern detergents are happy with temperatures as low as 20 degrees Celsius (68 degrees Fahrenheit).
The last line from Listing 4 calculates the energy consumption of the wash cycle from the measured data. In this case, the consumption is only 0.23 kWh. Boiling the washing would require more than five times the energy. At an electricity price of 40 cents/kWh, a wash cycle costs about 10 cents. Things get really expensive if the laundry is not air-dried but put in a tumble dryer. There is no button to let you turn down the temperature and reduce the financial impact. The energy required for fast drying exceeds that of a washing machine by more than an order of magnitude.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.