Tag Archive: Arduino

Despite still having a handful of unfinished projects I decided to take the plunge and have some solar panels installed. I found a local MCS accredited installer MAH Solar Solutions and in no time had the kit up and running. My house faces east/west so I have 8 panels on each side.


The panels are Canadian Solar 250W, total 16 to form a 4KW system fed into a Aurora ONE/PVI 3.6 inverter in the loft.


The solar install was the perfect opportunity to finally replace my ancient fusewire consumer unit. Which got me to thinking of ways I may be able to better monitor my energy consumption. I hoped to find “a magical fuse box” but hours, days, weeks of research and the best solution I could come up with were DIN rail mount KWH meters.

Unfortunately no amount of searching could find a single image of the KWH meters in use or a diagram of how to wire them in a consumer unit. Instinct told me to have each meter mounted alongside each breaker, but this would prevent me from using the busbar. Then I thought about mounting them upside down, but this would cause similar issues and mean running the neutral far too close to the busbar! The next idea was to either mount 2 consumer units side by side, having the breakers in one and the meters in the other… Then I found some information about twin/dual rail consumer units which seemed like a winning idea.

MAH Solar Solutions were to be installing the new consumer unit and despite having never seen or used the KWH meters before they were more than happy to install them. They came up with the idea of mounting the meters at the end of each block of breakers. With a big enough consumer unit this meant the busbar could still be used. I will try and add some diagrams and more images at a later date.


I’m still working the best way to read so many pulse counters simultaneously and log/process the data. Currently http://openenergymonitor.org/emon/buildingblocks/12-input-pulse-counting looks like one of the most promising, but I will need to start from scratch with a way to count, store, transmit etc. So for the time being I decided on the fluksometer which can handle 4 pulse inputs- which will do for now: mains, solar, oven & gas meter.


The flukso service itself provides quite nice graphing- you can see here my mains consumption (blue), oven consumption (green), solar pv generation (red) and gas consumption (orange).


Which feeds nicely to pvoutput.org.


You can see the rj11 cable coming out of the gas meter (to the fluksometer). The purple cable runs from the RS485 port on the inverter in the loft. I am waiting on a USB to RS485 device so I can start pulling some detailed data using Aurora Monitor or similar.


I understand the fluksometer has an onboard RFM12B configured on the 868Mhz band to understand communication from jeelabs devices- which is ideal as I meter my water using jeenodes.


I just don’t know how to get them talking… yet!

An update on my latest project

Further to: https://tickett.wordpress.com/2012/12/31/a-new-year-a-new-project/ I have discovered quite a few things, and it looks like I’m not going to have to start from scratch (although I may still be designing some form of hardware, it’s hard to tell at this point).

Existing projects/products set out to do something similar:

NPlug- http://www.indiegogo.com/projects/283102/x/2060579

  • Consumption measuring (believed to be more accurate than existing devices)
  • Remote switching
  • WiFi connected (requires no bridge/gateway device)
  • Zigbee 802.15.4 for connecting to other devices
  • USB option (add 3G dongle, additional RF interface etc)
  • SoC running OpenWRT Linux
  • Open source
  • Lots more…
  • £100 (estimate)

This is really meant as a single device and not to be used with every appliance in the home. The device acts like a gateway itself and aims to connect to existing consumption/switching devices such as the IRIS / AlertMe suite.
I have pledged as a sponsor for this project, and hope to get my hands on a prototype- however, the funding has been a bit slow, so please help out :)

AlertMe (IRIS)- https://www.alertme.com/shopping

  • Consumption measuring
  • Remote switching
  • Zigbee
  • Requires the SmartEnergy pack as a bridge/gateway to the internet
  • £25

Ubiquiti mFi mPower- http://www.ubnt.com/mfi#m-Power

  • Consumption measuring
  • Remote switching
  • WiFi connected (requires no bridge/gateway device)
  • Comes in 3 flavours: Single, 3 socket extension cord and 8 socket extension cord
  • Only currently available with US / EU plugs
  • No EU stock currently available (when it is, I will try one with a UK plug adapter)

