About Me

I've been taking things to bits, and making things ever since I can remember, starting with dismantling knackered alarm clocks and watches and helping my dad fix the car. Now I have a well-equipped workshop and have aquired lots of new skills, so I can make better stuff. When they first appeared, I became involved with personal computers, and these and developments in electronics have increased the scope of the things that I can do. Just recently retired, so O yes, now I can make all sorts of stuff.....

Tuesday, 31 January 2012

Arduino home control - Part3

Success at last!

Well, I've lost count of the days I have wasted trying to get this to work using my Chinese radio modules and code off the 'net. Some of the code that I downloaded had errors, but I suspect that I could have made it all work if I'd had a bigger brain and an understanding of C++. Can't be arsed to learn C++, so I looked around for an alternative.

The best one I stumbled over is a chap on Instructables who had hacked one of the Home Easy HE100 remote controls so that pulses on the arduino switched opto-couplers to operate the on
and off buttons - brilliant! Original source for this is here -


I searched for a HE100 to butcher, but could only find them bundled with more HE modules that I didn't need. However, my son Sean had a HE200 spare, so I scrounged it and set to work with my little hatchet.

The HE100 is a simple remote with four pairs of buttons to switch a maximum of four devices on and off. The HE200 is a more complex remote with a small display panel and the ability to run timers and to control up to 16 devices on the same house code. However, to select a specific device, you need to press the 'unit' button until the number of the device you want comes up on the display, then hit the 'on' or 'off' button. Like most of these devices, the buttons simply momentarily short out contacts and it is easy to mimic a series of button presses using the arduino.

First step was to dismember the beast and see what's inside. There are two screws in the battery compartment which hold the two halves of the case together, you will need to gently prise the two halves apart with a thin screwdriver to release the clips. The PCB is held in with another two screws and clips at the top end which force the contacts on the PCB against the rubbery terminals for the display screen. With a bit of care, the board pops out leaving the display and the switches in the case half. PCB looks like this from the switch side:-


...and like this from the back. The wires are not part of the remote, I soldered them on to do some testing.


The PCB is double sided, and luckily the connections needed for the switches also appear on the back side of the board. Even better, the copper tracks have small bare copper pads, probably for testing, and ideal for soldering fine wires. Best of all, these pads are numbered, so pad 65 on the switch side appears on the back and labelled 65 as well.

This remote has two batteries, there is a 3 volt button cell which runs the timers and the switches etc, and a beefier 12 volt cell to power the radio transmitter - it will probably work off a lower voltage, but 12v gives maximum range. My arduino is in a box which also contains a 12 volt power supply, so I left the battery out and connected the terminals to the CAT5 fly lead which also feeds signals back to the arduino. I left the button cell in place, they last a long time and I didn't want to mess about dropping the 12 v down to 3.

You can't just connect the arduino outputs to the circuit board. I didn't try it but I imagine a small puff of acrid smoke and another visit to Mr Credit Card to replace the burnt bits. Instead, I used opto-isolators - these are small chips that connect to the arduino pins on one side and to the HE200 switch terminals on the other, a high signal from the arduino causes the terminals on the other side to be connected.

I wanted a neat job, so I fitted the opto-isolators inside the case of the remote - as you can see in the picture below, I just glued the back of the chips to the PCB with a dab of superglue, and then soldered the wires from the CAT5 fly lead to the various solder pads and the legs of the isolators. With some careful bending and trimming of the isolator legs, I managed to get the whole setup low enough to fit inside the case.


I screwed the case back together again, inserted the button cell and - amazing! - the display fired up fine, and all the buttons worked. Connected up the fly lead to the arduino box, no blinding flash or puffs of smoke, always a good sign. Finally I set a HE receiver into 'learn' mode and pressed the 'on' button on the remote, and the receiver did the usual reassuring clicking and turned on and off when I pressed the buttons on the remote.

