Electronic – Activating Relay Coil (NPN and MCU)

esp8266npnrelay

Circuit primitive in CircuitJS

First, I'm having a hard time with transistors, and only recently managed to pass current through a NPN as planned (70-ish mA from 5 V with a 325 hFE 2N3904 with a 10K Ohms to the base).

Second, I'm using a ESP8266 devboard, which can only pass 40-ish mA through its GPIO pins, and a Songle relay that needs 70 mA at the coil according to the specs.

I have 3.3 V from my breadboard power supply going to the rail, then to the MCU Vin, and again from the rail to the relay's coil, and the other side of the coil to the NPN's collector; the emitter is connected to the ground rail, as is the MCU. The base is connected to a GPIO, via a 10K resistor; the hFE is 325.

Everything is powered from the same battery, so is at the same potential (I used to try while the MCU was connected to USB, but I wasn't sure if this was a problem or not).

I cannot get the relay to click, or even a LED to light.

If someone could walk me through the math, and tell me what I'm doing wrong, I'd greatly appreciate. Transistors were pushed to me as "simple", and "like a switch", but it's neither to me, and the simple fact there's also PNP transistors kinda makes me want to cry.

Again, any help would be dearly appreciated. I would post a picture of the setup, but there's a lot of stuff on the breadboard, and I'm not sure it'd be clear, but do let me know if it would be necessary.

[Picture added]

Circuit on breadboard.

Best Answer

I had same problem too.

First assume your coil needs 100ma to click. Then your hfe is 325 which is the amplification factor in common base mode. That is the current from your base will be 325 times smaller than the current from your collector. You told you gave 10k resistor in between them. Assuming that esp is running exactly at 3.3v and the voltage drop across the base to emitter is 0.7v we get a potential drop of 2.6v across the resistor. This led to a base current of 2.6/10000 = 0.25mA. This will result in a collector current of 0.25*325 = 81mA. Which is barely enough for the required specs.

You can either use s a transistor with higher hfe or lower the resistor down to 6.4k or 5.6k then it will work.