Belkin WeMo Switch- http://www.belkin.com/uk/c/WSWH

  • Switching only by the look of it
  • WiFi connected (requires no bridge/gateway device)
  • £40

Meter Polug- http://www.indiegogo.com/meterplug/x/2060579

  • Consumption measuring
  • Remote switching
  • Bluetooth only- so unless you’re within range and carrying a bluetooth equipped device, it’s not much good. This being said, the project has been fully funded, so there is clearly demand for such a device.
  • I have asked whether they’ve considered building a gateway device to enable internet connectivity but yet to hear back. Fingers crossed.


  • I have purchased a USB Zigbee packet sniffer in the hope that I can make sense of some of the traffic floating around my house from various “smart” gadgets.
  • Still waiting on delivery of my EVE Alpha board- http://www.kickstarter.com/projects/ciseco/eve-alpha-raspberry-pi-wireless-development-hardwa this should allow me to start doing some cool stuff with a raspberry pi using the gpio pins rather than dozens of USB sticks!
  • The guys over at flukso have confirmed that they will be continuing work on their enhanced hexabus plug once they have another project out of the way: https://www.flukso.net/content/hexabus-plug
  • I sent some details to a few companies in an attempt to understand costings for PCB design, production and assembly. Just one company has responded to date: http://www.newburyelectronics.co.uk/ – for something like the Hexabus plug they’re suggesting (rough figures): £1,000 PCB design (£500 each of the 2), £80 PCB production (£40 each of the 2), £60 parts (excluding several parts they can’t source), £130 assembly & inspection. Bringing the total in at about £270/device (forgetting PCB design)- ouch!

That’ll likely be my last update for a few weeks, as I’m off to Thailand shortly :)


A new year, a new project

*EDIT*: Update on this project https://tickett.wordpress.com/2013/01/10/an-update-on-my-latest-project/

So I realise I have been a little quiet on here lately, and so will make it my new year’s resolution to get back in the habit of blogging regularly.

I would like to share some details of a project I’m assessing for feasibility. It is yet to be named but in essence I’m looking at building an Automated Mains Plug / Socket, let’s call it aPlug.

What do you mean by automated?

  • Remotely switchable / “programmable”
  • Monitor / log power / energy consumption

Don’t these already exist?

  • A lot of rf controllable plugs exist but there are a number of limitations- # cannot integrate with other equipment, # cannot operate from outside of the home, # cannot operate without the supplied remote, # cannot determine current state
  • Some power / energy consumption monitoring plugs exist but again, bare limitations- # cannot integrate with other equipment, # require a gateway device to post data to the internet
  • A few devices even exist which address both requirements but- # cannot integrate with other equipment, # cannot operate from outside the home, # require a gateway device (possibly even an entire pc to post data to the internet), # are expensive, # are closed source

There is however, one possible hope! The hexabus plug: http://signup.hexabus.net/ – I am trying to make contact with the guys behind the hexabus plug to determine where the project is currently, where it’s headed etc. Regardless, the great thing about the project, it is open source- which means the schematic / parts list (BOM) have been published: https://github.com/mysmartgrid/hexabus – unfortunately the PCB layout doesn’t appear to’ve been, but again, I’m hoping it will be shortly.

This project has also sparked the interest of the guys over at flukso, and became the center of a talk at one of their meetings: https://www.flukso.net/files/presentations/flukso.20121026.hack_hexaplug.pdf – where they have suggested a minor tweak to enable interconnectivity with jee labs devices (they include a PCB layout, which suggests they likely have them- I am trying to make contact with them too!)

Even if I manage to make contact and get details of the existing device I still have a lot to tackle…

Network connectivity
I’m currently looking at options, but it makes sense to try and learn from the lessons the guys behind LIFX: http://www.kickstarter.com/projects/limemouse/lifx-the-light-bulb-reinvented
They have essentially gone down the route of creating a mesh network with “slave” devices, then using a “master” device to bridge to the local area network (LAN) and essentially the internet. This ultimate is a gateway device but “in disguise”- and unless I can miraculously find a way of driving down the cost I can’t see any other approach being feasible?

