Hourly energy model example 2: Variable supply and flat demand (python code included)

The second example in the hourly energy modelling tool models the degree of supply/demand matching between a variable renewable supply consisting of a single renewable energy generation type and a flat electricity demand profile.

A flat demand may not of course be particularly realistic and the more complex examples later on address this, but I've used it here just to illustrate this particular simple example case.

Online tool: > navigate to 2. variable supply and flat demand
The demand is subtracted from the supply for every hour in the 10 year period and the total amount of unmet demand and excess generation is measured as well as the amount of time the supply was more than or equal to the demand.

The demand level is set to an annual average electricity demand of 3300 kWh which is the average UK household annual electricity consumption. The amount of installed capacity is set to match this demand on the 10 year basis of the dataset.

Running the model for each of each generation type, matching total 10 year supply to total 10 year demand of 3300 kWh x 10 we get the following results:

Onshore wind Offshore wind Wave Tidal Solar
Installed capacity 1.17kW0.79kW1.33kW1.58kW3.98kW
Percentage of demand
supplied directly
Percentage of time demand is
more or the same as the supply

We can see again here that offshore wind is the clear winner with the lowest installed capacity requirement and highest level of supply/demand matching. Perhaps an interesting result is how less predictable technologies such as wind and wave provide greater levels of matching than power from tidal which is very predictable.

Python example source code
Alongside the online javascript modelling tool there are a series of python versions of the examples which are simpler to follow as they dont include all the code to create the visual output, they just print out the main results at the end.

I've highlighted the main parts in bold below:

# dataset index:
# 0:onshore wind, 1:offshore wind, 2:wave, 3:tidal, 4:solar, 5:traditional electricity
gen_type = 1

installed_capacity = 0.785 # kW

annual_house_demand = 3300 # kWh
house_power = (annual_house_demand * 10.0) / 87648  

# Load dataset
with open("../dataset/tenyearsdata.csv") as f:
    content = f.readlines()
hours = len(content)

print "Total hours in dataset: "+str(hours)+" hours"

total_supply = 0
total_demand = 0

exess_generation = 0
unmet_demand = 0

hours_met = 0

# for every hour in the dataset
for hour in range(0, hours):
    values = content[hour].split(",")

    # calculate the supply
    supply = float(values[gen_type]) * installed_capacity
    total_supply += supply

    # calculate demand
    demand = house_power
    total_demand += demand

    # subtract demand from supply to find the balance
    balance = supply - demand

    # record the total amount of exess and unmet demand
    if balance>=0:
        exess_generation += balance
        hours_met += 1
        unmet_demand += -balance

capacity_factor = total_supply / (installed_capacity*hours) * 100

prc_demand_supplied = ((total_demand - unmet_demand) / total_demand) * 100

prc_time_met = (1.0 * hours_met / hours) * 100

# print out the results

print "Installed capacity: %s kW" % installed_capacity
print "Capacity factor: %d%%" % capacity_factor
print "Total supply: %d kWh" % total_supply
print "Total demand: %d kWh" % total_demand
print "Exess generation %d kWh" % exess_generation
print "Unmet demand %d kWh" % unmet_demand
print "Percentage of demand supplied directly %d%%" % prc_demand_supplied
print "Percentage of time supply was more or the same as the demand %d%%" % prc_time_met

Hourly energy model example 1: Variable Supply

This first example in the hourly energy modelling tool model's the hourly output of a given installed capacity of wind, wave, tidal or solar. The model really isn’t doing much its just loading the capacity factors for every hour from the 10 year dataset and multiplying the capacity factor by the installed capacity.

The total electricity generated is calculated as the sum of the electricity generation in each hour and printed along with the capacity factor at the end.

This example is useful for just seeing what the ZeroCarbonBritain renewable capacity factor dataset looks like, you can zoom and pan through the datasets for onshore wind, offshore wind, tidal, wave and solar pv, click on the link below to open the tool:
Online tool: > navigate to 1. variable supply

