jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Connect Raspberry Pi to Remote Controller

Tue Jan 28, 2020 5:41 pm

Hi all,

I'm looking for a way to connect my Raspberry Pi (3 Model B) to the remote controller of my gate. At the bottom of this post, you can find a picture of the front and back of my remote.

I already did some research, and I think that the best solution would be to use the GPIO pins on the Raspberry Pi and solder wires from those GPIO pins to the correct button on the controller. I however don't have a lot of soldering and wiring experience and am thus looking for someone who can assist me with this. I think that I need to use one 3.3v GPIO pin and one regular GPIO pin? I also saw some people using a resistor, I suppose this is also necessary in this case?

Thanks in advance!

Jérémy


Image
Image

pcmanbob
Posts: 11955
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connect Raspberry Pi to Remote Controller

Tue Jan 28, 2020 6:54 pm

You can't just connect 3.3V and a gpio pin to the switches and expect it to work.

You need the pi to close a switch contact in the same way as pressing the physical switch does.

You could drive a relay from the pi and then use the relay contact to make the correct connection on the remote circuit board so simulating the button being pressed.

You could also do the same using an opto isolator but you would need to workout which way the current is flowing across the switch contacts to be able to connect the transistor of the opto isolator the correct way round.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

emma1997
Posts: 1666
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connect Raspberry Pi to Remote Controller

Tue Jan 28, 2020 7:46 pm

If that is similar to other 3v keychain dongles with 4 or less buttons then there should be no problem wiring a GPIO pin directly to the contacts. You need to connect common grounds and bring the button signal low to activate. The battery can be replaced by 3.3v from the Pi.

In order to preserve the ability to manually activate buttons then the Pi pin should switch from open (input) when idle to momentarily low (output) to activate then back again. If there is no need to press buttons other than with Pi then simply output low and output high are ok.

Remotes with more than 4 buttons may use matrix type keypad circuit so a transistor across each button is required. Not likely here though. It won't hurt to experiment with a piece of wire before hooking up the Pi to find out which type for sure.

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Wed Jan 29, 2020 12:03 pm

Thank you both for your help.

I would indeed prefer to directly solder to the board without using a relay. I also don't need to use the remote manually (this is an old one which we don't use anymore), only the Pi will use it.
I experimented a bit with a multimeter to see which connectors should be connected in order to activate the button. There are multiple possibilities, but closing the circuit diagonally always works and makes most sense (so holding one pen of the multimeter to eg. the left top connector and one pin to the right bottom connector).

Now how would I go with connecting this to the Pi? Should I connect a GPIO pin to one connector of the button and connect a wire to the ground from the other connector of the button? Like this sketch?

Image

The blue wire is connected to the GPIO2 pin of the Raspberry Pi, the black one to a ground pin on the Pi.

Thanks in advance!

pcmanbob
Posts: 11955
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connect Raspberry Pi to Remote Controller

Wed Jan 29, 2020 1:20 pm

As I said you can't do that , as you have it shown when you press the button you will short the gpio pin to ground and so damage your pi.

you can't just connect a gpio to a switch like that you have to drive a switch from the gpio to act in the same way as the existing switch,

which is what a relay or opto isolator will do.

if you persist with doing it this way then I can't provide any more help.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Wed Jan 29, 2020 1:41 pm

I'm not persisting in doing it this way, I was just assuming that what emma1997 said is also correct and would be easier.

So what you're saying is to put a relay in between, something like this?

Image

(Red is 3V3, blue is GPIO, Black is ground)
( Edit: I would probably need to connect to 5V depending on the relay)

Thank you in advance!

pcmanbob
Posts: 11955
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 9:54 am

Yes that is what I was suggesting , but you can also do it using an opto isolator like this

Image

The only thing you you have to be aware of is that the output of the opto isolator is polarity conscious so if you find it doers not work then you would need to swap the connections to the switch ( wires A & B in the diagram. )
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 10:25 am

Thanks for your answer and the scheme of the opto isolator.

Are there any advantages on choosing the opto isolator above the relay? Or vice versa?
I'm not really experienced with electrical stuff like this (more a software guy), and I kinda feel more comfortable with using a relay since I wouldn't need to keep into account the 'polarity conscious' thing and it is in my opinion easier to understand and to work with.

User avatar
rpdom
Posts: 19284
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 10:47 am

Some advantages of an opto isolator are that it requires very little current to drive it, so can be driven directly from a GPIO line without needing a separate power connection and driver board, it has no moving parts to wear out, is silent and much smaller than a relay.

Some can switch high currents, like a relay, but in this case you will be switching a tiny current. A relay would be overkill.
Unreadable squiggle

