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:
library(tidyverse) library(patchwork) 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()) %>% filter(n==360) 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()) %>% filter(n==8640) 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) dev.off()