1
\$\begingroup\$

I'm trying to make the Raspberry Pi controlled relay. Searching the internet the whole day, I still cannot get it to work. ( I did not even connect it to the GPIO yet, just using the 3.3v rail).

Specifically, the problem is with the transistor. I can't get it to work like a switch. I think it's not letting enough current pass through. Also it seems like more current is coming through the base rather than the collector(I used a LED connected to the emitter to test) .

The relay is working, because when I connect the relay to directly to the 5v rail on the raspberry pi. It clicks.

I have it wired up like this (see image below), just that I replaced the power supply with a 5v 1A one (replacing that 12V). R1 I calculated to be 3540 ohm. So I placed a 220 ohm resistor. This is based on coil resistance being 70 ohm, I(collector) being 5V/ 70 = I(collector) = 0.07A (from the data sheet, I don't know if I got it right). I then used Hfe value of 75 to find I(base). So 0.07/ 75 = 0.00093A . Which I then used with 3.3v (voltage of GPIO) to find the R1. So, 3.3v/0.00093A = 3540 ohm. enter image description here

Transistor model: KA2222A. www.ee.cgu.edu.tw/member/teacher/liuhl/Class/102-2-Introduction%20to%20Electrical%20Engineering/KN2222A.pdf

Relay Model:JQC-3F(T73). Rated for 230v output, 5v input. www.langir.com/pdf/pcb-relay-T73.pdf

I used instructables.com/id/Connecting-a-12V-Relay-to-Arduino/?ALLSTEPS to help me for the calculations, but he used 5v audrino, a different relay , a different transistor and 12v power supply.

I have knowledge on ohms law, what current and voltage is. I know what the components are supposed to do ( for example i know a transistor can be used as a switch, but I don't know how it works) . Other than that I don't know.

After reading all this, my question is just why is my circuit not working?? Thanks in advance! Below is how it's wired up in real life. The 2 blue wires are the 5v power supply. The green and the blue wire across the diode is the input for the relay. The blue resistor is the 220 ohm one mentioned above connected to the base of the transistor.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Based on your information, it should work, if the relay is actually a 5V relay, and the transistor is an actual 2n2222 (or similar). I suggest you pull everything out, pick a new transistor, and start again. If, with both the relay and transistor base at 5v (440Ω or lower resistor for 10mA base and worst case 33 hfe) it won't trigger, something is mislabeled. \$\endgroup\$
    – Passerby
    Commented Jun 15, 2014 at 18:33
  • \$\begingroup\$ Also, 0.07A / 75 is 0.00093A, or 0.93mA or 930nA. Your math is wrong. \$\endgroup\$
    – Passerby
    Commented Jun 15, 2014 at 18:34
  • \$\begingroup\$ Changed the calculations. I got 3540 ohms! Does that seem high? \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:48
  • \$\begingroup\$ The low resistor value isn't a problem. Giving the base 20mA won't adversely affect the collector current. So stick with the 200~400 Ω resistors. \$\endgroup\$
    – Passerby
    Commented Jun 15, 2014 at 18:54

2 Answers 2

1
\$\begingroup\$

Are the transistor emitter and relay power supply ground connected to the Pi ground? The transistor won't switch unless its emitter is connected to the Pi ground.

\$\endgroup\$
11
  • \$\begingroup\$ the emitter is connected to the negative node of the power supply. As for the relay, it's 1 side is connected to the 5v and the other to collector. \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:35
  • \$\begingroup\$ Is the "negative node" of the power supply connected to the Pi's ground? \$\endgroup\$
    – Majenko
    Commented Jun 15, 2014 at 18:36
  • \$\begingroup\$ Nope. But omg I tried it and it worked. I don't get how this works though. \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:38
  • \$\begingroup\$ A circuit is what it says it is - circuit - like you do on a running track. Round and round and round. How can it be like that with just one wire? That'd be like trying to do circuits on a straight track. You have to have the "back straight" to get back to the beginning on. \$\endgroup\$
    – Majenko
    Commented Jun 15, 2014 at 18:40
  • \$\begingroup\$ But I thought the negative node of the power supply served as the ground? \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:42
0
\$\begingroup\$

Almost without doubt a 12V relay won't work on a 5V rail. The solenoid force it exerts on the armature is proportional to current squared and this means the pulling force is reduced by about 80% compared to a 12V rail.

\$\endgroup\$
2
  • \$\begingroup\$ Hi andy, it's rated for 5v though and I tested just by connecting straight to the 5v rail of the raspberry pi. It works, I heard the click and current could pass through it. \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:30
  • \$\begingroup\$ Here's the relay to be specific. shop.ciseco.co.uk/jqc-3f-t73-5v-pcb-relay \$\endgroup\$
    – Melvin Foo
    Commented Jun 15, 2014 at 18:33

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.