ResourceKraft News & Updates

News and updates from the energy sector and everything that goes with it from the latest market trends to the ramblings and insights from the brains of our energy engineers & designers.

Liam Relihan

Recent Posts

Data Analytics & Application in the Energy Sector

Data Analytics & Application in the Energy Sector

Liam Relihan News & Updates

Attended a lecture this evening at Engineers Ireland by Jennifer Jennings, a data scientist at ESB (Irelands main Electric utility). She dropped some good understandings on us regarding ESB’s use of data analytics/data science/machine learning to solve problems of interest to energy utilities. Particularly of interest, was their approach to detection of partial discharges for power line fault detection.

Benfords Law and Energy Data: A Mathematical Aside

Benfords Law and Energy Data: A Mathematical Aside

Here is what Wikipedia has to say about Benfords Law:

Benford’s law, also called the First-Digit Law, refers to the frequency distribution of digits in many (but not all) real-life sources of data. In this distribution, 1 occurs as the leading digit about 30% of the time, while larger digits occur in that position less frequently: 9 as the first digit less than 5% of the time. Benford’s law also concerns the expected distribution for digits beyond the first, which approach a uniform distribution.

It has been shown that this result applies to a wide variety of data sets, including electricity bills, street addresses, stock prices, population numbers, death rates, lengths of rivers, physical and mathematical constants,[1] and processes described by power laws (which are very common in nature). It tends to be most accurate when values are distributed across multiple orders of magnitude.

So, does it apply to energy data? Well I ran a little SQL query on 150 million records of 15-minute energy data I had lying around. Here is the distribution of the digits:

“1” 49647887
“2” 27419091
“3” 18099660
“4” 14904116
“5” 13496329
“6” 10929017
“7” 9671925
“8” 7708455
“9” 6564295

and here is the distribution chart:

The vast majority of the data analysed are electricity usage data measured in watt hours. However, there are also gas and water usage data in there also. I left out negative numbers for simplicity (negative numbers can legitimately occur when energy is being produced, i.e. exported).

So yes! Benfords law is alive and well in 15 minute energy data. But why does that matter? In the case of our energy data, it demonstrates its veracity and the effectiveness of our data acquisition and data management on a large scale….and its just kind of interesting.

Understanding Your Utility Bill: Electricity (Ireland only)

Understanding Your Utility Bill: Electricity (Ireland only)

Before you can start seriously addressing your business energy costs, you need to understand how to read your energy bills. Now, the Irish energy utilities issue bills that are often (ahem!) less than tractable. This is a simple tutorial to help you read and understand them.

Getting to Grips with the Detail

The first step, when comparing any bill, is to check the billing period as the number of billing days in each month vary, having an effect on your bottom line. The next thing to check is that the tariff (e.g. Low Voltage Max Demand) has not changed without your approval. You should also be aware that some tariff types are seasonal (e.g. Summer/Winter) so you might see an increase in the cost of an October bill V’s September as we move into the winter period. This will usually be reflected by a change in the unit rates.

You should continue through your bill comparing each line item with the previous months. The consumption can, of course vary, depending on the operations at your site but you should be aware of these changes and understand how they impact consumption and cost. For example, you may have run extra shifts this month to meet customer demand. Look for any one line item that appears to have increased considerably and question why this might be the case. Also, look out for any surcharge items, e.g. Low Power Factor Surcharge. This indicates that you have been charged for abnormal usage, that may have been prevented, at your site.

There are three main ways to reduce the cost of your electrical energy bill:

1. Reduce your energy consumption.

2. Change/Negotiate a more favourable tariff with your utility supplier.

3. Ensure your Maximum Import Capacity (MIC) is correct and you are not paying for additional capacity you do not use. You should seek professional advice when making any changes to your MIC.

1. MPRN:

Metering Point Reference Number, this is a unique number used to identify your meter network connection.

2. DG MC Profile:

Used to identify user configuration and usage profile. The band which your organisation fits into can dictate the rates at which you will buy your electricity.

3. Billing Period:

The period within which your electricity consumption is billed.

4. Standing Charge:

