Are the 5V tolerant digital pins capable of sinking 5V as an output?


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

1 Like

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?

Edit: peekay123 beat me again :wink:

Thanks guys!

I’m controlling a cheap relay module, intended to run at 5V. It’s hard to trace out the board, but it contains…

  • A S8550 transistor (marked 2TY)
  • Three 1K resistors (marked 102)
  • A red and a green LED (red is power on, green is coil active)
  • A 5V relay (SRD-05VDC-SL-C)
  • 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 :smiley:

Good decision :+1: that’s what I’d have suggested next :wink:

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!

Good luck!

1 Like

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 :slight_smile:


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.

@steve Take a look at the Particle Relay Shield Schematic :wink:

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 :wink:

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?