Friday, September 21, 2012

Casting the net further

About 3 years ago, whilst working for a central London energy monitor company, a co-worker asked me whether it would be possible to come up with a device which would allow her to switch off electrical equipment in her home remotely using the internet. I thought about the problem for a while and finally cobbled together a solution that used a Microchip  dev.Net board, a repurposed wireless remote socket and a couple of PIC microcontrollers.

It was a real lash up, but it proved the point that the internet could be usefully used to remotely control simple devices - provided that it could extend it's capabilities beyond the router and the CAT 5 cable, using a low power wireless link. With wireless, it is possible to set up a zone of connectivity around the ethernet to wireless gateway, and any wireless compatible device brought into this zone would benefit from 2 way connectivity to the net.

This proved to be a powerful technique, and the advent of affordable open source hardware based around the ATmega328 microcontroller and the RFM12 low power transceiver allowed users to experiment with wireless sensor networks for remote sensing and home automation. The great thing is that this hardware is now available from a variety of sources, and shares RF compatibility - allowing you to mix and match devices from various supplers.

Further experimentation in the Autumn of 2009, led to the desire to produce an affordable internet gateway, and some work was done using hacked about energy monitors and the ethernet equipped Microchip PIC 18F67J60. Our out of hours development work led to "once per second"  power readings being sent up to a web based visualisation system in December 2009. Some of these ideas ultimately went on to be incorporated into the Nanode project during its design phase in March 2011.

This summer, I have spent the last 6 weeks visiting a variety of weekend events, including OggCamp 2012 in Liverpool, EMFCamp in Milton Keynes, the Brighton Mini Makerfaire and just theis last weekend OSHCamp in Hebden Bridge, Yorkshire.  Seldom a weekend at home it has been a good opportunity to catch up with the open hardware scene - and realise that the whole world has gone Raspberry Pi mad.

It was in the open fields of EMFCamp that I decided to do a range check on the RFM12 wireless transceiver. Using a couple of devices fitted with 868MHz  modules, I was able to wander around the campsite with my laptop and prove that the open field range of the RFM12 was better that 250m.  In a built up suburban enviroonment this translates to about half this distance - a similar test done in my street got me 130m from home before packet reception became unreliable.

The emonCMS server has become a central part of the remote control and monitoring system. It allows data  from sensors to be datalogged and visualised, whilst at the same time permitting commands and data to be sent back to control wireless nodes.

If we think of a node as a microcontroller with a RFM12 attached, there could be a standard set-up page on the server  which allows you to define the pin functions and allocate those to various input devices - analogue and pulse sensors, and output devices, such as relays, pwm drives etc.

It is our intention to publish the command structure - we are still looking at the best way to send both commands and data back to individually addressed wireless nodes.

There is also the issue of privacy/security.  It's good to be able to see other people's public feeds, but if my gas boiler is connected to a relay on a wireless node, it would be foolish and unsafe to give everyone access to that device.

One way of handling this is with the use of apikeys that are generated when you first register an account on the server.  

The simplest node could just be an Arduino with RFM12 shield or JeeNode, or even a stripboard Arduino with an RFM12 module mounted. Nathan Chantrell cleverly shows how to do this in his blog post

Nathan has gone on to produce similar designs with the ATtiny - if you want minimalism, and the ATmega1284 - if you want more I/O and much more RAM.  For most people, the ATmega328 is a good compromise, offering 6 analogue inputs and 7 digital I/O, once the RFM12 has been connected to the SPI bus and interrupt line.
The introduction of the new surface mount, ready assembled Nanode RF, this Autumn, will allow easier access to the project for those who don't wish to solder a kit, and with the Sketchgarden remote bootloader and emonCMS server, it should be even easier for people to get up and running quickly.

There is now Nanode compatible hardware from JeeLabs, OpenEnergyMonitor and just recently - with a very small ATtiny based node

With a lot of people purchasing Raspberry Pi's, it seems logical to use this device as a local server running a version of emonCMS, and already some experimental RFM12 boards have been made that plug into the PI's   I/O connector.