The standing charge that appears on your bills for both gas and electricity goes toward the maintenance of the country’s gas and electricity infrastructure i.e. gas pipes and electricity pylons. This charge is a fixed daily rate and is site dependent.

5. Day Rate:

This charge is applied between the hours of 08.00 to 23.00. This rate is agreed during negotiations with your utility provider.

6. Night Rate:

This charge is applied between the hours of 23.00 – 08.00. This rate is ALSO agreed upon during negotiations with your utility provider.

7. Service Capacity Charge:

Maximum Import Capacity (MIC) is the level of electrical capacity contracted between your business and ESB Networks. The service capacity charge on your bill is based on your contracted MIC level. The unit of measurement for MIC is the kilovolt ampere (kVA)

8. PSO Levy:

Public Service Obligation Levy, is a government subsidy that is charged to all electricity customers in Ireland. The money collected from the PSO Levy is used to subsidise renewable energy generation and peat burning power plants.

9. DUoS Charge:

A DUoS charge is a fee that ESB Networks charges your Electricity Supplier for use of the Electricity Distribution System. This is a toll for the use of the ESB Networks Distribution network.

10. TUoS Charge:

The Transmission Use of System charges are the charges associated with provision of access to and use of the transmission grid. The revenue collected from TUoS is used to cover the cost of operation, planning and development of the transmission network.

11. LPFS:

The Low Power Factor Surcharge applies when the metered wattless power is more than one third of the metered kWh (in any two monthly billing period). The charge is applicable to the kVARh in excess of one third of the kWh.

12. Electricity Tax:

This is a charge applied by government on each unit of electricity consumed.

We will shortly do a follow-on post for gas bills.

Messing About with LoRa

Messing About with LoRa

In RK, we count ourselves among the pioneers in the use of low power radio for AM+T so we continue to keep an eye on the emerging technologies. One of these technologies is LoRa which is being aimed at a bunch of different IoT applications. LoRa can operate in two modes: peer-to-peer and LoRaWAN. LoRaWAN is ultimately the way to scale this technology and we will have a future blog entry on what we are doing to deploy a LoRaWAN basestation at our offices. In the meantime, lets have a look at what it takes to do some peer-to-peer testing.

First of all let me give credit to Paul who wrote this article. I’m going to refine it a little to make use of the equipment that we had at our disposal.

What we want to do in this post is to show how easy it is to do some very basic range testing with two LoRa devices, one operating as a transmitter and the other as a receiver.

The Motes

First of all we ordered two Microchip LoRa motes here. These operate on 868MHz (the legal frequency in Ireland and many other parts of the world). These are nice little gadgets with an OLED screen for reporting status. Also, there is an onboard PIC MCU. This means that you can write little programs that will allow the gadget to act in an untethered way.

Communicating with the Motes

The motes are based on the Microchip RN2483 LoRa modem. The RN2483, like a lot of devices these days, can be configured and operated with simple console commands. The list of available command can be found in this PDF. There are 3 levels of commands:

  • sys for system command
  • mac for LoRaWan protocol related command
  • radio for low level radio transmission

The command sys get ver returns the firmware version, it is a good way to ensure the mote works.

sys get ver
 RN2483 1.0.1 Dec 15 2015 09:38:09

Plugging in the Transmitter

I plugged one of the motes into a SolidRun CuBox-i that we had lying about. This uses the standard Debian distro that can be downloaded off SolidRuns website. I cannot see why you could not use Beaglebone Black, RPi or any other Linux/ARM setup for this.

Plugging in the Receiver

I plugged the other mote into my mac. This will be the receiver.

Transmitter Software

On the SolidRun, you need to take Paul’s script and run it. You may find that the serial port needs to be changed from /dev/ttyUSB0. The mote pretends to be a modem so it calls itself /dev/ttyACM0 in my case. This meant that i called Paul’s script as follows:

bash /dev/ttyACM0

Here is Pauls script:

# LoRa loop send a message in loop over LoRa medium at default frequency
# module is connected to /dev/ttyUSB0 device