The units are really not important the example could just as well be in MW's or GW's. kW's where chosen as the other model examples in the series are focused around building a hourly model that's relatable to an average households energy demand. The kW's of installed capacity could just relate to a small share of a much larger wind turbine, solar farm, wave or tidal power installation.

Running the model for each of these generation types with the same installed capacity the results are as follows:

Onshore wind Offshore wind Wave Tidal Solar
Installed capacity 1.0kW1.0kW1.0kW1.0kW1.0kW
Annual generation 2834 kWh4204 kWh2482 kWh2092 kWh826 kWh
Capacity factor 32%47%28%23%9%

In all of the examples above the installed capacity of the renewable generator was the same (1.0kW) but we can see straight away that there is a significant difference in the total electricity generated by each type. A unit of offshore wind generates just over 5 times as much energy as a unit of solar pv using the zerocarbonbritain dataset. By itself this is not enough information to evaluate the effectiveness of a technology, we would need to compare the costs per unit of installed capacity, embodied energy per unit of installed capacity, how well a particular solution matches demand, the land areas required, the availability of the resource to name just a few of the many factors that need to be weighed up but it does highlight one of the important factors.

Python example source code
Alongside the online javascript modelling tool there are a series of python versions of the examples which are simpler to follow as they dont include all the code to create the visual output, they just print out the main results at the end.

The following 19 lines of python code are all you need to load the ZeroCarbonBritain dataset and run through all 87,648 hours, calculating the power output for each hour and accumulating the total energy supplied over the 10 year model period:

# dataset index:
# 0:onshore wind, 1:offshore wind, 2:wave, 3:tidal, 4:solar, 5:traditional electricity
gen_type = 4

installed_capacity = 1.0 # kW

# Load dataset
with open("../dataset/tenyearsdata.csv") as f:
    content = f.readlines()
hours = len(content)

print "Total hours in dataset: "+str(hours)+" hours"

total_supply = 0

for hour in range(0, hours):
    values = content[hour].split(",")
    supply = float(values[gen_type]) * installed_capacity
    total_supply += supply

capacity_factor = total_supply / (installed_capacity*hours) * 100

print "Installed capacity: %s kW" % installed_capacity
print "Total supply: %d kWh" % total_supply
print "Capacity factor: %0.2f%%" % capacity_factor

Next: Variable supply and flat demand - investigating the degree of supply/demand matching

Modelling hourly demand and supply for renewable powered domestic electricity, heating with heatpumps and electric vehicles

Earlier this year I did some work with Philip James from the Centre for Alternative Technology and a researcher on the ZeroCarbonBritain project on creating an open source online zero carbon energy modelling tool based on the ZeroCarbonBritain energy model which is one of the Uk's leading energy scenarios outlining a positive, aspirational 100% renewable zero carbon energy future.

This first tool is available online here and blog post, using it it is possible to explore how its possible to supply energy demands such as space heating and electric vehicles from a variable renewable supply consisting of wind, solar, tide and wave power and a mix of storage technologies. The tool models supply and demand on an hourly basis which is a significant improvement over simpler annual approach.

Understanding its workings
I had been wanting to dig down deeper into the workings of the model and unpick the effect of the different components, the full model has so many different things going on that its hard to see how each component such as space heating demand from heatpumps, space heating profiles, electric vehicle charging profiles, water heating, or different generation technologies affects the bigger picture of the overall supply/demand balance and resulting storage requirements and so over the last month and a half I've spent some time looking into this in more detail.

Python and javascript example models
I started by writing a series of python models that modelled many of the key components in turn using the full 10 year hourly dataset used in the ZeroCarbonBritain spreadsheet model, exploring the level of supply/demand matching for each generation technology. As I started to model some of the more complex demands such as space heating from heatpumps, including the effect of solar and internal gains, I needed to be able to see what was going on in more detail so I converted the models to javascript and wrote a data viewer using flot.

Online visual tool
I've put all these model examples together into an online tool and added alongside each model a brief analysis and extended results of the many model run's I ran with different parameters. The tool also includes an introduction and overview of the uk energy context which is intended to help put the model examples which focus on domestic traditional electricity demand, space heating and electric transport in context. This tool is now available online here:

