Home Control 3

This article is about home control – specifically controlling devices and reading sensors via the Internet – for example using a mobile phone – and internally via much lower cost short range radio boards. As it’s been a while since I did a write-up you could be forgiven for thinking the home control has gone off the boil. Nothing could be further from the truth.

A quick glance at the image below will confirm it’s coming along quite nicely. So – what’s new? Well, I quickly tired of struggling with space in the Atmega328p chips and moved onto the ATMEGA1284p chip. Why? Well, it’s still DIP so easy to work with, it is cheap, code-compatible, has lots of pins and is supported by Arduino (though all I’m using is the chip – fitted with the Optiboot loader). While the very cheap Ethercard boards were looking the favourite for a while, again a burst of common sense hit me – there’s only one in the system, it’s worth a couple of pounds more to have hassle-free operation – and I’m getting hassle-free operation. The ENCJ chips are just too much like hard work and using them with socket libraries just seems like asking for trouble.

I put some indicators on the master board to indicate flow of Ethernet data and radio data but got side-tracked when fretting about the number of wires it would take to wire up an LCD – I just happened to have one of the NANO boards available from China for around £3 I decided to stick one of those on the back of the LCD and make a general purpose LCD driver board. On the 16*2 boards it’s even possible to run the contrast and brilliance straight off the 328 – not so easy with larger boards due to greater power consumption – but works a treat for the former. Anyway to cut a long story short that little project is about to appear on Kickstarter as I decided to make the board do a whole lot more than just drive an LCD – and all off serial. It handles infra-red, de-bounced inputs, temperature sensing and far more. The board we’re working on right now will simply slot onto the back of a standard LCD board and you’re up and running.  More on that later, just waiting for prototype PTH boards to appear.

I looked at various mobile software solutions for this project but none of them visually hold a candle to what you can do with NETIO and so stuck with that.

The slave boards and again we had some proper boards made for these – come with 8 SMD LED indicators on for OUTPUTS, PWM OUT and a general purpose indicator – only recently did I discover the serially addressable RGB LEDS and in future boards I’ll use these as they only take one port bit to run the lot – no matter how many you use and the colour variations could be exceedingly useful. I’m still using RF24NETWORK, despite the poor range of the radio boards it is possible to create a network to expand that range. We are however looking to the more complex chips which include radio as these have far better range and yet can still be cheap in quantity – watch this space for an exciting development in that area.

At the time of writing – all is working well – I have two installations, one in Spain and one in the UK… and I’ve learned a LOT about programming Atmel chips and how to use Atmel Studio for debugging – which though I’ve no intention of becoming a “pro bore” like some guys I’ve seen in forums – Studio IS infinitely better than using the Arduino IDE… and as it is free – one has to ask – why not. More later on this one…

So below you see the current setup – way beyond my original wildest dreams but set to get a lot better. The Master board talks to Ethernet and takes in commands that way… it also talks via Ethernet to time servers to get the exact time- and given longitude and latitude figures up what time is lighting up time and dawn and offers this information to the slaves so that they can for example turn lights on and off accordingly rather than just straight on-off. Slave software includes the ability to read temperature and humidity from a variety of sensors as well as offer PWM output for LED strips.

Scargill's Home Control

So there you have it – working home control at low cost. While full Arduino boards can be expensive, DIY boards cost very little – ATMEGA328 chips can be had for a couple of pounds and the ATMEGA1284 for not much more.

Networking the NRF24L01+

tmp97BDThe tiny NRF24L01 modules you see in the photo to the right (the module handing off the board to the left) make great short distance communication units for Arduino projects – using the RF24 library. The main attraction of these radio units is their cost – under £2 each module from China (Ebay). The downside is they are short range, maybe 80 metres or so in a straight line but dramatically less through walls.  The main board you see is something I put together as a general purpose Arduino-compatible board, soon to be revised.

I’ve done a fair bit of experimenting with these radio modules as they make really cheap radio communications possible – the RF24 library works ok but the first thing to do is change the default 1Mbps data rate to 250Kbps. Still quite fast, considering you only send short packages – but this adds maybe 50% to the range depending on obstacles. I found the variations with a better aerial were only marginally better than these green10-pin modules.


The real breakthrough is to use these in a network – I have scoured the web and found almost nothing out there to do the job –some academic half-finished projects… but there is one… RF24NETWORK. I had to go into the main library file and change the speed (one location, easy to find) and in the test file do the address assignment in code (the example accepts a single digit from the serial input – if you don’t have anything attached to the input and leave it floating,  you’re asking for trouble as the format is too simple – but then I am just talking about an example – one would assume you’d burn in the address by another method in production.

The fellow has documented everything well but beginners beware – if you see a leading zero, he’s using OCTAL (base 8, ie 0 1 2 3 4 5 6 7 10 11 etc.) numbers which threw me off for a few minutes…

So the idea is you connect units in a tree structure… the root is device ID 0… then at the first level up you have devices 1,2,3,4,5.  The modules can listen to 5 channels at once so that’s how he’s based his network – here’s where the octal comes in  -siblings of device 2 would be 012,022,032,042,052 (they are Octal numbers). Any of those 5 can listen to 5 more etc.  It is possible to put thousands of modules in this network (though I would not recommend it) and I’ve already proven to myself that it works by making 3 units (the photo above is a board I designed some time ago as a general-purpose Arduino board) and spacing them so that the last board could not possibly communicate with the first one by sheer distance.

Works a treat – well worth investigating. Here is a conversation (with debugging turned on) and you’ll see the messages being passed around. Note line 8014. This log is coming from device 0.

Update May 2013: This article was originally written in 2012. Note that I have written a later article here – there are still issues with the networking software as you will see.