pcmanbob
Posts: 11955
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 10:56 am

Relays will be bigger and have moving parts and can be problematical getting them to work with the 3.3v gpio because many of the cheap ones are designed to work with the 5v arduino.

see here for explination
https://www.raspberrypi.org/forums/view ... 8#p1225448

the opto isolator has no moving parts and is much smaller , the polarity problem is not that difficult to solve , you just need to connect it up and test it , if it does not activate your remote then just reverse the 2 connections to the switch.

but if you are happier using the relays then its not a problem, if you are willing to build you own relay board you could even use dil relays which are much smaller but you would need to build your own relay driver circuits as well.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 11:18 am

Thank you both for your answers. I was indeed looking into buying the 'Keyes Funduino 5Volt 2x Relay" (https://www.sossolutions.nl/2x-relais), which is thus powered by 5V. I do understand that it is uncertain how it responds to a 3v3 GPIO signal.

I will look further into the opto isolator as that does indeed sound better, although slightly more challenging for me. Do you guys have any suggestion for a good opto isolator that I can buy?

User avatar
rpdom
Posts: 19284
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 11:51 am

Pretty much any general purpose opto will do, like a PC817 or 4N25
Unreadable squiggle

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 1:00 pm

Okay thanks! To what kind of stuff do I need to pay attention? Voltage, Ampere, ..?

User avatar
PeterO
Posts: 6095
Joined: Sun Jul 22, 2012 4:14 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 1:14 pm

jeremykeu wrote:
Thu Jan 30, 2020 1:00 pm
Okay thanks! To what kind of stuff do I need to pay attention? Voltage, Ampere, ..?
pcmanbob mentioned polarity. To get it right first time the collector of the opto-transistor (pin 5 in the diagram above) needs to go to the switch terminal that reads positive when you put a voltmeter across the open switch.

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 2:12 pm

No, I meant more like to what kind of stuff do I need to pay attention when buying one, since different opto isolators exist..

pcmanbob
Posts: 11955
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 3:24 pm

Almost any opto isolator would do the job because you will be working with 3v and very low current on the remote controller.

as rpdom suggested a PC817 or 4N25

or any of the 4N2X series or the 4N3x series will do.

if in doubt post version you are thinking of buying and we can advise.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

User avatar
rpdom
Posts: 19284
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 3:34 pm

pcmanbob wrote:
Thu Jan 30, 2020 3:24 pm
Almost any opto isolator would do the job because you will be working with 3v and very low current on the remote controller.

as rpdom suggested a PC817 or 4N25

or any of the 4N2X series or the 4N3x series will do.

if in doubt post version you are thinking of buying and we can advise.
Exactly.

Many of the opto isolators I've used have been scavenged from failed power supplies. The PC817 and 4N2X series are very common in those. The opto is one of the components least likely to fail.
Unreadable squiggle

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Thu Jan 30, 2020 5:29 pm

Thank you to all! Okay, I'll pass by a store tomorrow. And thus I also need a 470 Ω resistor?

So the setup would look like one of these two images, depending on whether I use the PC817 or the 4N25:

ImageImage

(Blue wire: 3V3, Black wire: Ground)

emma1997
Posts: 1666
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connect Raspberry Pi to Remote Controller

Fri Jan 31, 2020 2:20 am

jeremykeu wrote:
Wed Jan 29, 2020 1:41 pm
I'm not persisting in doing it this way, I was just assuming that what emma1997 said is also correct and would be easier.
Actually it is correct and would be easier. Probably safer and more reliable too since fewer components and less wiring involved.

Attached is a pic of similar dongle wired for direct connection to a Pi. Several were built and ran w/o issue for over 4 years as part of my x10 based security system. Since then Pi were replaced with ESP32s but only due to space and power requirements. Many interfaces for different type keypads built over the years for myself and others no problem either.

Since you've indicated there will be no manual press, concerns from other posters are not particularly relevant. Even then I would not hesitate considering the currents involved and actual characteristics of Pi io. To please detractors a 100r-1k in series would prevent any possible harm. I skip it myself.

Brief glance tells me your second attachment is in the right direction. Maybe add a wire from 3.3v between the two (do not leave that battery in!). If anything else I recommend a piece of paper in the battery holder to prevent short if squeezed. It never caused any permanent issues for me but the reboot can be a bit disconcerting.

Like with many other suggestions of mine it is not the only way. Adding relays and optoisolators (or John Deer backhoe) as recommended by the other smart and helpful posters will work. Personally I tend toward simplest and most economical solutions. Not often a popular attitude on internet forums.

