Monitoring electricity use

My partner and I are considering installing photo voltaic (PV) solar panels. We had solar thermal (hot water) panels in our old house, but our new property has a very different heating system. The air source heatpump which heats our home is excellent and means we have no use for gas, but our electricity use is much higher now it is our only energy source!

To help understand our electricity use, and hence how we might specify a PV system, I got an electricity monitor from the Open Energy Monitor project. The hardware and software they use are all open source, which appeals greatly. One worry I had with all the commercial energy monitoring products I’d seen was how easily I could access my data. This isn’t a worry when it’s sitting in an ODBC compliant database on a Raspberry Pi server!

Today I made my first download from the server. It wasn’t automated, but a few clicks through a web interface. Data are hosted in a component called EmonCMS, which is a suite of tools build around a MySQL database. I could extract data directly from this database into R, but EmonCMS also has the functionality to build dashboard apps for data visualisation. This will be more useful in the long term, as I will then be viewing live data with no additional effort.

Back to the problem at hand, I wanted to visualise our electricity use. I wanted to do this by day and also by hour. The latter is particularly important for solar, as I need to understand how much of our electricity use is during daylight hours. So with a bit of dplyr and ggplot magic, I created these two plots:


Downloaded data showed an instantaneous electricity use in Watts, recorded every 10 seconds. These values were converted to kWh and summed to hourly or daily. Days or hours with incomplete records were discarded. Here’s the code to make the plots:


elec = read_csv("~/Downloads/file.csv", col_names=c("time", "use"))

elec_hrly = elec %>%
   mutate(hr = str_sub(time, 12, 13),
          date = as.Date(str_sub(time, 1, 10), format="%d/%m/%Y")) %>%
   group_by(date, hr) %>%
   summarise(use_hr = sum(use/360000),
             n=n()) %>%

elec_daily = elec %>%
   mutate(date = as.Date(str_sub(time, 1, 10), format="%d/%m/%Y")) %>%
   group_by(date) %>%
   summarise(use_dly = sum(use/360000),
             n=n()) %>%

png("~/Cloud/House/Electric_use.png", width=1400, height=500)
ggplot(elec_hrly, aes(hr, use_hr)) +
   geom_boxplot() +
   labs(title=paste("Home electricity use:",
                    min(elec_hrly$date), "to", max(elec_hrly$date)),
        subtitle="By hour of the day (GMT)",
        x="Hour of the day (GMT)",
        y="Electricity use (kWh)") +
   theme_grey(base_size = 22) +
ggplot(elec_daily, aes(use_dly)) +
   geom_histogram(bins=20) +
   labs(subtitle="By daily use",
        x="Daily use (kWh)",
        y="Count of days") +
   theme_grey(base_size = 22)



  1. Nice. I’ve got a few of the emonTH devices, handy for tracking various temperatures. As well as outside temperature, you could monitor the temperature of the heat pump lines as a proxy for when the heat pump is operating. (Or, I would guess you can put a clamp on the heat pump cable at the CU assuming it’s on its own breaker). You can also use it to fine tune stored hot water although I’m struggling to remember whether your new house has a tank.

    1. One thing to come out this is thinking how much of the load can we move from morning/evening to the middle of the day? We’ll need to do that to get the best use of a PV system. Dishwasher and washing machine have timers, but not much we can do about cooking and space heating!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s