Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Gertbot relay control

Mon Jan 09, 2017 8:01 am

G'day,
I have a gertbot for my rasperry pi, is there a way to use the gertbot to control relays? I got a relay board that need to have a 5 v signal to activate the relay, has anybody ever done that using the J pins on the gertbot?

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot relay control

Mon Jan 09, 2017 9:44 am

I am^h^hwas working on a multi page answer but my computer died.
(I am borrowing a laptop to write this)
You can not drive relays, let alone 5V relay directly but you need to add a little circuit.
I found a picture on the web here: https://www.wired.com/geekdad/wp-conten ... driver.jpg
As I have no details of your relays the following are guesstimates.
For the resistor use about 1K.
For the transistor any** small NPN transistor should suffice.
For the diode any** small silicon diode should suffice.

**The Elector magazine would use the names TUN or DUS for those.
I found a website explaining that too here: http://www.sentex.ca/~mec1995/circ/tuptun/tuptun.htm
That list has rather (very...) old transistor but gives a good impression of what works.
Those transistors are still widely available.

Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Re: Gertbot relay control

Mon Jan 09, 2017 10:24 am

Mhh I don't think I was bery clear when I explained that.....
When I refer to relay board I am referring to a duniotech4R1b Board
http://www.surplusgizmos.com/4-Relay-Ex ... _2632.html

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot relay control

Mon Jan 09, 2017 12:00 pm

Looks like it has opto-couplers on it. I can't read the parts from the photo.
I you can give me the part number I will try to find the datasheet.
If I find it I should be able to answer your question.

Side note:
I don't understand why they have opto-couplers AND relays. Looking at the placements
of the components on the PCB the opto couplers do not offer safe isolation.
(There are many small components along side to isolation gap).
So what are they for?

Post edit: I found the schematic but it does not have the optocoupler part number.
I probably don't need it because what I see is an LED + 1K resistor + optocoupler diode in series.
That will work fine for a 5V output but gets critical for 3.3Volts.
First: It is perfectly safe to try, it might work or not.
If not, or unreliable, the problem is your voltage drop. You have 3.3Volts. A diode takes about 0.6V
but an LED can take between 1.8V and 3.3V. Which leaves between -0.6 and 0.9 Volts over the resistor.
(the -0.6 of course does not exists, that becomes 0 volts: your circuit will not work)
I give you a 99% chance it will work if you short out the LED. Which is perfectly safe to do
Alternative you can reduce the value of the 1K resistor.
Say your LED takes 1.8V, then with 5V you have 5-1.8-0.6 = 2.6V over 1 K is 2.6 milli amps.
To get the same current at 3.3Volts you need 0.9/2.6e-3 = 346 Ohm: take a 330 Ohm resistor.

I also found that the website advertising that board disclaims any responsibility from using that circuit
with respect to lethal voltages.
Do NOT use this with mains unless a very experienced person has checked your wiring!!!

Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Re: Gertbot relay control

Mon Jan 09, 2017 7:05 pm

Thank you for your reply Gert, dont worry I will not use it for anything higher than 24 V, the Board can be connected directly to the raspberry pi uart port, it takes 5v supply, and then a 5 volt signal what I was wondering was if I can use the J pins on the gertbot to send the 5 volt signal as the gertbot uses all the uart ports the board is a 4r1B duinotech board, i will look for a datasheet later on

Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Re: Gertbot relay control

Sat Feb 11, 2017 6:09 am

G'day,
Today I found a logic level switcher for $3, will keep you posted if it works...

Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Re: Gertbot relay control

Sun Feb 19, 2017 5:13 am

Ok the solution is a lot simpeler than I though...
The j pins are send a signal strong enough to engage the opto couplers on the relay board I have, however the relay board needs a seperate 12 V power supply.
( I did only supply 5 volts to the boards like any other raspberry or arduino component, so the opto coupler engaged but the voltage was too low to activate the coil)
:oops: :oops: :oops:

User avatar
Gert van Loo
Posts: 2440
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Gertbot relay control

Sun Feb 19, 2017 8:34 am

Thank you. It is nice to hear it has been solved. Too many times I give advice or tips and never hear back again.

Michael_w
Posts: 17
Joined: Thu Mar 31, 2016 12:00 am

Re: Gertbot relay control

Sun Feb 19, 2017 12:13 pm

I appreciate your time and input, you have designed a great piece of hardware!

Return to “Gertboard classic”

Who is online

Users browsing this forum: No registered users and 3 guests