I wrote a simple bit of code for the arduino to test it - basically, I 'learned' the receiver to be unit 10, then wrote some code that pulsed the unit button 10 times, then pulsed the 'on' button once. It worked! There is no way for the remote to tell the arduino which unit it has stopped at, so I set the remote to unit 1 using the buttons, then amended the code so that it counts up to unit 10, does the switching, then counts back to unit 1 again. This will be fine as long as the unit button doesn't get pressed accidentally, I need to find out how to prevent this - maybe a dollop of Mr Super Glue in the button

Too pleased with myself to do any more tonight, but a good day's work. I need to modify the code so that it reads the time and date from the PC when the code first starts up (the arduino has no internal real time clock) and I can then either write code that calculates when its dark or use a light sensor to tell it. Turning lights on and off at set times is one of the key functions of this box, and once this is working reliably I will add the rest of the stuff - switching the vent system with temperature; monitoring door lock status; watching the mailbox and the water leak sensors. Then tomorrow, we take over the world!

Thanks to all those who have helped with supplying me with information of this project, a pity that I am too stoopid to make the radio modules work - however, this hacked remote will do what I want it to with minimal effort, so I can spend more time doing other stuff :-)


Wednesday, 18 January 2012

Mail waiting alert - update

A quick follow up on this following an investigation today into the power issues and some mods to cure some erratic operation over the past week.

First, the power supply was only dishing up around 9 volts which fell to less than 8 by the time it reached the gatepost. Luckily, its a PSU salvaged from an industrial-strength network switch, and the output is adjustable with a small potentiometer, so a quick twiddle and voila! around 12 volts at the gate.

Still erratic in operation though :-( A bit more research later and I think I've found the cause. The Vellemann kit is designed to run off a couple of 9 volt PP3 batteries, one each for the transmitter and the receiver, and their web site/forum says that its OK to run the whole shebang at 12 volts. However, I discovered that if I drop the power to 9 volts on the receiver and leave it at 12 on the transmitter the instability goes away - no idea why, and finding out is well beyond my electronics knowledge. I've added a simple 9 volt regulator in the box and all seems well.

Just as well, as Mrs Grizzly was getting increasingly ticked off by trekking out to the gate to find the box was empty - a bit ironic, as when I announced I was going to make this gadget I got the standard roll of eyes and 'what on earth for??....' :-)


Friday, 13 January 2012

Mail waiting alert

My mailbox is on the gatepost, and the erratic timing of mail deliveries round these parts means sometimes several trips per day out in the pouring rain to check if there is mail. I built a detector from a Velleman kit to let me know when there was mail in the box, and this is how I did it.

The Velleman kit is an MK120 IR light barrier kit, available from Maplins in the UK and a number of other suppliers for around £10. It creates an infra red barrier, and sets off a squawker when the beam is broken. The kit needs to be soldered together, and for my purposes I needed to modify the kit slightly, as follows:-

1. make the infra red LEDs separate from the circuit boards
2. remove the squawker and replace it with a bright LED
3. also make the device send a signal to my Arduino based monitoring system.

First, the easy part - mounting the circuit boards in a weather-proof box. I had a spare aluminium box left over from another project and simply marked out the position of the holes and drilled and tapped them, then mounted the circuit boards on small plastic spacers to ensure that they couldn't touch the box.

The wires all come through the bottom of the box, and I put rubber grommets in the holes to seal them from the weather and stop the cables from chafing against the edges of the holes. Once all the holes were drilled, I sprayed the box and lid with satin black from an aerosol can.

In the picture, the green and yellow cables are the feeds to the IR LEDs, the other loose wires feed the LEDs that are fitted into the lid of the box.

To mount the LEDs remotely from the circuit boards I used a short length of coaxial cable (from and old audio lead) for each one. I tried CAT5 twisted pair cables and they were very prone to false alarms, I think because they picked up noise from each other and from the power cable - the coax solved that problem.

The LED end of these cables is exposed to the weather, so I encapsulated the end of the cables and the soldered connections in epoxy resin.