I am making contact with a number of companies who design, produce and assemble printed circuit boards (PCBs) as a number of the components involved in the device cannot be soldered by hand nor can the circuit(s) likely be built using a simple breadboard. I imagine this is going to be a real challenge as the cost for “one-off” or very limited production runs is likely to be extremely high.

Software / Firmware
I have coded some simple arduino / atmega programs in the past, and worked with some of the jeelabs devices but I will certainly be needing assistance to build something as complex as this if it’s going to be robust enough to put “out in the field”. My hope is that developers will show a keen enough interest and we can build something as a community. The devices will be reprogrammable so new firmware can be flashed with relative ease. The problems will come when a hardware change is required…

Regardless of whether a device is faced with mains voltages or whether a device is aimed at developers I anticipate some form of certification being required- this could be tricky (especially on an evolving device).

To gauge interest, boost funding, promote the project and hopefully attract some developers, testers and contributors I would like to run a kickstarter project- unfortunately it’s a little chicken & egg as I need at least some form of prototype before I can reach out to the community. I have however drafted a project so I am prepared if I do get that far: http://www.kickstarter.com/projects/tickett/736265394?token=98a4e52f (so far just some notes, and the reward levels are pure guesswork).

I just knocked the artwork up from a few google images:

I have asked someone to design some artwork for a t-shirt, so I will see if they can come up with a cool concept :)

Where Next?
Yes, it’s far too early to be thinking about that, but I can’t help it!

  • Multi socket extension lead type device with individual socket switching and consumption monitoring
  • aSocket, essentially a mains socket with the device inside so no “plug” is required
  • Other plug types (I am based in the UK so this is where I intend to initially focus)

At this stage I’d appreciate any feedback, or expressions of interest etc

Happy new year to all


More 433Mhz RF Hacking

I touched on the smoke detectors and door/window sensors I ordered last week: – here are a few more details.

The smoke detectors were £5.75 each – http://www.ebay.co.uk/itm/260990530306#ht_3800wt_1385 (all now sold out, but more available on a separate listing from the same seller – http://stores.ebay.co.uk/greatgougo)
The door/window sensors were £2.50 each – http://www.ebay.co.uk/itm/200759112077?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649#ht_500wt_1170 (shop link if/when the listing ends – http://stores.ebay.co.uk/HI-AYY-STORE)

The RF signals broadcast by both devices are not decoded by the RFXCom receiver/transceiver RFXtrx433. This meant finding a way to receive and decode myself.

