SmartMeter

Engineering Documentation


About

SmartMeter is hardware/software system for 247 recording of the overall electricity consumption in a family home.

It consists of a COTS camera-based embedded computer system which takes pictures of a regular electricity meter. Server software performs an OCR on these pictures and creates a time series report about the overall electricity consumption eventually revealing interesting consumption patterns.

We may gain insights from this report in order to optimze our energy footprint.

Project Definition

This is a tiny research project. Apart from the overall goal we want to achieve some learning outcomes.

Goal

Our goal is to improve our energy footprint. Therefore, SmartMeter aims for a fine-grained tracking of the electricity consumption in a family home.

Objectives

The project is less on the hardware side, rather it focusses on software for

  • reliably taking pictures in 15 minutes intervals
  • data management across various systems at home as well as on the Internet
  • AI based optical character recognition
  • unattended operation
  • fine-grained consumption statistics

Expected Results

  • 247 solution delivering electricity consumption data
  • Set of real world pictures used for future AI projects

Learning Outcomes

  • Methods and tools for AI based image processing
  • Assess the maturity and ease of use of available tools

System Design

This use case diagram depicts SmartMeter’s main services.

system main services

The brief design sketch below shows SmartMeter’s hardware and software components. The local embedded camera system uploads the pictures on Dropbox. The server is a remote host on the Internet downloads them from there and performs the OCR processing.

system main components

The current design distributes some main services as well as the data across several systems on the Internet. This has implications on data and privacy protection. Although all connections are encrypted, potentially sensitive data is stored outside the physical boundaries of the house, therewith, making data and privacy vulnerable. Special attention needs to be paid on access restriction as well as on data management, e.g. data retention.

An alternative is to perform all processing on the embedded camera system. This will keep all data local. We leave this for future work.

Hardware Setup

We use Raspberry Pi 3, Model B+ as the platform for the COTS embedded camera system. It connects to a Raspberry Pi camera module.

The regular electricity meter is inside a switch cabinet. The inner side of the cabinet’s door holds the Raspberry Pi and the camera using magnets. The following picture shows the installation.

SmartMeter installation

There are only 3 centimeters between the meter’s display and the cabinet door. The camera looks at the display via the mirror. A Raspberry powered USB light supplies sufficient brightness for the camera to take pictures. The next picture shows the components.

SmartMeter components

The picture shows how the installation is oriented towards the meter when the door is closed.

SmartMeter inside

When operating the camera captures a mirrored image of the electricity meter’s display. Rotating and mirroring it will show the number correctly.

Original image Image rotated and mirrored
image captured by meter camera meter camera

SmartMeter Camera Software

The SmartMeter camera software runs on the Raspberry Pi. It takes pictures and uploads them to Dropbox. The central script smeter.sh controls all functions.

For installation instruction see install_raspi.md.

Scheduling

An external timer switch powers-on the Raspberry Pi at a pre-defined time. After the reboot the cron scheduler runs the central control script smeter.sh, which takes the pictures (takepicture.sh) and uploads them to Dropbox (fileservice.sh). At the end, the script shuts down the Raspberry Pi. At a later time the external timer switch powers-off.

The timer switch has only 28 slots for defining on and off times. This is not sufficient for 15 min intervals per hour. We define a coarse-grained timer duty cycle of 50% within 1 hour, which consists of 30 min power-on duty and 30 min when the Raspberry is powered off. In the power-on duty time, the smeter.sh control script performs three measurement activities at 0, 15, 30 min after the start. This schedule achieves three 15 min intervals and leaves out one within a hour. The exact schedule deviates a bit from this description in order to give time management activities to take place before the external timer switch powers-off. The sleep delay after the cron scheduler starts gives time for the OS to bring the ressources online. The following figure depicts the schedule.

SmartMeter software on Raspi

The schedule repeats as soon as the external timer switch powers-on the Raspberry Pi again.

Maintenance Mode

The above schedule makes it difficult to do maintenance activities. A developer needs to login after the bootup and stop the smeter.sh script before the Raspberry Pi shuts down.

Maintenance mode:

The control script checks for a USB thumb drive at its startup. If it finds the file maintenance in the root directory, it will disable the shutdown at the end of smeter.sh control script.

The developer has to set the external time switch to permanent on in order to avoid further powers-off.

The maintenance.sh script implements the check for the maintenance mode. The following figure depicts the maintenance mode setting in smeter.sh as an activity diagram.

Maintenance mode of the SmartMeter camera software

Log Rotation

We use standard linux tool logrotate. The config file logrotate.conf defines the parameters and resides in the same directory as the other scripts. logrotate.sh has the following functions:

  1. Call the linux tool logrotate on the log directory
  2. Upload the logfiles to dropbox

The central control script smeter.sh calls logrotate.sh before the duty cycle ends and the system shuts down.

Logfile Analysis

The scripts like smeter.sh, fileservice.sh, logrotate.sh report their actions in a logfile. A typical log line looks like the following example.

2020-08-31 01:02:01,1598828521 - /home/pi/smartmeter/smeter.sh - INFO - SmartMeter camera system starts.

Apart from regular log lines the logfiles contain all other script output as well. Run the following command to cleanup the logfiles and only store log lines in smartmeter.log.

src/filterlog.sh > smartmeter.log

An R jupyter notebook runs the analysis and computes various summary statistics. An important output is the boxplot figure below. It shows the varying runtime of different scripts. One gains insight in the regular runtime behavior of the SmartMeter software.

Durations of the scripts as result of logfile analysis

The following table displays summary stats for each script. Each number reports the runtime in seconds.

smeter.sh fileservice.sh logrotate.sh
Min. 1738 38.0 9.00
1st Qu. 1739 39.0 10.00
Median 1740 41.0 10.00
Mean 1742 41.1 10.96
3rd Qu. 1743 42.0 11.00
Max. 1752 52.0 17.00

The complete logfile analysis is available as an R jupyter notebook. The notebook runs on mybinder and downloads recent logfiles from Dropbox. Just click the badge below to run a recent analysis.

Run logfile analysis: Binder

SmartMeter Server Software

The SmartMeter server software runs on a Linux server. It downloads pictures from Dropbox and processes them using an AI-based OCR approach.

For installation instruction see install_server.md.

Software Design

… tbd …

Report

… tbd …

AI-based OCR

Content

  • AI based optical character recognition
  • Methods and tools for AI based image processing
  • Assess the maturity and ease of use of available tools

… tbd …

Insights

The energy consumption report depicts our consumption profile. It reveals patterns which correspond to the behavior of the house’s residents. This section exploit statistical regularities to derives some measures optimizing our energy footprint. Concretely, we want to reduce the idle consumption, i.e. the energy usage when devices are not in use.

Conclusion

SmartMeter records the overall electricity consumption in a family home. It augments a regular electricity meter with an COTS embedded camera system. A server software creates a consumption report providing insights in energy usage patterns.

The list below displays the achieved objectives:

In the current design, data is stored and processed on an Internet server outside the physical boundaries of the house. In a future SmartMeter implementation, all processing and data handling will be performed on the embedded camera system. This will improve the situation on privacy and data protection.