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.

Advertisements

Charlieplexing

How do you control 3 LEDS with only 3 wires?

Impossible, right? Wrong.

Charlieplexing is a mechanism to do just that. It was developed by Charles Allen at Maxim.

Because LEDS are diodes they only work in one direction – and they only work above a certain voltage. These characteristics can be used to help control them in a multiplexing fashion.  Imagine for example you had TWO wires – surely you can only drive one LED with that. Well no. Imagine you put 2 LEDS and their associated resistors across the two wires – but in the opposite direction. Take wire A high and B low… and one of the LEDS will light up – takes wire A low and B high and the OTHER LED will light up. 2 wires, 2 LEDS.

So how many LEDS can you multiplex onto 3 pins… 3, 4, 5… no – SIX

leds

And here’s a library suitable for Arduino-like chips I spotted out in the wild!

http://playground.arduino.cc/code/charlieplex