Hi. I am trying to built a relay module using MMBT5551 transistor to switch relay on and off from ESP8266 or any arduino board. Schematics I am following, is attached.
My problem is that it is not switching relay on and off. I have measured the voltage across collector pin of MMBT5551 and 5VDC, it shows 4.75 and 4.35 volts when I switch IO pin on my ESP8266 HIGH or LOW. However, on connecting relay to +5V and GND directly, it works (Means relay is working).
When I try relay module (purchased ready made), Relay is switched ON and OFF. Most of the relay modules use BC847 transistors. Is it the transistor problem?
Don’t think so, looks like your resistor values are too high.
For values without any measurements try -
The 47k going to the base of the transistor, should be something more like 2k2 to 4k7.
Same with the LED resistor, at 10k it will never light, 330 to 470 ohms more suitable.
I would lower the base resistor to 470ohm (~5mA with 3.3volt pin drive).
That will give you a base/collector current ratio of ~1:15, assuming a ~75mA (sugarcube) relay current draw.
That should be enough to saturate that MMBT5551 transistor.
A 10k LED CL resistor is indeed a bit high, but 330-470ohm could be too bright for an indicator LED.
1k should be ok for a small indicator LED, even on a 3.3volt port (~1.3mA).
Not sure what max output pin current of a ESP8266 is. Above values total to 5+1.2= 6.2mA.
The 10k resistor from pin to ground is not needed.
base resistor should be 220 or so, not 47000 ohms. You need to switch the transistor on, not tickle it with a
To switch most BJT's on requires the base current to be 5 to 10% of the collector current, you are being
confused by the gain parameter, hFE, which is nothing to do with using a transistor as a switch (its for
when amplifying an analog signal in the active region.
For switching the transistor is either in cutoff or saturation. In saturation the collector-base junction is
forward biased and normal transistor action cannot occur, so the hFE parameter is not applicable.
I think 5-10% is a bit harsh for a little critter like this. 5% is more for big power transistors.
The datasheet for this transistor has a 1:10 graph.
10-20% should not make a significant difference in saturation voltage, and it's easier on the ESP8266.
As said in post#2, 470ohm (5mA) should be ok for most small 5volt relays (~75mA).