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.
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.