I didnt play much with RPI but now we have finish one project where we are triggering GPIO. The PCB relay board should be triggered from RPI GPIO and the door should be opened. Now, before i connect PCB to RPI i want to be sure that nothing goes wrong. This is the pcb schematics that we use for the relay trigger.
formatting link
What do you think . can i connect this directly to RPI GPIO, and which pins can i use ?
Thank you in advance !
Didn't find your answer? Ask the community — no account required.
S
Spehro Pefhany
Yes, it should work fine.
Reduce R1 to 560R to compensate for the 3.3V output of the Rpi port pins, and use the 5V power for the relay (and a 5V relay coil).
Double check the connections before applying power.
G
gm
----------- should i reduce the resistor value ? Am asking because i have made the pcb and i have to test it today and i dont have 0,5K near me. I have to buy it tommorow
G
gm
--------------- btw. what pins should i use ?
J
Jan Panteltje
On a sunny day (Thu, 06 Nov 2014 17:33:24 +0100) it happened gm wrote in :
Depends on what other things you want to use on the GPIO. Some pins have special functions. If all you do is drive some relais, then it makes little difference.
As for that resistor, take current of relay, divide by beta transistor, multiply by 10, and that is a safe base current. Then find R from (3.3 - .7) / base current. The .7 is the Vbe drop. It is not critical in any way.
E
edward.ming.lee
we
I
i
that
ch
o
Yes, good to go through the numbers, then just use 1K. 1K is common to sto ck. I think i have a few hundreds. It you have a really bad Q, then 680, 5
60 or 470. It might saturate the Q a bit, but not to worry. The selections might be strange to the OP, but for historical reason.
G
gm
-------------------------------------------- I need to drive just this relay. The relay should open a door. What pin number would you suggest. I newer use GPIO on PI, that's why am asking...
R
rickman
That is a question better answered by the rPi group. So I am cross posting your question.
Rick
J
Jan Panteltje
On a sunny day (Thu, 06 Nov 2014 18:53:06 +0100) it happened gm wrote in :
I dunno, I only have model B Raspies Specifically bought some extra so not have to change all my connectors, Next you will ask how to write the soft to drive that pin? If you know how to drive that soft then you know what pin to use.
G
gm
---------------------- OK. I have written the sw so this part is working. At least with LED. If i dont change anything on PCB , then i will connect this like this:
5V to pin 2
GND to pin 6
Signal to pin 7 ( GPIO 4 )
Will this work ?
W
Windmill
Diode D1 is vital to protect the transistor from the inductive surge when the relay is turned off (without D1 the surge voltage can be surprisingly high, even hundreds of volts and often enough to give you a small shock if you touch the relay), but one thing that can sometimes happen is that with D1 in circuit the current through the relay decays quite slowly.
How slowly depends on things not usually included in the specs for the relay, but if it takes too long, you can add a *small* (low value) resistor in series with D1. That will increase the voltage surge when the relay turns off, and ideally you would use an oscilloscope to see how big the spike is, making sure that it doesn't exceed the voltage rating of the transistor (usually given as Vce).
Sometimes everything is fine with no resistor and sometimes the relay is too slow
Windmill, TiltNot@NoneHome.com Use t m i l l
J.R.R. Tolkien:- @ S c o t s h o m e . c o m
All that is gold does not glister / Not all who wander are lost
G
Gordon Henderson
Yes.
If you want to make life easy for yourself, then I'd suggest installing wiringPi which has a command-line utility called gpio which lets you trivially fiddle with stuff from the command-line without writing scripts/programs, etc.
formatting link
To play with the relay on pin bcm-gpio pin 4, then:
gpio -g mode 4 out gpio -g write 4 1 # Turn on gpio -g write 4 0 # Turn off
With the disclaimer that I wrote wiringPi...
Gordon
R
rickman
Sounds like a useful program. Have you ever used Forth? This sort of capability is built into the language at a low level and if the syntax is not optimal for your use it can be easily modified. It is also good for constructing any program you might be interested in writing... all of it testable interactively. I have installed gforth on my rPi and hope to have it connected to something soon.
Rick
G
gm
--------------------- I will use pin 18 instead ( GPIO 24 ). So i have connected as described but the wires are still on terminal, i didnt hook up a pcb. I have set high for GPIO 24 and its working fine. High was set for 2 seconds and in this time i have 3,3V.
If everything is ok i will connect it to PCB.
G
Gordon Henderson
Yes, and I mentioned this in your Forth thread a while back; I spent a year being paid to write Forth. I have no intentions to write anymore Forth, paid or otherwise. C is my language of choice, then a BASIC-like language (but only because I wrote my own BASIC-like language)
The gpio command is just that - a command that you type in from the shell. No need to invoke any interpreter, compiler, etc. you can then incorporate it into a simple shell script too. I frequently see people writing 10-line Python programs just to turn an LED on and feel somewhat sad that they're doing that rather than just typing in a simple command to test their projects.
Gordon
J
Jasen Betts
The maximum you'll get from adding the resistor is the resistor value divided by the relay resistance multiplied by the voltage powering the relay, plus the diode drop voltage.
umop apisdn
J
Jasen Betts
yes, the too high a resistor can cause excessive heating in the transistor, and then the transistor fails.
Anything in the 200 Ohms to 600 Ohms range will suffice, eg: you could parallell two 1K resistors to get 500 Ohms. or use a 330 or a 470 if you have them on-hand.
umop apisdn
J
Jasen Betts
If you already had it blinking a LED, use that pin (if you don't need to blink the the LED anymore)
umop apisdn
G
gm
---------------------- OK i can do that but i dont understand one thing:
Dont i need to change R1 from 1 to 1,2 KOhm ? Because ih i leave it at 1K the base current will be 2,6mA instead of
2mA. If the raspbery PI port can handle and give this much or current then there is no problem. Nothing should burn out ... OR am i missing something ?
/////////////// BTW. is someone of you working in Python ? ///////////////
R
rickman
When I looked up the transistor you are using it says the DC current gain is minimum of 100. You don't say what relay you are using or what current it draws. The base current limited by R1 should be no less than
100 times smaller than the collector current which is whatever the relay draws. If the rPi outputs pull up to 3.3 volts, subtract 0.7 and divide by the current to size the resistor maximum value. You can get the I/O voltage and the max current drive from the Broadcom data sheet for the CPU. If the CPU output can't drive enough current you can use two transistors connecting the emitter of the first to the base of the second. Then the current gain of both transistors is multiplied.
Rick
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required
Report Content
You are reporting this content to the moderators. They will look at it
ASAP.