1

I've got an RPi running my OpenRemote2 Controller and want to add some more devices to my arsenal of remote control. These devices are a set of 3 mains switches (for lamps) and a projector screen which are both radio controlled and come with a blipper/sender. I popped the PCB out of the case and it was easy to work out which contacts to connect on the PCB as the micro-switches are on the opposite side of the board. Heres an image...

enter image description here

So figured all I need to do now is connect up those contacts using something like the GPIO. It doesnt need any power but just a connection as the PCB holds its own battery. I suppose it would be good not to use a battery but my understanding is the RPi output is 3.3v whereas the battery is 12v and reads 11.45v across the connections. Possibly the remote would work with less but designed for 12v.

Okay I've bought a few bits and pieces and could do with a bit of guidance. I can solder, understand what components do, and can follow instructions - i dont do design though :-/ I'm happy that I've got the right relay board. Just need to confirm I'm going down the right route. This is a very useful tutorial on YouTube

Here is the kit...

bits and pieces

8 way relay board

close up of relay circuit

By the way - a suitable enclosure will be courtesy of my kit 3d printer ;-)

enter image description here

Okay here is the prototype. I've hooked up some commands from OpenRemote2 and have the RPi operating the relay board. Each pair of relays will operate an on and off switch on the remote control. I'm using some software called wiringPi but getting some strange effects - the switch parameters I'm using in the commands don't seem to correspond with the pins out on the GPIO. Not a biggy but can only use 7 of the 8 connected. Can you see any connection problems? (theres a jumper on VCC/JD-VCC)

Got it! The wiringPi software includes zero so I now have 8 working relays. The valid parameters for activating GPIO using gpio.sh are 0,2,3,7,8,9,12,13. I'm guessing its to do with the conections I've used which are all on one side.

enter image description here

Heres the working prototype on YouTube

Assuming you are familiar with OR2 and creating commands:- The OR2 command protocol is Shell Execution Protocol The Path - Ive set this to \usr\local\bin\gpio.sh The Command Parameter relates to each of the pin pairs - they are bit of a peculiar order but sure there is some logic behind them.

gpio.sh should read somethng like this:

\#!/bin/sh
PIN=$1
/usr/local/bin/gpio mode $PIN out
/usr/local/bin/gpio writeb$PIN 0
sleep 0.5
/usr/local/bin/gpio writeb$PIN 1

This is telling RPI to close the circuit, sleep 0.5 seconds, then open again I was using 0.3 but failed to activate the remote - might be the remote control battery tho!

0

2 Answers 2

2

Direct connection to a device with unknown characteristics is risky. I would recommend that use some form of isolation. The safest approach would be to use relays. An alternative is to use optocouplers - success here depends on the characteristics (polarity, voltage, current) of the device. Provided you bond the earth of the controlled circuit and Pi together you MAY be able to use a transistor switch - darlington recommended.

http://elinux.org/RPi_GPIO_Interface_Circuits shows some interface circuits.

1
  • make sure you share ground between your device, and the pi. @Milliways, has a point about the risk, but you can likely figure out that circuit in an hour or so, and if you wanted to get fancy, you could throw a transistor in there, or use an opto-isolator to do the switching.
    – j0h
    Commented Aug 11, 2014 at 18:54
1

That is a good picture.

It looks like one side of each switch is connected to the + supply. Yes, direct connection would be really bad for your PI. a single transistor per channel is not going to do the job well. If you use relays they are going to need a transistor to drive each one. If you choose to do it this way use 12V "high sensitivity" relays and use a NPN transistor to drive it. There are plenty of examples on the Web.

I would recommend using Darlington Opto-couplers.

http://www.rapidonline.com/electronic-components/is4n46-darlington-output-optoisolator-58-0606 for example

The best thing about them is that even if the output is damaged, the PI is likely to survive unharmed. The opto-coupler's input is a LED and easy to turn on from the PI. Go for Opto-couplers with darlington outputs as they are sensitive, so in this case there are no extra calculations to do. Connect the collector to +ve and the emitter to the other side of the switch. It should not be any more complex. There is no extra current taken from the 12V supply, so the remote's battery could still be used.

there is no need to connect the grounds with opto-isolators.

Good Luck

Andrew

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.