Launch online zero carbon energy system example models:

and its all open source with the code and full website on github here:

The tool covers the following model examples and context pages:

    Energy Overview
    1. Variable supply
    2. Variable supply and flat demand
    3. Variable supply, traditional electricity demand and oversupply
    4. Mixed supply and flat demand
    5. Variable supply and space heating demand
    6. Electric Vehicles
    7. All
    ZCB Dataset
    ZCB web model
    Python models

I have found it really interesting doing this work, but it also feels like a chapter early on in a large book. There is a lot more I'd like to understand in more detail and expand on which I hope to continue with over time.

EmonTx v2.5 and throughhole kits

We've had quite a few people ask about the throughhole emontx v2 and emonGLCD's designs since we've moved away from stocking them in the shop and developed the pre assembled units. I've also had several conversations with people offline who said how much they enjoyed building the kits and encouraged us to keep supporting and stocking them. The challenge is the complexity of running an online shop with many different product lines and the additional workload of kiting and stock ordering - but it seems like it might be worthwhile for us to look into a way to make it possible.

The emontx v2 currently uses different 3.5mm jacks to the emontx v3 and emontx shield, It also required a different case which needed milling to use. To try and standardise on the components required I've been working on a new version that is designed to fit in the emonTH case that doesn't require milling and uses the higher quality 3.5mm jacks used on the emontx v3 and emontx shield.

As I got stuck in to the design I thought Id add the powering via AC circuitry that's on the emontx v3 and find a way of ensuring all spare IO is available + the addition of a row of terminal blocks with power, ADC's and digital IO breakout in much the same style the EmonTH.

The first revision of this new design is now available on github here:

and looks like this (im really quite pleased with how it turned out, there's something quite satisfying about designing and routing together a pcb, trying to find neat layouts and so on):

The main features are:
  • 2x CT sensor inputs using higher quality 3.5mm jacks used on the EmonTx v3 and emontx shield
  • 1x ACAC Voltage sensing and power input
  • Terminal block power, ADC's and Digital IO breakout + full spare IO breakout.
  • Onboard DS18B20 footprint
  • Based around ATmega328 + RFM69 core
  • Fits in emonTH enclosure
The main downside perhaps of this design is that in order to get it into the emonTH case I needed to drop the number of CT inputs down from 3 to 2, the thinking being that most applications are house consumption + solar pv. But Im aware that this does make is unsuitable for 3 phase application, we do want to develop a dedicated 3 phase board design with voltage sensing on each phase so perhaps that's the better option for 3 phase application than using the emontx.

I've sent off for a first prototype PCB from ragworm so will be building and testing this design hopefully next week. Id welcome thoughts on the design and any suggestions and may do another revision before getting these made in quantity.

Common component kit

The other idea we've had is that since the emonglcd and emontx kit share so many of the same resistors and capacitors we could potentially offer a general openenergymonitor throughhole component kit with enough of the common components to build an emonglcd or several emontx kits. Then alongside the common component kit would be the PCB and emontx/emonglcd specific components such as the LCD, connectors and perhaps the atmega. We're' just working out the pricing for this. This could be quite a good option for people who have good home electronics stocks of different resistors/capacitors and could simplify the kitting for us with just one kit with 10x 20x of all the different resistors and capacitors. Interested in hearing people's thoughts on the idea.

This blog post is a repost from the forum thread here:

Investigating the embodied energy of the EmonPi & OSCEDays London 12-14th June.

On the 12th – 14th of June there is an event happening called Open Source Circular Economy Days in many cities around the world, including in London which we will be attending. I first found out about the event from Lars Zimmerman who is on the core organising team and I met last year at OuiShare, Lars runs encouraging and helping people incorporate open source in their businesses, organisations and projects. The aim of Open Source Circular Economy Days is to bring open source thinking to the circular economy. The energy associated with manufacturing is a large part of our overall energy consumption and the question of embodied energy especially in the zero carbon energy sector is particularly important to understand better. There is quite a bit of discussion at the moment about the level of energy return on energy invested EROI required from the zero carbon energy sector as a whole in order to sustain a certain level of technological society.

My impression of trying to look into embodied energy and life cycle analysis is that it seems that the measurement of embodied energy and other impacts associated with manufacturing our stuff and then the understanding of what solutions are available to reduce this embodied energy, especially in electronics is still in its infancy compared with other energy demands that we are more familiar with like the solutions available for space heating and transport, both of which have solutions that can achieve 70-90% energy reductions without reducing the level of comfort or distance travelled

We're particular conscious of this question at OpenEnergyMonitor as we get our hardware manufactured and see the quantity of stuff involved in the production of our equipment. It has always been interesting to read about developments from other projects and companies who have been looking at this for sometime but in different fields predominantly outdoor clothing: and They have often achieved quite substantial improvements by looking at their materials, and supply chains in detail.

With Open Source Circular Economy Days coming up and after talking to Erica Purvis of who is one of the organisers of the London even we decided to try and sketch out a draft initial analysis of the embodied energy associated with the emonpi to take along with us. I emphasised its initial status there because I don’t have a high confidence in the reliability  of the data at the moment but I think it does provide a useful start on which further detailed research can be done.

Embodied Energy Audit Process

With a little research I found an example of an embodied energy analysis for an LED light with an accompanying dataset for the embodied energy of different components here: this example referenced data from the European commission project  Eco-design of energy-using products:

I then calculated an estimate for embodied energy by using the embodied energy dataset from these two sources and a detailed list of components for the emonpi including the weight of each component. The spreadsheet with the calculation can be downloaded here on the EmonPI open hardware github repository:

here's a screenshot of what it looks like:

I have summarised the main results in these two graphics:

Interestingly the application of the embodied energy values in the dataset suggest that at least for the parts that we are most involved in the custom design of (The EmonPi Shield and the aluminium enclosure) the embodied energy is dominated first by the enclosure at 10.1 kWh and then by the manufacturing of the printed circuit board (2.2 kWh) and the assembly of the unit (1.6 kWh). The integrated circuits only account for a relatively small percentage at 0.2 kWh.

Aluminium enclosures
The estimate for the embodied energy of the aluminium enclosure is based on the 40 kWh/kg figure in Sustainable Energy without the hot air. This equates to 144 MJ/kg which is lower than a couple of other figures I could find for standard aluminium embodied energy. The Wikipedia figure is 155MJ/kg and is based on a 33% recycling rate. The figures I could find for the embodied energy for aluminium from bauxite where between 191MJ/kg and 342MJ/kg. The enclosure made from aluminium from bauxite could at the higher end use 24 kWh and at the lower end require 16 kWh. 100% Recycled aluminium however only requires between 11.35MJ/kg and 17MJ/kg. The EmonPi manufactured from 100% recycled aluminium would therefore only need between 0.9 - 1.3 kWh to manufacture. The EmonTH ABS plastic case is about a third of the size of the EmonPI case and weighs 32g it had an embodied energy of around 1.0 kWh (111MJ/kg). A plastic EmonPi case might weight about 3x this (~90 grams) and so may use around 3.0 kWh. The aluminium would need have been recycled around 7-8 times to achieve the same level of embodied energy as an ABS plastic enclosure. There are also lower embodied energy plastics available such as Polypropylene (64-94MJ/kg) and recycled PET  may use around 42-55MJ/kg and then perhaps there are even more options in the design of enclosures to minimise the amount of material used.

Manufacture of printed circuit boards and assembly

Beyond learning more about enclosure options it would be useful to focus on getting a better idea for the reliability of the data for printed circuit board manufacturing and assembly and what options exist to lower their embodied energy requirements.

If your interested in learning more about the Open Source Circular Economy days event or joining us at the event in London have a look at the event pages here:

Useful links and references:

Introducing emonTH V1.5

The emonTH Temperature and Humidity wireless sensing room node is back in stock in the shop today with an updated version to V1.5.

V1.5 is a minor hardware update adds support for RFM69CW radio and includes a DIP -switch which allows setting four RF node ID's (19-22) easily and quickly. See emonTH wiki for updated documentation

emonTH V1.5 with DT22 Temperature and Humidity Sensor
emonTH V1.5 with RF node ID DIP switch and RFM69CW

emonPi Vs emonTx V3 Comparison

Here's a quick comparison table comparing the emonPi (currently active on Kickstarter!) to our existing emonTx V3 energy monitoring unit:

emonTx V3

It is no secret that there is much similarity between the two units, both are cut from the same cloth. Both units use the same ATmega328 Arduino IDE compatible microcontroller and front-end CT channel signal processing which gives identical monitoring accuracy. 

The emonPi is most suitable over the emonTx V3 for home or small business whole circuit energy monitoring and also solar PV where Ethernet or WIFI can reach the consumer unit. Being a one-box-solution and with its status LCD the emonPi is quick and simple to install and maintain. 

For larger systems where there could be multiple transmitter nodes and more channels to be monitored the emonTx V3 could be most suitable. The emonTx V3 transmits it's readings via RF (433Mhz) to an emonBase web-connected base station (Raspberry Pi + RFM69Pi). Multiple emonTx V3's can be used with a single emonBase

The emonTx V3 has the edge over the emonPi when it comes to powering the unit, the emonTx V3 can be powered directly from the AC-AC adapter while also taking an AC voltage waveform sample. Due to the higher power requirements of the Raspberry Pi the emonPi requires an additional 5V DC USB adapter. 

Struggling to decide? It's also worth noting that the emonPi and emonTx V3 can work together. emonPi by default also functions as an emonBase; as well as local monitoring the emonPi can receive data via RF from multiple emonTx V3 and other remote nodes such as emonTH temperature and humidity room node. 

For further details of the units see the Technical Wiki documentation pages.

Introducing emonPi: Raspberry Pi based energy monitor

emonPi Raspberry Pi based energy monitor Kickstarter

It's an exciting time for us; this week (on the 1st April, unfortunate timing!) we launched a Kickstarter crowd funding campaign for our emonPi Raspberry Pi based energy monitoring unit

The emonPi has been in development for the past 12 months or so, if you have been lurking on the forums you have probably seen activity on the emonPi's open development forum thread. Thank you everyone who contributed. 

The emonPi has been developed with input from the community, merging the monitoring unit and web-connected base station into a single easy to install and setup energy monitoring solution. 

The emonPi is fully open source hardware and software. It's been designed for maximum hackability and customisation being built on a fusion of two popular open source hardware platforms Arduino and Raspberry Pi.

emonPi Technical Features 

  • Two channel CT monitoring with AC sample input 
  • Compatible with Raspberry Pi model A, model B, model B+ and Pi 2 
  • Arduino compatible ATmega328 with ability to remotely upload sketches vis Raspberry Pi Serial 
  • RJ45 DS18B20 on-wire temperature bus to allow many temperature sensors to easily be added using a RJ45 breakout board for heat pump monitoring applications 
  • PWM and IRQ I/O's on RJ45 
  • Status LCD with function push button
  • Raspberry Pi shutdown button
  • RFM12B / RFM69CW with SMA antenna to receive or transmit data from other sensor nodes
  • Option to add OOK (on-off keying) transmitter footprint for controlling remote plugs etc. 
  • Option to add EEPROM to enable Raspberry Pi HAT compatibility (please get in contact if you have experience setting up Linux device tree). 
  • Open-source hardware, firmware and software 
  • High quality custom made, wall mountable enclosure
See the emonPi wiki for more technical info (currently under development).

We had fun filming a Kickstarter promo video, demonstrating some applications of the emonPi, Emoncms and the OpenEnergyMonitor system installed around where we are based in the mountain of North Wales, UK.  

Here's a video showing the emonPi installed and talking through how setup will work in practice. Having the LCD to show local IP address, status and uptime etc will no doubt make the system much more user friendly and accessible. 

The Kickstarter will be running until Apr 20 2015 9:46 PM BST, if we haven't reach our funding goal by then we will get nothing! Please help us share and spread the word :-)

Please help us by sharing our Kickstarter page with interested parties

We believe the opportunities and benefits of taking an open-source approach to smart monitoring and control challenges are significant; we hope to encourage others to start projects & businesses that also work towards a zero carbon future in an open way. 

Energy Display Options...

Sadly as of last week we have run out of emonGLCD kits in the shop and have decided to discontinue the emonGLCD for the moment. Preparing the through-hole kits is very labour intensive and the time and skill required to solder assemble is lagging behind our other pre-assembled SMT units.

Work has begun on a SMT pre-assembled replacement (see forum thread). However this would probably require significant investment in injection moulding tooling and commitment to high volume production. This would not would be a problem if we were sure on the design. However, I'm not sure if a standalone display is the right avenue to go down...

I am aware there that there is certainly value in an 'always on' wall mount / coffee table energy display. Being able to easily glance at the display throughout the day when your home really does remind me to switch off lights and appliances when not in use. As well as checking everything is turned off (base level energy consumption) when leaving the house. An always on display gives users a 'feel' for how much energy various devices use as the display increases or decreases in real-time as a device is switched on or turned off.

The future is mobile, everyone has at least one mobile device and increasingly as these devices are upgraded there are a large number of perfectly working just a bit slow older devices which could easily be given a second life as an energy display. This could help reduce the number of devices which end up being recycled or worse put into landfill, therefore helping to save energy in more ways the one! Old second hand android phones or tablets can be picked up on Ebay for less than we could make an emonGLCD!

I recently repurposed an old Nexus 7 tablet (2012 model) with a cracked screen as a home energy display displaying Emoncms MyElectric. I installed an app to keep the screen on all the time when plugged in charging. The tablet uses 5W of power. An added advantage of using a mobile device as an energy display is they are 'mobile'! The display can easily be moved around the house to support investigation power consumption of various appliances.

Much work could be done on the software side to make a really nice packaged android app for Emoncms which would support an energy display mode, useful features might be:

  • Intelligent screen-on-off e.g the display could turn off at night, when energy falls to base level consumption indicating the house is unoccupied 
  • Using the tablets motion / proximity / light sensor to sense movement to turn screen on-off
  • If device has an AMOLED display only certain pixels could be lit up to save power, like on the Moto-x Active Display 
  • Auto start at startup and full screen mode 
  • Home screen widget to be used if user does not want to decicate a devices solely as an energy display or to be placed on current mobile home screen to enable quick checking of power consumption / temperature etc when out and about.    

Emoncms MyElectric on Nexus 7 with cracked screen

A super low power alternative could be to use an old e-reader with an E-ink display. Here's Emoncms MyElectric running on a hacked Nook Touch.

Emoncms MyElectric on Nook Touch
Head over to the forums and let us know what you think...

Real World emonTH Battery Life

The battery on my home emonTH Temperature & Humidity Node has just died for the second time in 14 months. Each set of batteries lasted exactly 221 days (7 months and 9 days)! The 2 x AA alkaline battery voltage started at 3.1V and the emonTH stopped working just after the voltage dropped below 1.2V (final dying breath was at a battery voltage of 0.8V!).  The two AA batteries installed were low cost alkaline batteries unbranded from e-spares. Battery life would not doubt be longer from some quality cells. 

I recommend using rechargeable alkaline batteries if possible in the emonTH, for least environmental impact. See my previous posts on emonTH battery selection and power consumption optimisation

My emonTH had a DHT22 temperature and humidity sensor connected and was set to the default post rate of one minute in-between samples. The unit was running V1.0 firmware (the firmware is now at V1.2, there have been a couple of minor battery life improvements). 

It's very impressive how the DC-DC boost converter onboard the emonTH continues to boost the depleting battery voltage to 3.3V, using this method allows the battery to be drained much further than powering the unit directly.