I already had a few jeenodes (http://jeelabs.com/products/jeenode) knocking about and a 433Mhz plug (http://jeelabs.com/products/ook-433-plug) – there are many alternatives available. I fired up some sketches from the jeelib library (https://github.com/jcw/jeelib/) but wasn’t getting any output when triggering the door/window sensors or the smoke detectors;

I found a discussion on the jeelabs forum (http://forum.jeelabs.net/node/87) which led me to an application called ProtocolAnalyzer (http://wiki.nethome.nu/doku.php/analyzer/start). ProtocolAnalyzer describes a real simple circuit design which brings the RF signal voltage down to a safe voltage to pump into the microphone/line-in port:

I didn’t even have the right components so I improvised:

I only had a 4K7 variable resistor rather than fixed, and I think those fixed resistors are about 370 ohm so I doubled up. I didn’t have any capacitors, so I’ve omitted for the time being but that might be the reason I’m getting slightly inconsistent results as you will see later.

I fired up ProtocolAnalyzer and immediately started to see data coming in (without activating the sensors)- this suggested my CurrentCost devices and such were probably being heard. Many of the signals were being identified as conforming to the "Pronto" protocol, but the data wasn’t very helpful (nor was the way in which it was being displayed). To read the data you had to drill-down on each record. As I ultimately wanted to compare a large result set in an attempt to find patterns and work out which bits/bytes/words meant what this wasn’t really practical.

So I disabled all of the decoders and enabled just the raw signal capture:

I could now drill down and determine the pulse spec:

Which I could then use in an Arduino sketch to capture data. I used the ookRelay2 sketch and modified the Home Easy (HEZ) decoding function to decode my new devices:

class HezDecoder : public DecodeOOK {
HezDecoder () {}
// see also http://homeeasyhacking.wikia.com/wiki/Home_Easy_Hacking_Wiki
virtual char decode (word width) {
if (400 <= width && width < 1600) {
gotBit(width <= 600);
return 0;
if (width >= 3000 && pos >= 5) {
for (byte i = 0; i < 6; ++i)
alignTail(64); // keep last 56 bits
return 1;
return -1;

As soon as I activated one of the sensors data started to flood in:

HEZ 51 85 171 42 51 3
HEZ 166 106 85 101 102 32 51 85 171 42 51 3
HEZ 153 169 90 85 153 3
HEZ 51 85 171 42 51 3
HEZ 51 83 171 42 51 3
HEZ 51 85 171 42 51 3
HEZ 166 106 85 101 102 32 51 83 169 42 51 3
HEZ 51 85 171 42 51 3
HEZ 170 86 85 102 6 50 51 85 171 42 51 3
HEZ 51 85 171 42 51 3
HEZ 204 85 171 42 51 3
HEZ 51 83 181 170 50 3
HEZ 51 85 171 42 51 3

I’m not 100% sure of the reason for the receptions (I think some protocols rebroadcast multiple times to enable validation). Nor am I sure of the reason for the discrepancies (you can see most of the packets are HEZ 51 85 171 42 51 3 but a few contain different values).

I took the most common result and recorded it along with the jumper position (presumably indicating the home code):

I followed a methodical approach of moving the jumpers and recording the result- ending up with a pattern something like:

NNNN-NNNNNNNN HEZ 51 51 51 51 51 3
NNNL-NNNNNNNN HEZ 51 51 51 51 179 2
NNNH-NNNNNNNN HEZ 51 51 51 51 83 3
NNLN-NNNNNNNN HEZ 51 51 51 51 43 3
NNLL-NNNNNNNN HEZ 51 51 51 51 171 2
NNLH-NNNNNNNN HEZ 51 51 51 51 75 3
NNHN-NNNNNNNN HEZ 51 51 51 51 53 3
NNHL-NNNNNNNN HEZ 44 51 51 51 181 2
NNHH-NNNNNNNN HEZ 51 51 51 51 85 3
NLNN-NNNNNNNN HEZ 51 51 51 179 50 3
NHNN-NNNNNNNN HEZ 51 51 51 83 51 3
LNNN-NNNNNNNN HEZ 51 51 51 43 51 3
HNNN-NNNNNNNN HEZ 51 51 51 53 51 3
NNNN-NNNNNNNN HEZ 51 51 51 51 51 3
NNNN-NNNNNNNL HEZ 51 51 51 51 51 3
NNNN-NNNNNNNH HEZ 51 51 51 51 51 3
NNNN-NNNNNNLN HEZ 50 51 51 51 51 3
NNNN-NNNNNNHN HEZ 51 51 51 51 51 3
NNNN-NNNNNLNN HEZ 43 51 51 51 51 3
NNNN-NNNNNHNN HEZ 53 51 51 51 51 3
NNNN-NNNNHHNN HEZ 85 51 51 51 51 3
NNNN-NNNNLLNN HEZ 171 50 51 51 51 3
NNNN-NNNHNNNN HEZ 51 53 51 51 51 3
NNNN-NNHHNNNN HEZ 51 85 51 51 51 3
NNNN-NHNNNNNN HEZ 51 51 83 51 51 3
NNNN-HNNNNNNN HEZ 51 51 53 51 51 3

So I could see that the jumpers in pairs appeared to directly affect each byte of data being returned. I think built this table to demonstrate how I think they correlate:

A0 = Not Used
A1 = Not Used
HEZ AA32 AA54 AA76 DD32 DD10
NN = 51
NL = 43
NH = 53
LN = 179
LL = 171
LH = 181
HN = 83
HL = 75
HH = 85

Next steps:

  • Configure each of the sensors with unique jumper configurations
  • Determine and position the sensors
  • Add the 433Mhz receiver to the jeenode connected to my raspberry pi (running DomotiGa) and modify the sketch to decode these signals as well as receiving 868Mhz broadcasts from other jeenodes
  • Tweak the DomotiGa code to interpret the received data

Jeelabs 433 Mhz OOK Plug

It’d been on back-order for some time but finally over the Christmas break arrived in the post :)

I wired soldered the few parts and tried a few of sample sketches in the Arduino IDE but nothing… I gave up as some other jobs had to take priority.

A few weeks later some discussions kicks off over on the Jeelabs forum: http://forum.jeelabs.net/node/764 and Ed Voncken pointed out a few discrepancies in the documentation and provided some tips on building and testing the board on his blog: http://edvoncken.net/2011/12/assembling-the-jeelabs-ook433-plug-part-1/

My big faux-pas was not soldering the jumper R1 (no resistor is required). I also opted for soldering the bridge between P and the middle pad rather than + (as it looks like the 433 Mhz receiver board is marked up for the + 5V which are provided via PWR as opposed to the + which only provided 3.3V).

Now I fired up the ookScope2 sketch, fixed the pin mappings (OOK_PIN = 16 and OOK_POWER = 12) uploaded to the device and launched the serial monitor:

Woah, that’s a lot of data… but quite expected as I have 9 currentcost devices transmitting, 2 oregon scientific devices and probably some other stuff I’ve forgotten about.

I retried the ookDecoder sketch now that I know some real rf data is acknowledged- and to my amazement there was some sensible output:

HEZ BEBA1200800700

Apparently these are home easy transmissions- though I don’t have any home easy or compatible devices in the house (that I’m aware of)- so my only guess is that they belong to my neighbours!

I need to do some more research into whether the currentcost protocol can be decoded and find a working sketch for my oregon devices then start to consider purchasing some remote mains sockets.


After getting my first few jeenodes flashed earlier: https://tickett.wordpress.com/2011/12/02/my-first-jeenodes/ it was time to get them to actually do something. With the sketches from the hah wiki http://www.dbzoo.com/livebox/hah_hahnode#flashing_from_the_hah I had hoped to start seeing traffic straight away but needed to know where to look.

I plugged the jeelink back into my laptop and fired up Arduino IDE- I’d hoped to use the serial monitor but serial port wasn’t listed. Fortunately Brett over on the hah forum quickly pointed me in the right direction of the usb/serial drivers: http://www.prolific.com.tw/eng/downloads.asp?ID=31 and I was up and running!

I could see the jeelink output: [HAHCentral.1] D i4 g212 @ 433 MHz

And knew that the frequency/band needed changing to 868 Mhz- so I issued the 8b command. Now it was time to check the jeenode- unfortunately serial output isn’t enabled using the default hah sketch. I flashed the RF12demo sketch and set the group and band to match that of my jeelink. I believe these configuration settings are stored in the EEPROM so after flashing the hah roomnode2.hex back the id, group and band will remain unchanged.

With the hahcentral plugged into the laptop and the serial monitor fired up I was starting to see some data coming in from the roomnode:

[HAHCentral.1] D i4 g212 @ 868 MHz
OK 2 0 0 0 0
OK 2 0 0 0 0

2 is the node id but for some reason the temperature, humidity and light values are all 0 (there is no PIR attached so I’d expect motion to return 0). Thanks again to Brett over on the hah forum for pointing out that the roomnode2 sketch support the DS18B20 temperature sensor and not the jeelabs room plug I was trying to use with the SHT11 temp sensor.

Meanwhile I tried to get the Serial SCHEMA service and plugboard scripting engine working on the hah. I created the jeenodeApplet.lua on my laptop and used wget to move it into /etc/plugboard but running top the xap-plugboard service didn’t appear to be running. I tried to launch it via ssh:

# xap-plugboard
lua: error loading module 'jeenodeApplet' from file '/etc/plugboard/jeenodeApplet.lua':
/etc/plugboard/jeenodeApplet.lua:4: unexpected symbol near '?'
stack traceback:
[C]: ?
[C]: in function 'require'
/etc_ro_fs/plugboard/plugboard.lua:23: in function 'fun'
/usr/share/lua/5.1/pl/tablex.lua:365: in function 'foreach'
/etc_ro_fs/plugboard/plugboard.lua:71: in main chunk
[C]: ?
Loading /etc/plugboard/jeenodeApplet.lua #

So it looks like a problem with the jeenodeApplet.lua. I spent quite some time puzzling over it till messing around with VI I noticed a few vanishing/invisible question marks ? In the file. I guess this is something to do with the various character sets and binary/ascii conversions that took place moving the file from my laptop (osx) to my webserver (some flavour of linux) and then to the hah! Now the file was fixed I was able to get the service up and running! Excellent- what next?

I tried using xFXviewer to pickup the xAP broadcasts but all I could see was local feedback:

Again- a lot of playing, checking firewalls etc but to no avail. Eventually I installed xFXviewer on another virtual machine and picked up the broadcasts:

Now with Brett’s help I’d flashed the jeelabs roomnode3 sketch onto the roomnode and was getting "a bit more" data back for temperature, humidity and light: ROOM 0 0 0 -396 0 but something’s still not right! This time after fiddling I tried another jeenode with the room plug and bingo:

[roomNode.3] B i2 g212 @ 868 Mhz
ROOM 7 0 51 228 0
ROOM 64 0 59 230 0

Now to try building my graphics board :)

Seemed pretty painlesss- now let’s get the glcd_demo onto the board and give it a go:

Doh- yet another "not gone according to plan"- but as ever, I will persist :) Thanks to a suggestion from martynj on the jeelabs forum I decided the contrast was the problem and as pointed out, this is controlled by the software so I had a look at the code:


Bit of a stab in the dark… but let’s trying bringing that down considerably:



One last task before I call it a day: Get some data posting to pachube. Luckily the hah web interface allows this to be configured relatively easily: http://www.dbzoo.com/livebox/hah?s[]=pachube#xap_pachube but as expected I ran into technical difficulties. I forgot to take a note of the message but it was because of a blank row in the config:

The trash can doesn’t seem to work to delete the record so I had to manually fix the /etc/xap-livebox.ini via ssh (see the count=X setting under the [pachube] section). And after a few hours running:

Voila! I’m not quite sure what’s responsible for the drop-outs but I will get to that later. Hopefully I’ve learnt the basics whilst troubleshooting the various problems and as I find the time to get additional hardware/software up and running it’ll all go a lot more according to plan!

Here’s some ideas of what I’d like to do in a rough order (some of it is unrealistic):

  • Hookup a node in the main rooms of the house for monitoring temperature, humidity, light and in some also motion
  • Hookup a pulse counter to my gas meter (Schlumberger R5 which fortunately already has an RJ11 or RJ12 socket)
  • Hookup flow meters to my mains water supply and central heating output from the boiler (I’ve already ordered the parts for this)
  • Hookup some rf sockets/mains switching (to remotely turn lights and some other mains devices on/off- currently investigating solutions: plugwise seems to be one of the only 2-way solutions but the reliability is reportedly flakey unless you have a lot of devices)
  • Retire my CurrentCost bridge/netsmart in favour of directly connecting the EnviR CC128 to the hah (there’s no real urgency for this as the data is already being sent to pachube)
  • Attempt to interface with smoke alarms (it’d be nice to house the roomnode for measuring temperature, light, humidity and motion all in one neat package)
  • Collect data from other areas of my network to send to pachube (bandwidth stats from my pfSense virtual appliance, disk usage from my fileserver etc)
  • Build a database to house additional info & potential some of the existing data (depending on how easily I can query pachube)
  • Build a website to display the various information housed by pachube & my custom database
  • Add "security" devices: A few high resolution outdoor cameras and a few devices to detect open/close doors.
  • I’m sure I’ve missed some stuff off…

Some inspiration from these ideas has come from: http://bwired.nl/ and http://www.hekkers.net/domotica/


%d bloggers like this: