Thursday, August 21, 2014

Integrating a Generic Relay Module with Insteon



SainSmart 4-Channel Relay Module

Relay modules such as the one pictured above, available in 1, 2, 4, 8, and 16 versions, are readily available from a number of sellers. Click the picture above to be taken to Amazon for the SainSmart version.

All of these modules are similar. They work on a 5v system, both requiring 5v to operate and switching when they receive 5v or ground (depends on the model, some can be switched by a jumper), and switch up to DC30v or AC250v at 10A.  They are an excellent addition to any budding Arduino enthusiast's toolbox. I used relays like this in my Arduino-powered stoplight, which uses an Arduino to give the logic to a standard stoplight, which is powered by 120v mains.


My home automation system of choice is Insteon, a powerline communication system.

This summer, I installed recessed can lighting in my living room. Six lights in total, but I wanted to be able to turn the one directly above my TV off, without having to resort to such archaic means as unscrewing the lightbulb.

I initially tried a Micro On/Off module hidden in the can light I wanted to remotely control. If I hadn't wired all of the lights together in series, adding this to the scenes for the living room would probably have given me what I want. The problem is, that though once the living room can lights were turned on  the micro module received power and would work to switch that can at will, it didn't boot up instantly. So it wasn't a seamless solution. When you'd turn on the cans, all of them would come up, then the micro module would boot up, and only then could you turn that TV can on and off.

This solution would also cause Insteon network communication issues, since anything with that micro module in the scene would continue sending requests and eventually give failed communication notices. This isn't good networking.

My lack of foresight required some clever electrical engineering. I remembered some of these relay modules, more than able to handle switching a single 120v led can light, but how to integrate it into my Insteon network?

I took a rather simple approach, avoiding the inclination to make a wifi-enabled, Arduino-powered, relay switching, network-enabled do-it-all box. I wanted to use an older I/O Linc Insteon module to provide the power and then activate and deactivate the 120v relay to the TV light.

Though the I/O Linc has ports for 5v, GND (ground), S (sense), N/C (normally closed), N/O (normally open), and COM (common). The latter three are used for the output of the I/O Linc, as it has a built in relaying function. The in-built relay function will only switch low voltage, for example, I have one hooked to my garage door opener to trigger the door to open or close as needed. I/O Lincs respond to any Insteon input, so if I could get the I/O Linc to switch one of my relay modules, with those relays switching the high voltage side, I'd be in business.

One word of note, the output of the I/O Linc can function in either momentary or latching mode. In momentary mode the I/O linc will open the N/C contact and close the N/O contact (sending it to common) for a period of time before switching it back. This is how it functions as part of my garage door operation, it shorts the N/O and COM for a second, simulating the physical press of the garage door button on the wall.  Latching mode makes the relay output work as a switch, going back and forth between the N/C and N/O being sent to COM. Think of latching mode working like a light switch, it's either on or off until you flick the switch again, nothing is timed.

On the bench, the 5v output of the I/O Linc will power the relay modules, no problem. So I ran the 5v and GND from the I/O Linc to the relay module, jumped the GND to the COM, then used the output from the I/O Linc (set to latching mode) to send ground (from the COM) to my output of choice (in latching mode it doesn't matter which, the N/C or N/O is used, as it just moves back and forth).

After crawling into the attic, the relay functioned just as expected. My remote (either a Remotelinc or a Keypadlinc) can send a command to the I/O Linc to cycle the high voltage relay on and off. This worked beautifully for all of about 10 minutes. Back up into the attic I go, rewire everything, thinking the attic was just too hot for the I/O Linc or that the I/O Linc failed. Replace everything, bring the Remotelinc up with me to check, and get it working again. Ten minutes later, it quits working.

I figure out, from all these failures, that either using the 5v from the I/O Linc constantly or (more likely) shorting the ground from the I/O Linc to COM was causing the I/O Linc to overheat and become inoperable. I fried one of them doing this, so DO NOT SEND AN I/O LINC'S GND OR 5V TO COM or else you'll crap the bed.

I hooked an old cellphone power brick into the mix, to both power the relay board and to become the new source for my ground (or 5v into COM if your relays switch with a high input). What you end up with is a relay that is controlled by the I/O Linc, can switch a 120v line signal, and the relay board is powered by any 5v power adapter which can be plugged into the pass through mains plug on the I/O Linc.

***DO NOT UNDERTAKE SWITCHING HIGH VOLTAGE IF YOU DO NOT KNOW AND UNDERSTAND WHAT YOU ARE DOING. YOU CAN KILL YOURSELF. HIGH VOLTAGE IS DANGEROUS.****

You'll also, if making a permanent installation, need an understanding of the rules, laws, codes, etc. for high voltage wiring.

Here's how to wire the relay up. Remember to switch the I/O Linc into latching mode. Since Fritzing doesn't have either of these devices, I resorted to wiring up another on the bench.

I use a mini breadboard to be the backbone of the system, but it's not needed. Once you get it working, you can solder the wires together. The line on the left, with the black at the top, is the ground/negative lead from a USB 5v power supply. Yellow and orange leads are tied to ground.

The line on the right, the red wires, are 5v power.


Yellow, tied into the COM port on the I/O Linc is the ground from the external power supply.

Orange is the N/C port on the I/O Linc here, but if you're in latching mode, it really doesn't matter. Tying it into N/C means that it'll default to "on", so in the event of some failure, the relay will be triggered to close (i.e. on).


On the relay board side, the brown wire from the breadboard brings ground to the GND pin (far left) and the red lead brings 5v from the breadboard (far right). The orange wire comes from the I/O Linc and is the low side trigger for the IN1 (relay on the left, where my finger is). Though I have a yellow wire in IN2, ignore it, that's not the same as the other yellow wires, it was just a spare wire on the test leads.

If you've got it all wired up, toggling the I/O Linc (either by sending commands from a linked remote or by tapping the black button on the side) should toggle the relay (you'll hear a click and the led on the relay board will turn on).

You can now use the relay's high voltage side to switch a load (switch it on the "hot" wire, typically black, not on the neutral, typically white). There's a little diagram on the relay's output side to tell you which terminal is normally open and which is normally closed. Use a multimeter to help make sure your circuit is wired correctly and operating how you want before you put the more dangerous high voltage hookups in.

The biggest advantage of switching my TV can light this way is that the relay doesn't care what the voltage or current is, it just switches back and forth. So I can toggle that one can light on and off while the upstream circuit is powered by a dimmer switch. For example, I can dim the lights to 50% and then toggle the TV can off and on. It truly operates seamlessly now, essentially like a bulb I can remotely unscrew when I don't want the TV washed out with light from above.

1 comment:


  1. It is really useful information, Thank you for sharing this useful information with us. Recessed Mounted Magnetic Contacts

    ReplyDelete

Search This Blog