startRet() {
   (if read -t 3 ret < $dev; then echo $ret ; return 0 ; else return 1 ; fi) &
checkRet() {
   wait $wf
   return $?

stty -F ${dev} 57600 cs8 -cstopb -parenb -echo

startRet ; echo "sys get ver" > $dev
if checkRet ; then
  startRet ; echo "mac pause" > $dev
  if checkRet ; then
     startRet; echo "radio set pwr 14" > $dev
     if checkRet ; then
        while true ; do
           echo emiting $i
           startRet ; echo "radio tx 123456789AB" > $dev
           sleep 100
           i=$(( $i + 1 ))
     else echo "error setting power"
  else echo "error setting mac in pause"

else echo "cant establish communication"

Setting up the Receiver Side

On my mac, I coded up the following dirty little thing in python:

import serial
import time
import datetime
import sys


def readlineCR(port):
    rv = ""
    while True:
        ch =
        rv += ch
        if ch=='r' or ch=='':
            return rv

def sendcmd(cmd):
    if echo:
        print (">>"+cmd)

def sendcmdprintresp(cmd):
    rcv = readlineCR(port)
    print "<<"+rcv

port = serial.Serial("/dev/tty.usbmodem1421", baudrate=57600, timeout=3.0)

sendcmdprintresp("sys get ver")

sendcmdprintresp("mac pause")

while True:
    sendcmd("radio rx 0")
    #print "<<"+resp
    if (resp == "ok"):
        while True:
           if (resp.startswith("radio_rx")):
               print "aRECEIVED at "+str(": "+resp.split("  ")[1]
           elif (resp.startswith("radio_err")):
               print "RECEIVED error"

        print "ERROR: "+resp
        print "WAITING TO CLEAR"

This assumes that the port is at /dev/tty.usbmodem1421. In my case it was but you will probably need to change it for your system. You will note that this prints an ASCII BELL character so you can hear each ping as it arrives.

Running the Tests

So anyhow I set everything up in the lab such that the mac was pinging nicely. To increase the frequency of the pings from every 100 seconds, you might want to change the "sleep 100” to something like “sleep 30”.

I left the transmitter in our lab. This lab is on the top floor of a four story building in Limerick city centre - a town that is mostly low-rise. This means that we are relatively high up with respect to much of the the local building stock. However, our building has a lot of metal along with a metal roof so I expect attenuation to be significant. To put it another way, my transmitter was placed in a rather sub-optimal location.

I then took the receiver to the basement car park of our building and I received every ping. This is impressive - you would certainly not see this with something like Zigbee unless you installed a bunch of repeaters.

Then I went driving to see where the range faltered. This map shows where I began receiving either 1) mostly errors or 2) nothing. The performance to the West was very good and this is not wholly surprising as there are far fewer buildings in this direction. Also the transmitter is situated above this low-lying region.

The performance to the East was less impressive. Right now I associate that with the extra building density and the urban canyon effect along with the rise and fall of the terrain - Limerick is built on some gentle rolling hills.

Overall, this technology looks very promising even when deployed in absolutely lousy conditions, like I just did. Very shortly we will be deploying a LoRaWAN base station for Limerick on The Things Network and we will be doing this in a much more professional way.

Understanding Your Utility Bill: Natural Gas (Ireland only)

Understanding Your Utility Bill: Natural Gas (Ireland only)

Following on from my post on understanding your electricity bill, here we aim to improve your understanding of your Irish Natural Gas bills.

The Detail

The first step when comparing any bill is to check the billing period, as the number of billing days in each month vary having an effect on your bottom line, often you will find with gas bills that they are either estimated (indicated by the letter E after the meter reading value) or have a consumption period that is not the standard calendar month due to manually meter readings.

You should continue through your bill comparing each line item with the previous months, the consumption can of course vary depending on the operations at your site but you should be aware of these changes and understand how they impact on consumption and cost (e.g. there was a particularly cold snap and the heating was running for longer). Look for any one line item that appears to have increase considerably and question why this is?

There are two main ways to reduce the cost of your gas energy bill:

• Reduce your energy consumption

• Change/Negotiate a more favourable tariff with your utility supplier

Your Gas Bill Explained

Here is a typical gas bill. We have marked the main items and provide an explanation below:

1. Conversion Factor

The conversion factor is a metric used to convert the m3 “meters cubed” of gas that you consumed and translates it into kWh “kilo Watt hours” of energy consumed. This metric is subject to minor changes on monthly bases from your utility supplier.


“Gas Point Reference Number” is your unique identification code which identity’s your meter and connection to the main gas network.

3. AC Band

The AC Band is a letter that identifies the amount of energy you typically consume in a year. This can impact on your Gas Commodity Tariff which you negotiate with your utility supplier. The bands are as follows….

A: Less than 6,000kWh
B: 6,000kWh to 23,500kWh
C: 23,500kWh to 73,000kWh
X: 73,000kWh to 750MWh
Y: 750MWh to 5,500MWh.

4. Consumption Period

Is the period of time that the bill is calculated on April 1 – April 30.

5. Gas Commodity Charge

The gas commodity charge (cent per kWh) reflects the monthly unit rate of wholesale gas. Natural gas is purchased in sterling on your behalf in the UK natural gas wholesale market. The cost of natural gas varies according to demand and supply.

6. Carbon Tax

This is a governmental charge implemented to tax all co2 emissions. The amount of co2 emitted depends on how much energy you consume. Example 0.194 kg CO2 / kWh of energy consumed or 11 kWh/m3 so that’s 2.134 kg CO2 / m3.

7. Fixed Rate Charge

The Fixed Rate Charge (c/kWh) incorporates those costs which depend on the volume of gas supplied where the appropriate rate of cost recovery (per kWh consumed) remains constant through the gas year and does not vary between customers. This charge consists of transmission commodity tariffs, distribution commodity tariffs, UK transportation costs, swing flexibility and an approved margin on total costs. This is a per kWh charge for the provisioning of gas to your site.

8. Site Charge

The standing charge that appears on customers’ bills for both gas and electricity goes toward the maintenance of the countries gas and electricity infrastructure i.e. gas pipes and electricity pylons. This charge is a fixed daily rate, market pressures influence what the utilities choose to apply.

9. Gas Shrinkage Charge

Gas Shrinkage charge means the cost of the Natural Gas which is used by the Transporter for the operation of the Transportation System including, inter alia, at compressor stations and lost or otherwise unaccounted for from the Transportation System or any part of the Transportation System.

Pretty Sparkline Charts with jQuery Sparklines

Pretty Sparkline Charts with jQuery Sparklines

Sparklines are the brainchild of Edward Tufte. They are those “intense, simple, wordlike graphics” that you sometimes find embedded in stock listings and such like.

To help our installation team we have created a little application that runs on installer’s smart phones. This application is written in PHP and is designed to show live energy streamed from our Canary embedded data acquisition devices.

Rather than just show constantly changing energy numbers, we added a little sparkline alongside each number to show the history of that number. Anyhow, probably the most trivial way we could find to do this was jQuery Sparklines which was written by Gareth Watts for Splunk Inc and released under the New BSD License

Anyhow to make this work for your first demo, you need to install the sparklines library in your Javascript/ folder and enter just a little code.

<!DOCTYPE html>
Copyright (c) ResourceKraft Ltd. 2015

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Display Device Stream</title>
<script src="">   </script>
<script type="text/javascript" src="Javascript/jquery.sparkline.min.js"></script>

<script type="text/javascript">
$(function () {

<h1>MODBUS Slave Analysis</h1>
<P>Last Update: 3 seconds ago


<dt>i1</dt><dd>9.00 amps<span class="inlinesparkline">30.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,11.0,12.0,10.0,9.0</span></dd>

<dt>i2</dt><dd>5.00 amps<span class="inlinesparkline">30.0,20.0,4.0,5.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,5.0,10.0,11.0,12.0,0.0,0.0,5.0,5.0,5.0</span></dd>

<dt>i3</dt><dd>23.00 amps<span class="inlinesparkline">30.0,20.0,4.0,5.0,5.0,10.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,11.0,12.0,0.0,0.0,30.0,24.0,23.0</span></dd>




<dt>i1</dt><dd>77.00 amps<span class="inlinesparkline">30.0,20.0,4.0,5.0,5.0,11.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,12.0,0.0,0.0,30.0,20.0,90.0,66.0,66.0,77.0</span></dd>

<dt>i2</dt><dd>6.00 amps<span class="inlinesparkline">30.0,20.0,4.0,5.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,5.0,11.0,12.0,0.0,0.0,30.0,20.0,4.0,5.0,5.0,6.0</span></dd>

<dt>i3</dt><dd>33.00 amps<span class="inlinesparkline">30.0,20.0,4.0,20.0,4.0,5.0,5.0,10.0,11.0,12.0,10.0,5.0,5.0,30.0,11.0,12.0,0.0,0.0,30.0,25.0,22.0,23.0,33.0</span></dd>


Leaky Bucket Algorithm

Leaky Bucket Algorithm

Liam Relihan News & Updates

Occasionally, we aim to publish something that has to do with how we implement our hardware and software solutions. Here is one of these “somethings”….

On one of our embedded devices there is the facility to automatically dispatch text messages in response to particular events. However, to protect against the possibility of the device sending out a storm of text messages (e.g. due to a bug in the event detection code), we decided to create a little algorithm to limit the generation of messages in any given period.

To do this we used a little algorithm from the computer networks field called the “leaky bucket” algorithm. Here is what it does…
when the user wishes to do a controlled action (e.g. send an SMS), he tries to add a “drop” of water to the “bucket” using addDropToBucket()
addDropToBucket() checks to see whether some drops should have leaked out since the last call. If so, it lets them leak
then addDropToBucket() checks to see if there is space in the bucket for a single drop. If there is, it adds the drop and returns true, otherwise it returns false
if the user receives “true” he carries out the controlled action, otherwise he doesn’t.

Essentially, the metaphor is that of a leaky bucket leaking out water at a certain rate.

Finally here’s the java code to make it all happen…

     * Leaky bucket algorithm to prevent huge amounts of SMS text messages
     * from being dispatched by any insane processes. Each SMS message
     * sent adds a drop to the
     * bucket which leaks at a constant rate. Once the bucket fills, no
     * message can be sent until a drop has leaked out.
    private class LeakyBucketLimiter {

        private int numDropsInBucket = 0;
        private Date timeOfLastDropLeak = null;
        private final int _BUCKET_SIZE_IN_DROPS = 20;
        private final long _MS_BETWEEN_DROP_LEAKS = 1000 * 60 * 60; // 1 hour

        public synchronized boolean addDropToBucket() {
            Date now = new Date();
            // first of all, let the bucket leak by the appropriate amount
            if (timeOfLastDropLeak != null) {
                long deltaT = now.getTime() - timeOfLastDropLeak.getTime();
                // note round down as part of integer arithmetic
                long numberToLeak = deltaT / _MS_BETWEEN_DROP_LEAKS;
                if (numberToLeak > 0) { //now go and do the leak
                    if (numDropsInBucket <= numberToLeak) {
                        numDropsInBucket = 0;
                    } else {
                        numDropsInBucket -= (int) numberToLeak;
                    timeOfLastDropLeak = now;

            if (numDropsInBucket < _BUCKET_SIZE_IN_DROPS) {
                return true; // drop added

            return false; // overflow

    // here is how you use it
    bucketLimiter = new LeakyBucketLimiter();
    if (bucketLimiter.addDropToBucket()) {
        // dispatch SMS


The above might seem a little excessive, but long term reliability in our measurement and control devices is a really big thing for us. Ideally, each device needs to be able to take care of itself for many years at a time – in fact virtually all of the devices that we installed in our first year of operation 7 years ago are still running. Most have never once being touched by a human hand.

Why Ireland Needs to Get With Engagement…

Why Ireland Needs to Get With Engagement…

Liam Relihan News & Updates

It’s due to become one of the major political hot potatoes over the next couple of years, but many people don’t yet realise that Ireland has signed up to massive carbon reductions by 2020. In the 2007 Government White Paper, Delivering a Sustainable Energy Future for Ireland, a target has been set for a 20% improvement in energy efficiency across the whole economy by 2020. The White Paper also states an ambition to surpass the EU target of 20% with an indicative target of 30% energy efficiency by 2020. Furthermore the paper states that the public service is to take an exemplar role in energy efficiency, with a savings target of 33% by 2020. These targets are incredibly ambitious especially given that Ireland is now a mere 5 years away from 2020.

If Ireland is to achieve even a fraction of these targets without “lawyering” its way out of commitments, it will need to drive action on a range of fronts, including mass retro-fit programmes, financial incentives, financial penalties, and engagement. Central government bodies such as the SEAI are doing a great job with what resources they have. However, there are simply not enough energy experts in the country to do what needs to be done over the next five years.

Customer engagement is increasingly being seen as an extremely effective way to employ individuals to implement their own energy efficiency improvements. Customer engagement uses the power of modern communications technologies to empower customers to interact with their energy providers more easily using the communications channels they prefer. The fact is that Irelands energy utilities are a key part of the solution and they are being woefully under-utilised in the race to 2020. In the United States, utilities are deploying customer engagement programs to achieve greater participation in existing energy efficiency programmes, improved their customer satisfaction ratings, and increase stickiness with their existing customers (because ‘churn’ is the great bane of energy retailers lives).

It is ResourceKraft’s contention that utilities must be leveraged urgently in the final straight to 2020. They must be provided with the tools and the incentives to do the right thing for their customers (and by extension the national 2020 targets). This practically means:

  • energising and empowering customers to modify the way they use energy
  • educating customers about grants and incentives for energy efficient equipment
  • providing high quality information showing customers how they rate against their peers
  • demonstrating that money saved on energy is good for their bottom line, especially if they are businesses

ResourceKraft is already developing technology for such engagement programmes elsewhere in the world, especially the United States. As such it believes that it can bring substantial innovations to the Irish markets. In 2015, ResourceKraft intends to bring its knowledge to government bodies and utilities to show how energy consumers can be part of the solution. In practical terms, it can bring the following to bear:

Smart bills are beautifully formatted energy bills that don’t just show KWh used and costs incurred. These bills will also offer practical, customised advice on how to tackle energy costs

Clever, innovative, data-driven approaches to energy consumers using the latest social media techniques that demonstrate that their energy bills are controllable

Giving customers a good reason to engage with their energy utilities in their efforts to reduce energy costs

Liam Relihan

Dragonfly and the Implications for Irish Businesses

Dublin, Ireland

Yesterday, Liam Relihan, the CTO of ResourceKraft, a Limerick-based supplier of energy management systems warned that Irish businesses and government institutions were vulnerable to an ever larger collection of cyber attackers. He stated that “the Building Management Systems (BMS) and SCADA systems that have been deployed by Irish businesses and government bodies present an increasing attack vector for would-be hackers. Software systems that control water pumping stations and production lines are increasingly being attacked by well-organised groups. These systems were, in some cases, designed in the eighties or nineties and are simply not designed from the ground up to be secure in the hostile environment of the Internet”.

Mr. Relihan explained that dragonfly uses a range of techniques that have evolved over time to infect products provided by companies, which sell Building Management Systems (BMS) and SCADA systems to industrial, commercial and government customers.

He went on to say that :

“the recent Dragonfly campaign has exposed the fact that public utilities are now a target, at a time when increasing automation is needed more than ever to drive efficiencies and to reduce costs”

It is believed by security researches like Symantec and F-Secure that the dragonfly attacks were developed to gather information from the organisations targeted, and open a backdoor for future sabotage. Dragonfly’s targets include energy grid operators, electricity generating businesses, pipelines and suppliers of industrial equipment to the sector in the US, Spain, France, Italy, Germany, Turkey, and Poland. However, Mr Relihan said there was every likelihood that future attacks would be widened to include Ireland-based organisations. He stated that the problem was compounded by the fact that control systems are increasingly being connected to the cloud to provide for more centralised control. While centralised control is an obvious benefit, it means that what might previously have been relatively secure systems are now vulnerable to a range of attacks.

Mr. Relihan says that in his conversations with ResourceKraft customers, he encourages customers to sever any open connections to vendors that give them “back door” remote access to their control system devices. He also discretely mentioned a large multinational based in Ireland that recently installed a state-of-the-art building control system. The system was designed to be attached to the Internet for energy monitoring. However, within hours it had been subjected to cyber-attacks from the Far East. The system has now been disconnected from the Internet.