We believe that the combination of simple open source hardware based on 8 bit microcontrollers fitted with a low power wireless link is a powerful tool for extending the internet into the field of remote control and monitoring.  Nanode is committed to continue to produce low cost hardware to develop this further.

Ultimately we should like to see Nanode gateway products priced between £20 and £25, and simple ATtiny based wireless sensing nodes starting at around £10.  Continued use of DIL and through-hole designs suitable for the DIY/home assemby market, will be complemented by ready assembled SMT devices.

Wednesday, September 19, 2012

Using Nanode RF and emonCMS for Remote Control and Monitoring

For the last couple of years I have been looking at simple low cost methods of measuring analogue data - such as that from temperature or humidity sensors placed around the house and getting that data up to a cloud based server for datalogging and visualisation.

With the introduction of the Nanode RF last September, and working cooperatively with Trystan Lea and Glyn Hudson of, we have managed to send data from a variety of wireless sensors to   their emonCMS server.  Trystan and Glyn developed this platform mainly for logging and visualising electricity data - both consumption and generation from PV,  but the versatile open source server can be applied to a wide variety of monitoring and control tasks.

A typical system consists of one or more wireless sensors, which collect analogue or pulse data and send this  wirelessly to the Nanode RF - which acts as a basestation.  Nanode RF runs a multinode sketch, which allows it to receive data from any wireless sensors that are in range.  These sensors have a node ID from 1 to 30 and can be arranged into different groups.  Provided that the sensors don't all try to transmit at once, and a certain time randomness should be included into their transmission slots, the Nanode RF receivers their individual data and posts it up to the emonCMS platform - where it can be manipulated, graphed and visualised.

As well as electricity data, emonCMS has been used for heat-pump monitoring and bee hive temperature monitoring.

Now a little documented feature of emonCMS is that the last posted value of a feed can be requested by the Nanode RF. This feed value can generally be a 16-bit integer - for easy interpretation by the Nanode, and with suitable decoding can be used to control the hardware either on the Nanode RF, or any of the wireless nodes connected to it.

It is a relatively simple matter to create a web dashboard which contains switches and rotary controls - allowing different parameters to be sent to the Nanode RF, or any of it's connected nodes.  A simple example would be a RGB LED lamp, connected to pwm pins on the Nanode controlled remotely from sliders or knobs on the dashboard.

Trystan's code for reading a feed value is here on GitHub. - example g in the Guide.

An extension to this is to get the Nanode RF to send the feed value as an RF packet out to the wireless nodes. A simple hack was done using one of Trystan's graphical LCD display units which feature a pair of bicolour LEDS.  Sending a feed value of 0,1,2 or 3 allows you to remotely control the colour of the LEDs from the server - and because we are using the RFM12 - the distance between the base station and the wireless node can be quite large - better than 200m in open field conditions or 100m or so in a built up street.

If you want to experiment with this you just need to put the following line of text into your browser's URL window

By changing the value of power from 0 to 3, this causes the colour of the  LEDs on my emonGLCD to change.  You can send me feedback on Twitter @monsonite - I'm going to get a proper control dashboard set out, but for the moment it proves the point.

More complex controls, for individually accessing the I/O pins of remote RF nodes could readily be devised, allowing each such node to be accessed from it's Node ID.  The read apikey ensures that your feeds are safe and cannot be tampered with - without having the apikey, the correct password and username.

This system makes it very simple to incorporate the monitoring and logging of room temperatures - from RF nodes - including WiNode, JeeNode - and the new very small, ATTiny84A based Funky,  another RFM12B compatible node. At the same time, relay outputs connected to these nodes could be used to turn on central heating, open or close radiator valves, or switch on or off electrical appliances - all from the web accessible platform - using laptop or even an app running on a smart phone.

In the 18 months that Nanode has been around, it has gone from strength to strength, and is now appearing in various compatible versions from new suppliers. The latest is the Micro IoT Gateway from This will make a great RF gateway, but just needs a RFM12 fitted to make it compatible with Nanode, Openenergymonitor and JeeNodes.

Watch out for an important announcement regarding an exciting Nanode new product towards the end of next week.