The 'mail waiting' alert is a bright orange LED that is fixed into the lid of the box (drill a 5mm diameter hole and secure the LED in it with a dab of super glue) with a short length of flexible cable to connect it to the squawker connection on the PCB. Note that a 220 ohm resistor is used to limit the current to the LED, and the LED was selected to give a bright light from around 5 volts - the box sits in direct sunlight most of the day, and a standard brightness LED can't be seen easily. Keep the unused squawker in your spares box for another day :-)

To seal the box from the weather I ran a small bead of silicone sealer around the edge of the lid and screwed it down tight. The sealer gets squeezed out of the joint, so the excess needs to be cleaned off before it dries (scrape most of it off with a screwdriver, then scrub it down with a wet cloth)

I feed the device with power from a central 12 volt power supply fitted in my central Arduino box, and a second (green) LED fitted into the lid of the box shows that power is present. This power supply also feeds the water leak detectors in the house (more on these later). The Velleman kit is designed to run on a 9 volt PP3 battery, but will happily work on 12 volts. When I built the house, I had a duct laid under the driveway to the gatepost and laid both CAT5 cabling and a mains power cable in it, so power is fed to the mailbox via the CAT5. This is not ideal, as the long cable run means that the voltage drops considerably and the 12v at the power supply ends up being around 8v at the mailbox. I plan to modify the power supply to fix that, although the mail detector works fine at this low voltage.

The same CAT5 cable also lets me feed the 'alert' signal back to the Arduino so that I can see on a screen in the house if there is mail in the box. I originally tried just using the raw output from the squawker connections, but could not get the Arduino to reliably read it, then realised that this was because the power supply is separate from the Arduino - instead, I use the squawker output to fire a small 5 volt relay which switches a connection between the Arduino's own 5v power rail and the data pin which monitors the mailbox status. Works a treat, although the low voltage sometimes makes the relay chatter instead of latching solidly.

My mailbox is a simple tin affair with an opening door at the front. I mounted the LEDs into some short plastic tubes glued to an aluminium plate across the back of the box, and angled in towards each other at around 45 degrees. A cheap make-up mirror is fixed to the inside of the door with double sided tape and reflects the beam when the door is closed. Drop a letter into the box and the beam is interrupted and the warning light comes on. Hooray!

It works fine, I just need to jack up the power a little so that the relay latches reliably. No more abortive trips in the rain out to the gatepost for me!


Thursday, 8 December 2011

Body sensing stair lights



I'm about to tackle the whole Arduino/Home Easy thing again after a break to finish off some other stuff. As a warm up, I thought I would write up the stair lights that I installed a while back and which would be one of the devices that will be controlled by the Arduino.

I started with two sets of cheap LED deck lights. These are small LEDs encapsulated in a slim waterproof plastic housing and with a stainless steel bezel and clip arrangement. Each light fits into a hole around 12mm diameter and they are designed to be flush-mounted into decking with the lights shining upwards.
I mounted a single lamp on each step, with two on the 'half landing' (I think that's what its called) and one on each side of the lowest step. They come in sets of 10 lights, and I needed a total of 14, so two sets required. I could probably have driven all 14 off one transformer, but I didn't want to risk overloading it so I spread the load across the two transformers that came with the kits.

Fitting the lights was the easy part. I drilled a 12mm hole horizontally into the wooden side of each step, and then drilled another 8mm hole from the top vertically into the wood so that the holes coincided - this let me feed the wire for each lamp into the horizontal hole, then fish it up with a slim hook through the vertical one. At this point I realised what my son Sean had discovered with his hall skirting lights: the lights are longer than the depth of the wood I was fitting them into, so the hole needs to be drilled into the wall behind. Fortunately, in my case the wall is plasterboard, and the extra depth is no problem.

So we now have lights on each step with a pair of wires poking out the top of the side board. On the half landing, there was no wood to fix to, so I fitted the lights to a length of skirting (grooved at the back to run the wires) and fixed the skirting to the wall with NoMoreNails. The lowest step sticks out into the hall, with no walls either side, so I cut a small triangular piece of skirting for each side and fixed these with some stick-on velcro. No other way to run the wires between these last two lights, so I tucked it down in the fold of carpet at the back of the step, and it hasn't reappeared.
Now the hard part, running the wires. I cut a narrow strip of wood the same width as the stair side and around 15mm thick, and cut a groove for the wires into the underside of it on the circular saw. I planned to nail the strip down with panel pins, so deliberately offset the groove to allow space for the pins. I needed two pieces of wood as the stairs are a lot longer than any wood I could buy.

I soldered each lamp to a single pair of wires (lights are wired in parallel) and fixed the wire to the top of the wood with tiny bits of gaffer tape to keep it more or less straight - without the tape, its one of those need-seventeen-pairs-of-hands impossible jobs to fit the wooden capping while holding the wires. The amount of juice carried by these wires is minimal, and the solder joints are all concealed, so I just offset the joints on each of the + and - wires by around 20mm so that they could never touch. You could use shrinkable tubing, but space is pretty tight.

Before covering the wires up, its a good idea at this point to connect the transformers and switch them on to make sure that all of the lights work and that all the solder joints are sound. If any of the lights doesn't work, check that its wired the right way round - LEDs do nothing if they are connected backwards.

I finished off by pinning the strip down (careful not to nail through the wires!) and running a bead of paintable silicone sealer along the joint between the wood and the wall to give an invisible joint.

Now into the home straight. I tidied up the tail end of the wires where they emerged at the bottom of the stairs, and soldered the transformers on to the ends. Plugged them in and switched on, and hooray! everything works!

Not the end of it, though, as of course the lights would then be on all the time. I needed them to only switch on a) when it was dark, and b) when somebody approached ether the top or the bottom of the stairs. After playing with various more complex solutions, I ended up with a cheap and cheerful setup using a Home Easy plug socket and a cheap PIR sensor.

The PIR sensor is designed to switch outside security lights, so it is mains rated and comes in a neat plastic housing which protects the unwary from touching the live wires. Its also has a pair of knobs which adjust the sensitivity and the range of the sensor, as well as the length of time it stays 'on', and the housing swivels as well. With the sensor 'eye' pointing up the stairs at roughly 45 degrees the sensor picks up movement at both the top and bottom of the stairs.

The whole lot is wired in series: the wall socket has the Home Easy socket plugged in, and into this is plugged a short length of 3 core mains cable which goes to the PIR sensor. The output of the sensor feeds a 4 way extension socket block unobtrusively fixed to the wall, and the two transformers are plugged into that.

I have the Home Easy socket turn on each day at around 8pm, and it stays switched on until 7am. During this time, the lights are off by default but turn on when anyone approaches either end of the stairs. The PIR timer is set to keep them on for around 30 seconds, giving plenty of time to navigate the staircase and giving enough light to see some distance beyond the last stair.

The sets of lights were on special offer at around £20 per set from B&Q, and the PIR sensor cost me around £5 from Screwfix (so cheap I couldn't resist buying two, no idea what to use the other one for yet, a classic bargain buy). The lights are one of those widgets that just works, and you take for granted - I only realised how useful it is when my Home Easy remote packed up recently and the lights stopped working.

Saturday, 26 November 2011

New router part 2

Finally managed to crack the last few issues, so the new box is now fully working and running my internet connection from both wired and wireless PCs. Its a bit fussy about DHCP, but I think its because you can't configure the PC with a default gateway unless you set a static address, do this to 'register' the gateway and then switch back to dynamic addressing and all is well. I also realised late in the day that my old router was still plugged in and probably still trying to serve up addresses and act as the gateway, even without the ADSL line connected.

Either way, all machines are now tickety-boo, just need to check that the phones connect as well and re-configure the internet radio and the IP camera to hook into the new wireless network and we're all done. Ten quid well spent, I think, lets see if this solves my connectivity issues.

Friday, 25 November 2011

New router!

Blimey. I have been having ongoing problems with my broadband connection, lots of drop outs for no reason. I think its the BT line, since I've changed the filter and the switch, and tried various different PCs, with no improvement. Before I get on the phone to my ISP (Zen, and highly recommended) I need to make sure that its not the router, so off I goes to ebay.

I find a Speedtouch 585v6 for ten quid with free postage, so I'm in like Flynn. Box arrives three days later, and sho' nuff its a new router and although with euro plug it also has a UK adaptor.

I plug it all in and check it out. No connection to anything, no great surprise there, so I go for the set up wizard. Ah. The menu is all in Spanish, although if you put the wrong thing in a box it complains in english (very much like my trips to Spain, in fact), and there are very few options available - PPPoA or RFC1483 - and it seems that manual configuration is not possible, the wizard has to do it. Ah well, its off to the web to get more information.

Several hours later, the best advice comes from the zen web site, who advise replacing the user.tpl file (this seems to be what drives the setup wizard) in the router with a new one which offers more in the way of options. Long story short, I now have a working router although it only works if I make my IP address public and don't use NAT - this requires me to configure each of my PCs with a public IP address (I think) and I'm not sure how that will complicate my life.

However. I have a new working router for a tenner, and will spend a bit of time experimenting with NAT and other stuff. Stay tuned

Friday, 11 November 2011

Arduino home control part 2

Well, the enthusiasm for this project has been dented a bit over the past week. I received my radio modules from the good folks in China, and set to work hooking them up to the Arduino using some breadboard. I also downloaded all of the software I could find that had any application to controlling the Home Easy kit and set to work. BTW, I'm already tired of typing Home Easy, so from here on its HE, OK?

The system needs a bit of code to do a 'one off' exercise first. This code listens to the radio receiver and when a button on a HE remote control is pressed, the software reads the incoming transmission and decodes the following key items of information:-

- the address code for the remote control unit (this is needed since all devices need to be paired with a one or more remotes, and won't activate otherwise)
- the address code for the target HE devices - if you don't know the code for the device, how can you switch it on?

The receiver software collects other stuff in the incoming package as well, but these are the only bits I am interested in.

The whole process fell in a heap at this point. Some of the Arduino software that I downloaded threw up loads of compile errors, possibly because not all of the required libraries are available. Other software uploaded to the Arduino OK, but then just sits there blank with no indication of what (if anything) its doing. Out with the breadknife and hacked the code around a bit to discover that -

- the radio module receives a fair amount of random noise traffic, to be expected I guess
- I get no change to the random noise when the button on the HE remote is pressed.

Tried a second receiver module in case the first was duff, but no change. Switched to several different input pins on the Arduino, no change. I have two different HE remotes, a HE200 and a HE300, no difference regardless of which one I used. Hmmm.

The HE remote is supposed to send a preamble sequence of high and low pulses to alert the target device that a live transmission is coming, and then sends a data package. The software that I have downloaded is supposed to look for the preamble and then capture the data. So, I have the following possible causes for my non-capturing:-

- the remote is sending a completely different bundle of preamble and data to that which the software is looking for
- the radio module is faulty
- I've connected the module wrong (unlikely, there's only three wires plus an antenna)
- the Arduino is reading the wrong pin
- the software is not reading the pulses on the input pin properly (I really hope its not the software as a) cleverer people than me have written the code, and b) although I can code simple stuff, this is a lot more complex and its going to take me ages to learn to write my own.)

I need to rule out the radio module first, so the first task is to hook it up to 5v power from a separate power supply (in case the Arduino output is too low - its already running a bunch of LEDs around the house - and look at the data output with an oscilloscope. If I get output from it, the next stage is to see how it changes when the HE remote is pressed next to its ear. A positive result from this means the radio is OK, so I then need to look further.

I'll hook up the 'scope over the next few days and see where we are then.