I want to switch several (10-20) relays with a raspberry pi. I will use darlington arrays like the ULN2003 to drive the relays, and a shift register to not use up all of my GPIO pins.

I will use an external 5V power source just to be extra safe, in case I switch all the relays at once.

Since the raspberry uses 3.3V TTL logic, while my relays require 5V, I was looking for a shift register that converts the 3.3V to 5V. I found the 74HCT595, which works off of 5V and is TTL compatible and can be cascaded. However, it seems noone sells it in a DIP package, and the stores I looked at have none in stock and need months to restock (mouser europe). Also, I'd really prefer a large package.

The 74HC595 (same data sheet, no "T") barely meets the requirements for the 3.3V input, and is available as PDIP. Would that be an alternative, or will I get erratic behaviour?

Another alternative I found is the SN74AHCT595N, which seems viable as well, however I am unsure if I can cascade it. I want to avoid buying the wrong part (again ;-/ ) and since I barely find any information on this part, I need some help ( all searches turn up the information on the parts without "A").

The datasheet mentions cascading, but it is not completely clear to me which pins I should use? Can I just connect QH' to SER of the subsequent register? (for the other registers there was always some pin called SEROUT or somesuch. Also, can I both source and sink current using this register, or are there some limitations? And where would I find this information in the datasheet, I don't see it.

Or should I use another shift register altogether? I'd be happy for any pointers, thanks.

edit: I checked the datasheet of the mentioned TPIC6x595 (where "X" is "B" or "C") and they seem nice, however now I have more questions. Both mention relay applications. The relays are dual coil latching KMET EA2-5TNJ and have an operating power of 140mW at 5V. The "B" outputs 140mA continous current, so I am covered, but will I still need darlington arrays to take care of the back-action during switching, or can I leave them out?

However, the initial idea was to use the raspberry 3.3V logic. If I tie the relays to an external 5V and use the "B" driven by 3.3V logic to sink current, then I can switch to 0V just fine, and both coils of the relay will turn on when I want them to (The set voltage of the relays is 3.75V for both coils). While this may work, it doesn't seem proper, since I can never turn the coils off properly. Outputting high on the shift register gives me 3.3V, which means the coils are not active (5V-3.3V = 1.7V < 3.75V), however they aren't completely off either.

So in summary:

  • Do I need a darlington array with the TPIC6B595?
  • Should I just use a level shifter and be done with it, or can I make do without?
  • In case I need a level shifter, which one would be a normal one to use? Would a SN74AHCT245N be okay?
  • 1
    \$\begingroup\$ I think there are ones that come with embedded transistor arrays do drive LED or other heavier loads (than what a logic device can). You tie the relays to 5V and the IC has open drain outputs. \$\endgroup\$
    – Wesley Lee
    Commented Feb 20, 2018 at 17:56
  • \$\begingroup\$ See TPIC6x595. \$\endgroup\$
    – CL.
    Commented Feb 20, 2018 at 17:57
  • \$\begingroup\$ @WesleyLee thanks. I updated the question to understand if this will this work with 3.3V logic input. \$\endgroup\$
    – Bernhard
    Commented Feb 21, 2018 at 10:36

3 Answers 3


I will use darlington arrays like the ULN2003 to drive the relays

The ULN2003 requires an input voltage of 3 volts maximum to guarantee a collector current of 300 mA. See section 6.6 of the Texas Instruments data sheet for this part. This means there is no need to have a level shifter because a 3.3 volt compatible shift register will be able to adequately drive the ULN2003.

I'd be happy for any pointers

However, using the ULN2003 might mean you don't get enough voltage across the relay. The ULN2003 has a collector saturation voltage of up to 2 volts and this eats away at the 5 volts you thought you might be able to drive the relays with. Look at figure 1 in the data sheet.

So, either use a MOSFET package or a greater supply voltage (maybe 6.5 volts) or choose a relay that will work down to about 3.5 volts.

A possible option is to use the TPIC6B595N - it is a shift register with N channel MOSFET drivers built in. However, it needs 5 volt logic signals on data in and clock but you should be able to find a level shifter circuit from 3.3 volts to 5 volts for data and clock fairly easily.

  • \$\begingroup\$ Thanks. Can this be done without level shifter? And do I need the darlingtons when using the TPIC6B595? \$\endgroup\$
    – Bernhard
    Commented Feb 21, 2018 at 10:38
  • \$\begingroup\$ @Bernhard read the data sheets and look at the output characteristics of the MOSFETs in the chip - with a 100 mA load they drop typically 0.85 volts i.e. much less than a ULN2003. They also have built in 50 volt clamps for back-emf protection. Additionally I believe your relay coils only take about 30 mA so this should be easily met. You cannot avoid level shifting clock and data. \$\endgroup\$
    – Andy aka
    Commented Feb 21, 2018 at 10:46
  • \$\begingroup\$ Thanks again. Could you please teach a man to fish and tell me which Figure you are referring to when you talk about the 0.85V drop? (In the data sheet you linked above). It's all Chinese to me, and the only figure that seems relevant to me is Figure 3, which shows resistance versus drain current, but that alone does not get me the voltage drop. Also, for the level shifting would something like the SN74AHCT245N be fine? \$\endgroup\$
    – Bernhard
    Commented Feb 21, 2018 at 11:44
  • \$\begingroup\$ @Bernhard section 6.5 has a table - 2nd row of parameters. Figure 3 is good - it tells you that at 25C the on resistance is about 4 ohms so at a relay current of 30 mA, the transistor will only "lose" 120 mV and this is good. For the level shifter I'd use two of these: ti.com/product/SN74LV1T04 \$\endgroup\$
    – Andy aka
    Commented Feb 21, 2018 at 11:55
  • \$\begingroup\$ You could also use this: i.sstatic.net/skslh.jpg \$\endgroup\$
    – Andy aka
    Commented Feb 21, 2018 at 11:57

If you can use an SPI port or generate SPI in software by manipulating GPIO ('bit banging') then you could use the ONSemi NCV7608.

The NCV7608 load voltage (VS) range is 5.5 V to 28 V, so this device is only viable if your relay supply rail can be in that range, though.

The NCV7608 gives you 8 configurable 350 mA drivers, each of which can be a low-side or high-side driver. You can use low-side drivers with an external clamp diode across each of your relays. Driver 'on' resistance is 1.2 ohms, giving a low driver power dissipation than the Darlington ULN2003A.

The device has a logic supply and a load power supply. The logic supply range is 3.15 V to 5.25 V, so it'll interface directly to your 3.3 V logic.

It also has over-current protection and some error-detection functions thrown in that you can access over the SPI interface.

enter image description here


You can simply use a TPIC6B595. The datasheet says the recommended operating voltage is 5V, but the app note says it works fine down to 3V with a 25MHz clock.

The TPIC6B595 is designed for driving inductive loads and relays can be connected directly.


Your Answer

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

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