In the past, I've been able to drive a relay using a 2n2222a via a GPIO pin given the same schematic with PCF removed. However, once I introduce the PCF8574, it doesn't work.

I have read that I should probably change the schematic to use sink instead of source, or a different transistor, or a different I/O expander - but I'm a noob and don't really know how to construct or modify my circuit accordingly i.e. what that specifically changes my circuit.

Do I add a PNP somewhere, or switch to a TIP120 - what's the easiest thing for me to do with the least modifications to this circuit?

I kind of get what is going on, but because I'm not an EE I don't totally understand the theory behind it. I have read every post on SO, and I think the transistor of choice doesn't get fully saturated by the PCF because it cannot source more than say 30 mA so it's not opening fully. I've read about pull-up 1k to 5 V on the outputs of the PCF, but that didn't seem to do anything. I do know the second I ground the collector it activates the relay, so I'm pretty sure the PNP is not fully opening. When I connect an LED, I did notice it was dim and less dim depending on the signal coming from the PCF.

Here is the Songle relay's datasheet.

Here is my current schematic (apologies for the poor layout, first time using Schematic Editor):

EDIT: Forgot VCC/GND connections on PCF.

EDIT 2: Added all other connection and components.

EDIT 3: :facepalm: 1k resistor label..

enter image description here

  • \$\begingroup\$ What’s the current drive capability of said I/O expander? If limited, why not an N-MOSFET? Also, EE top tip: draw your positive supplies pointing upwards, GND and negative ones pointing downwards. \$\endgroup\$
    – winny
    Jul 4, 2022 at 20:20
  • \$\begingroup\$ @winny Thank you for the tip! I appreciate it. I'm not sure of the exact number you are referring to, but the datasheet is here: ti.com/lit/ds/symlink/pcf8574.pdf I am guessing it's 20mA? \$\endgroup\$ Jul 4, 2022 at 20:23
  • 1
    \$\begingroup\$ I guess you have bypass capacitors on the regulator too, but omitted from diagram? The PCF8574 can source out only 1mA but sink in 25mA. \$\endgroup\$
    – Justme
    Jul 4, 2022 at 20:23
  • \$\begingroup\$ Mmm I'm not sure. I do have a 10uf cap between +3.3v of the LM1117 output and GND of the USB \$\endgroup\$ Jul 4, 2022 at 20:26
  • 1
    \$\begingroup\$ Make your schematics with all components and connections. Otherwise we keep having a repeated cycle of "it won't work because X missing" and "oh X is there just did not draw it". \$\endgroup\$
    – Justme
    Jul 4, 2022 at 20:29

1 Answer 1


1kohm at the transistor base is way too high with PCF8574, due to the weak output high drive ability it has (marketing term is quasi-bidirectional IO, which allows a data pin to be an input and an output without a separate data direction register).

It might not work even with a 0 ohm resistor there.

Relay needs 160-180mA, therefore to drive the transistor fully on, the base approximately as a rule of thumb needs in the order of one twentieth to one tenth of that, about 8-18mA.

The PCF can output less than 1 mA, so it can't drive the transistor base with high enough current.

Try a 270 ohm to 470 ohm base resistor to 5V and have the PCF output directly to base. Alternatively switch the BJT to a logic level MOSFET, or use an IO expander with normal outputs, or change to a high side PNP transistor as the output can sink in 20mA current when driving a pin low.

  • \$\begingroup\$ I changed the 1k to a 470 to 5v, and the output pin direct to base. No change. Still reads .650 or so at the base when high, and 0v when low. I'll try to see if I have a logic level MOSTFET in my array of goodies. \$\endgroup\$ Jul 4, 2022 at 22:19
  • \$\begingroup\$ Doesn't look like I have any mosfets in my collection. Do you have a recommendation as to which ones I should grab? \$\endgroup\$ Jul 4, 2022 at 22:26
  • \$\begingroup\$ Alternatively, I do seem to have some PNP's around (not sure which are suitable for this). How would the connections change if I move to a high-side PNP? \$\endgroup\$ Jul 4, 2022 at 22:39
  • \$\begingroup\$ @CircuitNoob Order some? Break open any non functioning electronic device and harvest some MOSFETs? \$\endgroup\$
    – winny
    Jul 4, 2022 at 22:43
  • \$\begingroup\$ Yeah I'm just going through mouser right now, I've never ordered them before so not sure what #'s will work with this circuit I'm building. \$\endgroup\$ Jul 4, 2022 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.