Get Plugged in to the Future of Smart Energy Meters

Due to a number of recent events around the world, energy prices are on the rise in a big way. In the United States, the U.S. Energy Information Administration reported that the average price for residential electricity rose by 8% in 2022. That is a bitter pill for consumers to swallow, but on the world stage, it is a relative drop in the bucket. In much of Europe, for example, prices for oil have risen up to 60%, and natural gas is up as much as 400%. For many, price increases of this magnitude are more than just an inconvenience, and may cause serious problems as winter sets in.

Problems of this scale are very complex and not easily solved — especially not by a lone engineer. But, with the powerful tools available to us today, it may be possible for an individual with a good idea to make a real impact. Electronic engineer and machine learning enthusiast Christopher Mendez Martinez is one such case in point, with a very clever proof of concept device that he recently built with Edge Impulse Studio. With no power to actually reduce prices, he decided rather to approach the problem by creating a way to help people to better manage the power that they do use, and perhaps reduce consumption in the process.

Martinez built a smart energy meter that tracks variables relevant to power consumption. These variables are processed by a machine learning algorithm running on-device that is capable of identifying which appliances are switched on, and when. Altogether, this information provides a user with important insights that can help them to better understand how they are making use of electricity. Such insights can lead to changes in behavior that reduce power consumption, and with it, energy-related costs. The entire device is constructed with low-cost, off-the-shelf equipment.

The data collection setup

The STMicroelectronics STM32 Nucleo-144 development board was chosen as the main processing unit for the build. With a STM32F767ZI microcontroller onboard, the Nucleo-144 comes loaded with an Arm Cortex-M7 CPU running at 216 MHz, 512 KB of SRAM, and 2 MB of Flash memory. That is plenty of processing power to tear through machine learning algorithms that have been optimized for resource-constrained devices by Edge Impulse. A current sensor and voltage sensor are wired into the development board to capture measurements from the mains electricity. Finally, a Blues Wireless Notecard was selected to enable the device to wirelessly communicate over Wi-Fi.

Since mains power is delivered via alternating current, some calculations are needed to determine the following parameter values: RMS voltage (V), RMS current (A), power (W), power factor, and energy (kWh). A subset of these variables, along with the raw current and voltage signals, were selected to be used as inputs to the machine learning model. To prove the concept, Martinez chose to initially focus on identifying the electrical signature of a refrigerator, fan (ceiling and floor), light bulb (incandescent and LED), microwave, air conditioner, and an LCD television. Accordingly, he set about collecting samples of the variables of interest while each of these appliances was in use.

In the hope of producing a well-generalized model, Martinez collected data over a period of several hours for each appliance. To make this a hands-off process, and to avoid issues with storing large amounts of data on an edge computing device, he used the Edge Impulse ingestion service, which allows data to be transferred to an Edge Impulse Studio project via HTTP or HTTPS API endpoints. As data was collected with a simple application, it was sent to the ingestion service via the Blues Wireless Notecard.

Exploring the training data in Edge Impulse Studio

After a few days of collecting measurements, the Edge Impulse project was loaded up with training data, so it was time to build an impulse to analyze it. The impulse starts with a step that cuts data into 100 millisecond windows, then performs a spectral analysis on each window to analyze the voltage and current signals in the frequency domain. A flatten block was also added to the preprocessing step to extract the average value of RMS current, power, and power factor. Finally, two learning blocks were added — first, a neural network classifier to determine which appliance is in use, and second, a K-means anomaly detector to recognize when a new appliance, that the model is not yet aware of, has been switched on.

The model training process was launched with a button click, and after a short time the results were presented in the form of a confusion matrix. The overall average classification accuracy was found to be better than 99%. Since the model was exceedingly good at making correct classifications, there was no need to go back to tweak the model structure or hyperparameters, so Martinez moved on to deploy it to the physical hardware. Using the deployment tool, a self-contained C++ library, including the full machine learning analysis pipeline, was generated and downloaded. This is one of the most versatile deployment options available — it can be deployed to virtually any target hardware, and it offers the flexibility of coding your own logic that can be triggered by the inference results of the model.

Building a complex ML pipeline with a simple UI

As a finishing touch, a web dashboard was created that allows a user to view historical data related to their energy and appliance usage. It is these insights that Martinez hopes will give people the ability to trim unnecessary energy use and reduce their electricity bills. There is still some work to be done in the future, however. To be generally useful, the device will need to be trained to recognize many more types of appliances, and various brands and models of each particular appliance. Further, the prototype was built while running a single appliance at a time. Later revisions would need to be able to recognize multiple appliances operating at the same time. Fortunately, these scenarios should be able to be accounted for by collecting more data and retraining the model.

Power up your brain by scanning through the detailed project write-up, then clone Martinez’s Edge Impulse Studio project to get the jolt you need to get your own project off the ground fast.


Want to see Edge Impulse in action? Schedule a demo today.

Comments

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter