DIY Home Automation on a budget

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.

Another RFID project from the Past

September 25th, 2012

When I first got my RFID implant, the first thing I wanted to do was to RFID enable my car but I wanted to do more than just unlock the doors.  I set out to create a 3 point immobilizer as well as control the central locking.  The cool thing with having an implant as your key is well, you can never lock your keys in your car!  With that in mind, this also has the ability to have ‘passive lock’ but this was something I never really perfected in the code. It works (selectable) but it was too procedural in that you have to unlock car, start, run, stop, open door, close door and then after 3 seconds it would lock automatically.  I tried it for a while but while somewhat cool, it had some annoyances so i disabled it again.

The project is based on a PIC16f681 and coded in PicBasic pro and uses the ID-12 chip from Innovations.  The setup cost for this is probably in the mark of $100+.  The code works fine as-is.  In fact this is the exact setup that is in my car now but if i had to do it again, I’d probably start with an Arduino Nano and work from there.  Things are just much easier in Arduino land than Microchip Pic.

Provided as is – I will not change this code but hey,  feel free to do it yourself. I might be able to offer some info but this was written in 2010 so it might as well be someone else’s code to me by now. There is a couple of  missing links in the PCB as seen by the link wires in the photo.

If you don’t have a Pic programmer, I recommend the RCD Programmer and PicProg4U

Downloads:  PicBasic Source, compiled HEX, Eagle PCB, Eagle Schematic

Arduino Wiegand door access module

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

LFS Gear indicator and shift light

September 23rd, 2012

I always wanted to do some sort of Outguage project but never really got around to it and I guess it was more of a luxury than a requirement.  With recently getting back into the racing and now with a sequential shifter, I wanted a big gear indicator that could be glanced at and see the gear.  Sure, the built in LFS one works but bigger is better right? I also wanted a shift light so i can concentrate on driving line rather than shift points.

I looked at some ways of achieving this goal and ended up mashing some projects from some other people together and came up with my version.

The display is based on an ethernet enabled arduino – In my case the Freetronics Etherten.  You could just as easily use a Uno with ethernet shield however. This means there is no serial connection to the arduino and there is no noticeable delay in the display compared to LFS.

The code is based on the Outguage library from by Jaakko Linnosaari and another individual by the name of Pete Willard with my own customization.

The gear indicator code is fairly simple as such, the harder part of it was for the shift light.  Since only a handful of cars in LFS actually have a shift light, we have to look at the theoretical shift point for each car and set the light to come on at that RPM.  The light is currently set to come on at the ‘Max power RPM’ as stated in LFS which is generally a few hundred to a thousand RPM before it hits the limiter.  Once it hits the limiter, the shift light will flicker.  This is achieved by using a ‘tone’ output from the Arduino instead of just turning it on. The shift light/LEDs are powered via a BD681 darlington transistor so you can use almost any light you want.  I just chose leds.

**The tone library used needs to be modified to compile under Arduino 1.0.1, see the comments in the code.

The common annode display is driven via a ULN2003 darlington transistor array.  All 7 pins from the arduino go straight to the input pins of the ULN2003 and the segments of the display are grounded via a 500 ohm resistor for current limiting.  It’s a bit of a hack job – Not normally how i like to have my projects but this one was so quick and easy to implement, there was not really much need for a shield to run it.

Arduino sketch:

Racing sim update

September 23rd, 2012
Some time ago I somewhat shelved the sim, mostly because I didn’t really have the room to keep it set up but also because I decided to re-work the wheel setup but it never really took off.  The idea was to make my own electric feeback wheel with an optical encoder, arduino and a big DC motor but I could not get it right.  The movement side of it was fine – I had the arduino reading the pulses and converting this into a joystick axis but it was the electric force where I could not get it right. Big DC motor, H-Bridge and PWM but I could not get enough force out if it that I was happy with.  I decided the best option was to buy a commercial wheel and use my pedals/shifter.
I ended up buying a Logitech G27.  I am very happy with the mechanics of the wheel and it’s force abilities but the pedals and shifter really let it down. I tried them but going back to a position type brake (over force like my pedals) just felt all wrong and while the shifter is ok, it just did not have that realism of my DIY aluminium H shifter.
I also removed the stock wheel from the G27 and replaced it with the one from my other setup and placed some button switches on the wheel to hook up in place of the stock ones.  This is a much better size and feel.  The only downside is the flappy paddles are now too short but I hardly ever use them. Maybe one day i will make up some longer ones.
I have re-worked my H shifter now too.  As well as replacing the H plate with a friendlier soft plastic (cutting board) instead of the aluminium I had before I have modded it to be able to swap to sequencial mode. This is great for RBR and other rally games but I also prefer it to paddles where it is harder to change gear while turning.
There is now an extra 2 switches mounted to the bottom of the H plate and a removable washer is screwed to the bottom of the shifter shaft.  This gives a little extra throw on the shaft to push the switches.  I also too advantage of the holes in the upper part of the shifter to insert some tube to restrict the movement forwards and backwards.  This restriction allows the shifter to return to center.  Another screw in one of the brackets supporting the shifter prevents sideways movement too.
Swapping from H to sequencial takes about 30 seconds and is very easy.

Blackberry bold 9000 sound fix

July 1st, 2010

For those of you that have a Blackberry bold 9000, you are probably familiar with the problem of having intermittent ring sound or loudness.

For ages i have put up with the problem on mine, trying various fixes based on the contacts between the main board and the pads
on the underside of the speakers which appeared to solve the problem for a little while but it seems it was only incidental. It was
not until recently that i finally discovered the REAL reason for the fading sound.  The problem is caused by a conductive
elastomer that fails.  If you remember back years and years ago, the old Nokia 3/5/6/7/8110’s and others in the era suffered from a
failure of a similar item which caused the dreaded ‘screen fade’ problem where you could push below the screen and the display
would come back to life. What would happen is that over time, from being continuously compressed in pockets etc, the elastomer
would compress permanently causing it to lose connection between the two surfaces. Nokia learnt from it’s mistakes and promptly
moved to a sprung contact in it’s next generation of phones.

This is exactly what is happening in the Bold but for the connections to the speakers.  For some reason that is still not obvious to
me, they use electrical tracks on the underside of the grey cover that goes over the camera flash LED to conduct electricity to the
speakers from the flex circuit the LED is mounted to (via the conductive elastomer).  It seems idiotic to do it this way, there is
simply no need for it.  The design is simply flawed – as if it was an afterthought.

So, on to a FIX – Well, so far i have managed a ‘primary’ fix which involves removing the grey plate, stretching the elastomer out and
replacing the plate again with a bit more force than it had before.  This is all i have needed to do to get it back to ‘as new’ but time
will tell if it is a long term solution or not.  If it proves to fail further down the track, the next option would be to connect the
speakers with wire directly rather than relying on the elastomer.

Disclaimer: In doing this ‘fix’ you will be voiding your warranty. I accept no responsibility for damage to your phone in any way.  This information is provided ‘as is’ without any warranty or guarantee that it is accurate or will actually fix your phone.  These are the steps i undertook to repair my phone and it worked, it may not for you. Follow these steps at your own discretion and risk.

Tools required:
Sharp knife (hobby knife or box cutter type), Fine tipped soldering iron and a spoon (yes, I’m serious)

Step 1:
Remove the battery cover

Step 2:
Look at the grey plate.  As you can see, the plate is held on by 8 plastic pins that have been melted over (marked in red in the pic below). With a small sharp knife
(Be careful!) remove the melted tops of the pins so the grey plate can be removed.  Try not to push down on the grey bit when you cut the tops
of the pins off, you want to leave as much pin left as you can.

Step 3:
Remove the grey cover, being careful not to lose the led reflector from between it and the LED and put them aside.

Step 4:
Either flip the phone over and give it a tap on your hand or gently pry the elastomer out with something small – it’s the white bit
above the LED (marked in green below).

Step 5:
Grab your spoon and put the elastomer on it’s SIDE on a clean, hard, flat surface.  Now what we want to do is squash it a bit.  You
can use a bit of force but the idea is to get it to bulge back out from the way it was compressed in the phone.

Step 6:
Replace the elastomer in the phone, put the LED reflector back in the grey plate and put it back on the phone.  While holding them
together with a little bit of force, check the sound is all good by playing some music or something.

Step 7:
Once you are happy that it’s all going to work and the led reflector is definitely in place, grab your soldering iron and with a bit of force, hold the grey plate down to expose
some more of the black pins and just dab each one with the soldering iron.  It only takes a dab, no need to hold it on there.  Once all of them
are done, test again and with any luck you now have an ‘as new’ sound level.

Time will tell on this fix but if it fails again, i will simply solder some extra fine wire from the flex board on the bottom to the
contacts on the speakers.  The problem then is that it would likely be next to impossible to replace the grey plate for a ‘stock’ look
but probably nothing some hot glue and some slight modding would not fix :)  The other option is to just replace the rear frame with
a new one but that is not really fixing the problem – even RIM have told me replacing it will not fix it permanently meaning they have
not changed the design of the part so it is still flawed. If you prefer to go down that path offer great deals on phone
parts and are really efficient.  I don’t have any affiliation with them, I have just been a very happy customer of thiers in the past.

I do not believe this is a problem in the newer 9700 bold.

Hope this helps someone!

Sim Update – Shifter paddles and a better seat

June 29th, 2010

With the basics now sorted I’ve moved on to some more asthetic and convinience items for the sim.  I managed to pick up a seat from a local DIY car wrecker from a Suzuki Swift Gti for $28!  It’s got a couple of very minor rips but over all it’s in great condition and super comfy.

I’ve also recently added some F1 style shifter paddles to the wheel.  This enables easy use of cars that are only sequencial shifing in LFS.  It’s odd – a ‘H pattern’  gearbox based car can be driven as a sequencial but not the other way around.  I guess it’s because most commercial wheels do not have H shifting (or a clutch for that matter) so it keeps compatibility. I’m still considering what i can do to make an add-on for the H shifter to convert it easily to sequencial and back again but it’s less important now and it would only be for realism.

The paddles are constructed very simply. The orangy brown stuff is a silicone rubber.  The bolts support the flaps on the main bolts and give it a spring effect.  The gap between the microswitch and the paddle is only a couple of mm and it works really well.  The original design for the paddles were a little short and were not easy enough to reach so i extended them with another bit of aluninium rather than make new ones – hence the addition of the second set of bolts.

Sim pretty much finished now

June 7th, 2010

I completed the shifter not long after the last post and also made some slight mods to it.  The main change being that the shaft is now much shorter than the original one.

This is the shifter in it’s current state:

Also, since completing the shifter, I broke one of my design rules – the ‘Small/Storable/Dissasemblable” rule.  There were various reasons for this but the main one was that i just could not get the ergonomics right when sitting at a desk/table.  It mean that regardless of how i laid it out, it just didn’t feel right.  Not only that, I decided to utlise an old 32″ HD CRT TV that i had and it weighs about 50kg.  It’s not something i wanted to put on a rickety desk.

I proceeded to make a metal frame placing the pedals, shifter and wheel at comparable distances to my real car.  The seat came later….

With the basic frame complete, I was in the hunt for a seat.  Ideally i wanted to use a real car seat.  Not necessarily a real racing seat but perhaps just a slightly bucketed seat from a sports car (something still nice and comfy).  That is still the intention but for now, i’ve mounted an old school style plastic chair to it.  It’s not overly comfy and still doesn’t feel quite right but does the trick for the time being. I also added some adjustable feet to the frame.

This is pretty much how it is today:

The only change i have made since this image was taken is the addition of a handbrake.  This helps immensely for drifting and offroad driving.  It uses an extra axis on the mjoy.  It’s noting spectacular and ideally needs more sprung force on it but is very functional.

Shifter update

March 28th, 2010

My shifter is almost complete now.  All the mechanics of it have been done, just the electrics left.

The pictures are pretty self explainatory but i’ll explain how it works.

The first collet on the shifter shaft is staic and held by a grub screw.  The spring then exerts force against the delrin block supporting the skate bearings.  The block is free to move over the shaft.  This part gives the ‘clunk into gear’ feel.  Underneath the the rod end is a slightly cupped out thick ‘washer’ and then that’s followed by another static collet.  The spring force is also excerted on the washer and then the body of the rod end.  This means that when the shaft is moved off center, the washer falcrums on the body of the rod end and pulls the shaft down against the spring, this keeps it centered.  This combined with the gates on the bottom of the shifter gives it a very real feel.  I still have to put a slight concave in the neutral position although it is not stirctly needed as the spring is just about enough to give some more resistance, just before falling over the edge onto the ‘in gear’ ramp.

The plan for the electrics is to have a dual personality 6th gear.  There will be a toggle switch to make it either reverse or 6th.  Therefore in normal 5 speed boxes it will be reverse but in 6 speeds i can use it as 6th but flick a switch and it will be reverse.

p3280032_sml p3280034_sml p3280033_sml

Racing sim update

March 26th, 2010

Ok, as promised here is the details of the electronics.  Most of you would be interested in the load cell interface so i’ll start with that.  The interface is truly simple, the main chip, an INA122PA is only about $7 from RS and a little more from Farnell.  There are other equivalents but this is the one i used and is also one of the cheapest.  The pinout is very basic for our purposes.  You have a power supply (coming from the Mjoy) to power the chip and the load cell.  The load cell applies it’s voltage to 2 pins and the chip simply amplifies the voltage from the load cell.  The gain (how much it amplifies the voltage) is set by the resistor accross pins 1 and 8.  The capacitor is a simple 0.1uf filtering type. The cell puts out 2mv/v so at 5v excitation we get 10mv at full scale.  To get 0-5v we need to multiply that by 500.  For this chip that means a resistor of about 400 ohms.  Less resistance will give more gain.  Since my load cell is a 100kg item i have increased the gain on mine to about 600.

That’s about it!  Hook it up inline instead of a pot and you’re done.  Just make sure you get the wires around the right way…

lc_interface Load Cell interface

As for the main Mjoy board, I modified a layout i found around the net.  I have not removed any ‘branding’ so if one wanted to seek out the original designer i’m sure they could.  The only real change i made was to add pads to be able to vertical mount standard diodes for the buttons rather than use SMD types.  Most other changes were to add some distance between tracks etc.  Print, transfer, etch, drill and solder etc.  I made up my own paralell port programmer interface to program the chip in place with the provided header.

One thing i would like to add here is that originally i tried to use an AtMega88 as i was told they were basically the same.  Unfortunately they are not.  There are too many dfferences to allow the standard hex file (for the AtMega8) to work.  Someone has ported the code to the ’88 but i have not been able to get this to work.  I presume it has something to do with fuse settings on the chip but even though i have set them right, it still does not work for me. I ended up having to stick with an AtMega8 at about 5 times the price of the ’88.

mjoy_pcb p3210025_sml1

PCB Layout files (Sprint 5.0 format, free reader available to be able to print them

NB – The Mjoy PCB has incorrect axis lables, they are backwards so it should read X,Y,R,T,Z,Rx.  Not really important other than the fact that the XYRT axes are 10bit and the other 2 are only 8bit. Earlier versions of Mjoy only have 2 10bit axes (X and Y)


Please let me know if you download these files, it’s nice to know someone else is finding these useful.

I’ve also started work on my H Shifter for the sim.  I’m trying to keep the design simple but at the same time i want something robust and somewhat realistic.  Combining the ideas of some others, i have come up with my own design which should allow for this.

Shown below is the basis of the shifter (not complete obviously).  Between the 2 horizontal bars (the ones with holes in them) will go a block of delrin which supports 2 standard skate bearings.  I have not yet finished the profile on the horizontal bars, there will be another dip in the middle. The delrin will freely slide over the 1/2″ shaft and will be followed by a spring and then a retaining clip.  This will force the block/bearings down on the ‘ramps’.  This should give a ‘clunk’ into gear and also allow for a little freeplay between gears in the ‘y axis’ when viewed from above.  The centering mechanism will be another single spring around the shaft that sits on the rod end and is secured again by a retainer.  The compression of the spring will try to keep it centered.  From there it is only a matter of making a gate plate and hooking up the switches for the gears.  I intend to mount the switches in the base of the unit to keep them safe.

p3250031_sml p3250030_sml