Archive for the ‘Arduino’ Category

DIY Home Automation on a budget

Tuesday, June 4th, 2013

This first post is going to be a long one, describing the basics of how my system is set up – I apologize but without this information, anything further I post will not make any sense.

For about the last 9 months I have been tinkering away in the background designing some home automation devices.  There are various reasons for wanting to do this but in  short – because I can.

The main inspiration came from Jon Oxer and his Superhouse project he started back in 2008(?). It was also for this reason that I chose the Arduino to be the base for all of the modules.

Ethernet enabled arduinos are very easy to use, versatile, keep things simple and are relatively cheap – The perfect solution for DIY home automation. Sure, there are things like X10, Clipsal cBus etc but these are generally expensive and/or not very universal.

The main important difference between my intended setup and Jon’s was that I have an existing house that I am not doing a major remodel on so re-cabling my whole house was not going to be an option.  This meant all the mains switching would be done locally at the switch point and not back at a central point.  There are a couple of advantages of this but the main one is that I don’t have to rely solely on the automation system and components used to build the it just to turn on a light.

The arduinos send and receive messages to/from a server so that (for example) when a button was pressed at a module, it would send a signal back to the server (to update a web page for example) or  I could use the server to send a ‘button push’ command enabling the actual automation side of things.  However, if the automation systems fail such as the server being offline or a network switch dies – How can we ensure we still have some (perhaps somewhat reduced) functionality? I still need to be able to turn lights on and off but I’m ok with it if they don’t turn themselves off while the system is offline.

With this in mind, the outputs of each Arduino, directly control the outputs of the system.  For example, if a button for a light is pushed, it turns on/off a directly connected relay and added to that, if it can, it reports to the server it’s status.

My house is wired with cat5e to every place I intend to utilize the ability to automate a process such as light switches, doors, sensors etc back to a communications rack. The arduinos will be placed in these locations and powered with ‘poor mans’ PoE.
The communications rack houses a special low power PC that only consumes about 30W of power – This box is my Internet router, VoIP phone system, web server (not this one)  and MQTT server.

MQTT?? What’s that?  I hear you say – Well, really that is the heart of what makes all this possible.  MQTT stands for Message Queue Telemetry Transport and is a special message protocol that was intended to be used on slow or intermittant TCP based networks for sending information such as sensor data over the internet.

While it was possible to develop some PHP pages on apache and have the arduino’s generate ‘GET’ requests to make things happen or some other sort of TCP socket connection, it’s really like using a car to squash a pea. Sure, it can do it but why go to all the effort when all you want to do is send a few bytes of data.  MQTT works based on a Publisher and subscriber type system.  Think of internet newsgroups – You have a server, with a heap of topics you can subscribe to, or publish to.  MQTT is similar but much simpler.

There are a few  MQTT servers (called ‘Brokers’) available, the one I use is Mosquitto.  Not for any specific reason other than it was simple to install on my CentOS box but it’s also available for windows for those not so linux minded.

The system is very simple. A device or computer can publish information to a ‘Topic’ and anyone who is subscribed to that topic will receive that data. A device or computer can simultaneously be subscribed to a topic and publish to it. Topics sort of look like a folder structure such as ‘home/kitchen/lights’

Lets take a practical example:
If i have an arduino that is subscribed to ‘home/kitchen/lights’ and it waits for a simple ‘0’ or ‘1’ to turn the lights on or off, then any other device on the network can publish a value of ‘1’ to ‘home/kitchen/lights’ to turn the lights on.  Fortunately there are many MQTT compatible clients out there for use in java, php and just plain binary programs to do this.  So, you can have a PHP based web page that is able to publish this data – You now have the ability to control your kitchen lights at the click of a button on a web page. Not only that, the web page can reflect the status of lights in real time with the assistance of Ajax or similar technology.

Generally speaking, each module will have the ability to:
Control up to 4 relays via tactile switches with LED status indicators
Have controllable back lighting for the switches (for night time)
Have up to 4 inputs for movement sensors
Be equipped with a temperature sensor

However, there will be some custom modules for the likes of RFID readers (door access control) and a special one to do some switches and monitor household electricity use (read my electricity meter) and another one will have an RF transmitter for controling some RF enable power point devices.  All of these are already developed, just not implemented yet with the exception of the electricity meter reader which I will go in to more detail on soon.

Arduino Wiegand door access module

Tuesday, September 25th, 2012

A few years ago now I was implanted with an EM4102 compatible RFID tag in my left hand and since then I have created quite a few projects based on reading the tag for various tasks – Mostly access control.  One of my more recent projects was to create a ‘Door access module’ but this one would be different.  In the past I have interfaced with an ID-12 chip from innovations which has a generic serial output. While this is easy to interface with, the readers are expensive and somewhat awkward to use as far as mounting, waterproofing and tamper proofing.

This inspired me to come up with a way of interfacing to industry standard readers.  These readers use the Wiegand data format which comes from the days of mag/swipe cards but it also means this project can be used with almost any Wiegand reader.

This means I can use generic, cheap readers from ebay that generally cost less than $10 coupled with a $20 arduino and a homebrew shield for about $40 total cost. This is about the cost of the ID-12 chip alone.

Initially this project was a very simple reader with grant/deny access and nothing more but I reworked it a bit later on to be a complete online version as well (with Arduino ethernet module and POE).  For now lets look at the basic version.

This simply works by programming in a set of tags to EEPROM and when a card is read it is compared to those in EEPROM and if one matches, access is granted, if not, access denied.  No advanced control is used.  This is handy in scenarios where all users are trusted and you have no care for the time that they get ‘access’.

I made a simple shield that interfaces to the reader via a pin header, a couple of buttons, an output for the strike and a BD681 darlington transistor to handle activating an electronic strike or whatever other high current device you desire.

Downloads: Sketch and Shield in Sprint Layout format