This is the internet so care should be taken from where we get our info and bag of tricks. Unfortunately some enjoy watching noobs spin or just misguided themselves. Or often just boils down to personalities and human nature. Nobody likes to be told they are wrong. So highly recommend you do not just listen to me because I could be one of them. Involve in some research yourself and base actions on that. In the end you are responsible for your own decisions (as are we all).

One thought is to try more than one of these schemes and report back so others will not go through the same confusion. It would be nice if more of those seeking advice returned the favor.
Attachments
IMG_3627.JPG
IMG_3627.JPG (80.26 KiB) Viewed 3999 times

PhatFil
Posts: 1705
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Connect Raspberry Pi to Remote Controller

Fri Jan 31, 2020 6:52 am

Is the remote control hack your only option?

I cant read anything on the pcb or chips in the OP's Pics other than the battery specs.. Is there any information as to the signal and frequency that this device emits?

Is there any chance of sniffing and replicating the signals without the remote hack?

If the device broadcasts a 433mhz signal for example a cheap Rx and TX pair of modules can be sourced for few dollars and if a known protocol is used to encode the signal sniffing and replicating may be possible.

However some more secure systems use rolling or changing codes once paired with a controller which is NOT quite so trivial to hack.

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Fri Jan 31, 2020 5:55 pm

emma1997 wrote:
Fri Jan 31, 2020 2:20 am
jeremykeu wrote:
Wed Jan 29, 2020 1:41 pm
I'm not persisting in doing it this way, I was just assuming that what emma1997 said is also correct and would be easier.
Actually it is correct and would be easier. Probably safer and more reliable too since fewer components and less wiring involved.

Attached is a pic of similar dongle wired for direct connection to a Pi. Several were built and ran w/o issue for over 4 years as part of my x10 based security system. Since then Pi were replaced with ESP32s but only due to space and power requirements. Many interfaces for different type keypads built over the years for myself and others no problem either.

Since you've indicated there will be no manual press, concerns from other posters are not particularly relevant. Even then I would not hesitate considering the currents involved and actual characteristics of Pi io. To please detractors a 100r-1k in series would prevent any possible harm. I skip it myself.

Brief glance tells me your second attachment is in the right direction. Maybe add a wire from 3.3v between the two (do not leave that battery in!). If anything else I recommend a piece of paper in the battery holder to prevent short if squeezed. It never caused any permanent issues for me but the reboot can be a bit disconcerting.

Like with many other suggestions of mine it is not the only way. Adding relays and optoisolators (or John Deer backhoe) as recommended by the other smart and helpful posters will work. Personally I tend toward simplest and most economical solutions. Not often a popular attitude on internet forums.

This is the internet so care should be taken from where we get our info and bag of tricks. Unfortunately some enjoy watching noobs spin or just misguided themselves. Or often just boils down to personalities and human nature. Nobody likes to be told they are wrong. So highly recommend you do not just listen to me because I could be one of them. Involve in some research yourself and base actions on that. In the end you are responsible for your own decisions (as are we all).

One thought is to try more than one of these schemes and report back so others will not go through the same confusion. It would be nice if more of those seeking advice returned the favor.
Thank you for this extensive answer. I don't have a lot of experience myself in electronics, so it's very difficult to judge what would be the 'best' solution, or which solutions are okay and which not. This means that I do indeed have to rely on advice given here and on information that is available online.

When thinking about the different solutions, it does make sense that I need to create some kind of 'loop', as I did the same during the try-out with the multimeter (I think?). This is in the end what the button does too. That's why I went for the other solution that was presented in this thread, which is using the relay/opto isolator. Also the fact that multiple people agree with this gives me the feeling that the solution is good.

Thank you a lot however for your suggestion! I will try to report back, but I don't want to fry my Pi by doing something wrong. :p
PhatFil wrote: Is the remote control hack your only option?

I cant read anything on the pcb or chips in the OP's Pics other than the battery specs.. Is there any information as to the signal and frequency that this device emits?

Is there any chance of sniffing and replicating the signals without the remote hack?

If the device broadcasts a 433mhz signal for example a cheap Rx and TX pair of modules can be sourced for few dollars and if a known protocol is used to encode the signal sniffing and replicating may be possible.

However some more secure systems use rolling or changing codes once paired with a controller which is NOT quite so trivial to hack.
Thank you for your answer. Remote control hack is not my only option. I could go through the hassle to try and figure out my 20-30 year old gate installation to directly connect the Pi to it. I however would like to keep the Pi inside the house and don't have any sockets directly available near the gate.

The remote in the picture is a 'Sommer TX03-8-4' (full size image here: https://d.pr/i/bbpeI3). This transmits a 868,8MHz FM signal and a Somloq1 rolling code. This is why I already figured out that it would be easier to just sacrifice an old remote that is no longer being used and use this to send the signal instead of trying to 'replicate' a remote and figuring out the rolling code and etc.

---

Back to the opto isolator. I didn't find the necessary stuff in the store which I went to, so I just decided to order it online. It should arrive monday/tuesday, so I will report back then! :D I ordered the PC817 and some resistors.

jeremykeu
Posts: 14
Joined: Thu Feb 15, 2018 2:53 pm

Re: Connect Raspberry Pi to Remote Controller

Wed Feb 05, 2020 12:04 pm

Got some good news. Soldered everything together today and it works perfectly! Here's a picture of the end result:

Image

(Please excuse my soldering skills, this is the first time I'm soldering something myself)

I followed the first scheme from my previous post. The only difference is that I used GPIO10 instead of 2, since 10 is during startup on 'low', while 2 on 'high'. This caused the remote being triggered during startup and until I started my program.

Thanks for all your help! Really appreciate it and couldn't have done it without you people!

emma1997
Posts: 1666
Joined: Sun Nov 08, 2015 7:00 pm
Location: New England (not that old one)

Re: Connect Raspberry Pi to Remote Controller

Thu Feb 06, 2020 7:48 pm

Excellent news. Thanks for getting back with your success. I find these threads quite interesting considering my personal interest in hacking remotes. It's almost a separate hobby by itself.

So being convinced to take The Long Road Home had some benefits after all. I think it was worth a few extra days and dollars to learn about optos, pull ups, etc. Definitely lots more fun than any boring piece of wire too.

Maybe someday investigate the possibility of powering from the PI instead of the coin cells. One does have to take more care then compared to direct connect since wiring errors could get tricky. The important thing is it's working now and can only get better with similar future projects. Good luck.

Haskar
Posts: 1
Joined: Tue Aug 11, 2020 11:29 am

Re: Connect Raspberry Pi to Remote Controller

Tue Aug 11, 2020 11:43 am

Hey Jérémy and all of the other awesome people in this thread!
Thanks for the nice guide. I replicated the results and it works fine :)

I also wrote (mostly copy pasted) some python script to control the garage-door (I call it "Garagentor" in german ...) via MQTT over openhab.

Code: Select all

import paho.mqtt.client as mqtt #import the client
from gpiozero import LED
from time import sleep

Tor = LED(27)

############
def on_message(client, userdata, message):
    print("Message: ", message.payload)
    if message.payload == "OPEN":
        print("Garagentor oeffnen")
        Tor.on()
        sleep(5)
        Tor.off()
        sleep(1)
    print("done")

########################################

broker_address="192.168.1.4"
client = mqtt.Client("RaspyZero") #create new instance
client.on_message=on_message #attach function to callback
print("connecting to broker")
client.connect(broker_address) #connect to broker
client.publish("RaspyZero/Debug","Online") #publish
client.will_set("RaspyZero/Debug","Offline") #last will

print("Subscribing to topic")
client.subscribe("RaspyZero/CMND")

client.loop_forever() #start the loop
In my case pin 1 of PC817 is connected to GPIO27
And I also connected the power supply to the raspberry pi directly but I didn't desolder the battery compartment just in case I need to disconnect it and reprogram it.

@PhatFil: I tried to "hack" the signal first. It is a 868.35 MHz signal with a rolling code. It is possible but more expensive if you need to buy the equipment to decode first. It is also more time consuming and harder than just connecting an old remote.
I bought an SDR-Stick and a YARD stick one ... and I couldn't get it done in a week ... I am also not familiar with RF hacking but I learned a bit in the process.

Sowsix
Posts: 1
Joined: Fri Sep 04, 2020 4:22 pm

Re: Connect Raspberry Pi to Remote Controller

Fri Sep 04, 2020 4:37 pm

jeremykeu wrote:
Thu Jan 30, 2020 5:29 pm
Thank you to all! Okay, I'll pass by a store tomorrow. And thus I also need a 470 Ω resistor?

So the setup would look like one of these two images, depending on whether I use the PC817 or the 4N25:

ImageImage

(Blue wire: 3V3, Black wire: Ground)
Hey there,
I've almost the same project, but with a bluetooth remote powered with two 1.5V battery (so 3V)
IMG_20200904_120853_2.jpg
IMG_20200904_120853_2.jpg (244.77 KiB) Viewed 1989 times
Please can you explain how did you decide to put a 470Ω resistor ?
How did you get to make it work ? i've Domoticz but i don't know how to send command to GPIO.. :shock:

OPTIONAL : Is it possible to remove my two battery and connect it directly to 3v of raspberry gpio ?

sorry, newbie in electronic ...

Return to “Automation, sensing and robotics”