I see that a number of the digital pins are 5V tolerant when configured as inputs. Are these same pins capable of sinking 5V when configured as an output? What current can they handle?
I need to drive an external module which uses a PNP transistor (S8550) running at 5V, via D3. Is that possible?
@mcoms, the â5V tolerant pinsâ can only tolerate 5V as inputs. In output mode, they provide 3.3V with a safe current sink capability of 20ma. The transistor should work fine using a current limiting resistor from D3 to the base.
Iâm not completely sure what you actually intend to do.
Even if the outputs would be (-)5V tolerant in LOW state, you would not be able to completely âshut offâ the transistor, since the max. out voltage when in HIGH state is 3.3V which leaves you with (-)1.7V âappliedâ to the base.
Can you show us your wiring plan, and some summary?
Pin headers for 5V, Gnd, and âInâ (which must actually be pulled to ground to trigger the relay)
A diode of some kind
Thereâs about 1k between the transistor Base and the the âInâ pin header (matches a 102 resistor). Vcc to Emitter is a short, Gnd to Collector ~73ohms (matches coil resistance).
3.3V does seem to be enough to hold the transistor âclosedâ, although it bounces initially. Pulling the âInâ pin low through D3, would trigger the module, but would sink (measured) 4.1mA at -5V.
I guess weâre saying these pins are -5V tolerant at that sort of current level?
Having actually tried it though, the bounce I get when applying 3.3V high doesnât fill me with confidence, so Iâll probably âdo it properlyâ with a NPN transistor
Sounds like you have done a great investigation and have a good plan there! Just one other thoughtâI always like to use an optoisolator in situations like this. Then the core is only driving an LED and the relay board can have any power supply. Just something to consider!
Cheers⌠NPN transistor worked a treat for this module, but for the final board (which will have its own relay circuit) Iâll go with @bkoâs suggestion of using an optoisolator â Iâm switching central heating, and thermostats use mains in the UK
I am using this same relay board. I got three out of four channels to work by driving the relayâs VCC from the Spark Coreâs 3.3 V output. Then the digital logic becomes inverted (i.e. you drive a High from the D output of the Spark to cause the relay to turn âoffâ and a Low to turn âonâ).
I assume that 3.3 V is marginal for the relay board and perhaps thatâs why the remaining channel does not work with this configuration.
could you hum a few bars of how to âdo it properlyâ with a NPN transistor. Iâm driving a couple of very similar relays and am having a similar issue.
I am driving a 5v standalone relay with a PNP transistor (E-VCC, B-10k resistor, C-Relay) on a low-active ESP8266 GPIO. Due to the VCC difference between ESP8266 (3.3v) and the relay VCC of 5v, the relay initially was able to close but wonât release when GPIO output turns high. I guess this is because the VCC difference from the emitter to the GPIO pin is enough to sustain the current once the relay is on. I plan to added a voltage drop with a LED between the base and the GPIO pin in order to absorb the VCC difference and completely shut off the transistor. Any suggestions?
I would measure the voltage potential you mentioned between the PNP emitter and GPIO pin used on the ESP8266. When the pin goes high, is that measure potential greater or equal to the drop out voltage of your particular relay coil?
Thanks for replying! The voltage drop from the emitter to the GPIO out is exactly 5-3.3=1.7v. Based on the Hfe (~350) of the transistor and steady state current of the relay (~60ma), 1.7v is not enough to kick on the relay but somehow it is enough to sustain it if it already on. Interesting, ehh? I think by adding a LED between the base and GPIO Iâd be able to absorb much the 1.7v while preserving the low-active operation of the circuit.
Putting a load in series like youâre describing will definitely drop the supply voltage to the emitter.
Datasheets for relays often list the pull-in and drop-out voltage. Iâd wager to say that the relay youâre using wonât drop out at or above 1.7 volts based on your findings. You could always use a different relay - one with drop-out voltage of 2.0 volts or higher.
The typical way to design a âhigh-side switchâ (you should google that) is to have an NPN transistor driven by the Photon that controls the PNP transistor with the relay as a load, and importantly a voltage divider that pulls-up to the +V supply of the PNP on its base.
Basically the NPN lets you isolate the base voltage requirement of the PNP and eliminate problems.
Thank you all for your comments! Adding an LED between the base and resistor from the GPIO did solve the problem. I had to use PNP transistors because I run out of NPNs
Designing a relay driver with GPIOs from ESP8266 is challenging from another perspective. In my design I had to use 8 GPIOs (4 inputs, 4 outputs) so GPIO2 and GPIO15 had to be used as outputs. However these two pins have to be pulled H and L, respectively on power up in order for ESP8266 to boot from SPI flash. You can imaging there is a problem with either NPN or PNP relay driver especially considering the 5v driver and 3.3v logic.
For example, a problem I face is that GPIO 15 has to be pulled L on booting, but voltage divider between the pull down resistor on GPIO15 and the base resistor to PNP prevents the ESP8266 from both starting up and triggering the relay after booting. Any suggestions?