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.


2 thoughts on “Home Control 3

  1. Hi Peter! I’m Gonzalo from Argentina and I’ve read a couple of your posts and find them very interesting. I’m pretty much a newbie in Arduino but very excited as well.
    I found “openHAB” and was looking for a “low-cost” solution as you propose to get in this “monster” of integration in domotics. OpenHAB I understand that can be used via MQTT protocol and Arduino, as you proposed in a couple of posts. I have a question before starting regarding the flexibility of this system.

    I was wondering, if I let’s say make my home automation system, hopefully succeed at it 😀 but then want to add one more NRF node at the end of the “network” or in the middle, this means I have to reprogram every node up to the master node in order for them to “accept” the new one?

    I’m probably asking a stupid question, but before starting to dedicate a lot of time on it I want to clear some things up instead of finally surprising me.

  2. Hi – and sorry for the delay in writing.. I’ve just realised there were a boatload of comments needing moderation (many of which were spam – hence the moderation).

    Firstly, I have achieved a lot since writing this article and I will do an update. I have tried (hard) with OpenHab and am treating it right now as a “work in progress” and that is all. If you get into it, it seems like they are looking to make a commercial project – and using hobbyists to find the bugs right now. I’m not sure I “trust” that this will simultaneously (a) develop and (b) remain free. Either way it did not do what I wanted and so I put that to one side. It is entirely possibly incidentally to develop your own home control using Android – the software I have played with is cheap – and it is called Basic4Android (B4a) – the libraries include a “socket” library which will happily talk to the likes of NETIO and the socket code of an Arduino Ethernet card. I’ve not done anything concrete enough to publish but I have made a little socket terminal for my phone which reliably talks to my Arduinos.

    On the NRF24L01 side – I will update elsewhere – after years of using the RF24NETWORK I defected to the RADIOHEAD library. I then found issues with this and solved all of them in two ways… firstly the Radiohead library allows for full mesh networking – that is, no octal numbers, no manual routing – just units numbered 0-254 and they talk to each other – none of this “up to 5 at one level” stuff – they just talk…

    Except when they don’t – I found that I was getting routing occurring one minute – and not the next – I nearly abandoned the library until I remembered someone telling me that you can’t tell the signal strength of the NRF24L01 radios – and it hit me – how can an automatic system choose the BEST unit to contact in a mesh network if it can’t tell a bad signal from a good one?

    With that revelation I backed down a level so that my network consisted of numbered units just the same – but each unit had a list – the list details which unit to contact if sending on to any destination. So – for example in my case, unit 0 is the master – unit 1 is the strategically placed relay for units 2,3 and 4… so id 2,3 or 4 want to talk to base – they do so via 1. If unit 0 wants to talk to anyone, it does via unit 1 – simple tables. Works a treat – except when it doesn’t.

    By this time I was wondering if I should take up woodwork… and then I spotted some posts on the subject of the NRF24L01 radios. For some time I’ve been putting a small capacitor across the power of the NRF24L01 units on the assumption that they are sensitive to interference from switched mode supplies (I use cannibalised plug-in-the-wall USB supplies in my units). This had improved things a little but here I was after months still getting issues I could not explain.

    On the the guys pointed out that the radios ALSO tend to take a high current spike when transmitting and were incredibly sensitive to having power available at this point. I thought it worth a try (at this point I’d have tried homoeopathy) and put a 330u cap across the power pins of the radio board – I already feed them with 0.1u. VOILÀ the range went up – the reliability went right up.

    Not only that but for unit 1 I had already tried one of the NRF24L01 boards with a PA amp and stub aerial – and had never seen an improvement (they use even more power). Armed with my 330uf cap trick I tried again – NOW the larger unit which I’d used as unit 1, my “relay” unit which also controls outputs – and… enough range to get around the building with reliable comms – problems over.

    So what I would say to people now is this…

    Check out the RADIOHEAD library – which is being updated even now as I speak – it works, it’s easy, it works with a RANGE of boards by changing one header file only – and it’s free.

    NEVER under-estimate the need for smooth, adequate power to the little NRF24L01 boards. The next time I do board layouts to plug in an NRF board, they will include 2 socket options for the two types of board, a 0.1u cap and a 330u cap right next to the socket area… and that area will be as far away from everything else as possible – and the power supply will be mounted at the opposite side of the board. Take that advice on board and you’re well on your way to NRF24L01 success.

    My final advice – unless you really do need to keep costs to a minimum and/or have only simple requirements, consider the 1284 chip instead of the 328, no more desperately trying to save RAM. I have encouraged library writers to support the 1284 chip (usually just a line of conditional code to lump it in with the MEGA) with success.

    So there you are – I am now concentrating on how to actually DO things with my network instead of how to keep it working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s