Transitor array - ULN2804A

Hi everyone,

I want to connect multiple devices/sensors to an arduino mega. Device such as various displays, bluetooth/radio modules, basically any device that draws more than 20 mA.

Since I will not use all of them at the same time, I thought it would be a good idea not to connect them directly to the 5v output, but instead to a GPIO pin. That way, if I need a device/sensor, I could simply put the specific GPIO HIGH, providing therefore current to the device/sensor.

I quickly came to realize that some of the devices/sensors, in particular displays, might draw to much current for one GPIO pin, which might damage the arduino mega. I then thought about using transitors. After some research a discovered transistor array, and in particular the ULN2804A.
https://www.ti.com/lit/ds/symlink/uln2803a.pdf?ts=1612681900913&ref_url=https%3A%2F%2Fwww.google.com%2F

My idea now is the connect arduino pins to the ULN2804A "inputs" , provide 5v high current (external source) to the ULN2804A and connect the devices/sensors VCC to the ULN2804A "outputs".

For example: I connect pin 3 of the arduino to pin 1 (in 1) of the ULN2804A, and the display VCC pin to pin 18 (out1) of the ULN2804A. An external 5v high current source will be connected to pin 10 (COM).
That way, when I need to use the display for a project, I can simply set pin3 of the arduino to HIGH in order to power the display.

It seems to easy, am I missing something ?
I don't have a clear picture of what the project will end up looking like, I just want to be able to switch on/off device I might need for a specific task, device that can't be directly connected to a GPIO because it migh draw to much current.

Thanks for you inputs on this.

You need the ULN2803, not the ULN2804, if you are operating from 3.3V or 5V logic.

The ULN2804 needs 6V or more to work, and as far as I know is completely obsolete anyway.

These are darlington drivers, so will drop 1V or more when on, which is not very good for
switching a logic load or sensor.

A small logic-level MOSFET would be a better choice, as these have an on-resistance, not
an on voltage-drop. Single switching BJTs like 2N2222 are also much better, some have
on-resistances as low as 50 to 100mV.

Switching low-side has some issues you might want to consider, like the breaking of the ground
into different regions. Often its more viable to switch loads high-side with p-channel logic-level
FETs or PNP switching transistors.

It seems to easy, am I missing something ?

You are missing 3 things:

That device switches ground, not positive, so if you did use it (don't) it would switch 0V not +5V

If you switch the power to devices you have to be very careful about phantom powering, which means the device getting power from some where it's not supposed to. Take the +5V away but leave an input pin high and the device will probably be powered from the input pin through the protection diodes.

An external 5v high current source will be connected to pin 10 (COM).

That's not how it works. Pin 10 (com) is for the protection diodes, which are needed when switching inductive loads, see https://forum.arduino.cc/index.php?topic=705982.0

Thanks for your input, it wasn't that easy after all ^^

It is better to use an 2N2222 for each device right ? That's what I wanted to avoid, since the wiring is more "intense".
Is there are any IC that does what I described but doesn't have the brawbacks of a darlignton driver ? (like a 2N2222 array or something)

Not the latest in surface mount technology or anything, but relays make for effective, practical solutions.
This particular reed relay has a suppression diode built in and its coil is 500Ω, no 'transistor driver' required. It can switch loads up to 500mA.
(Relay contacts, switches, are "lossless".)

Shift registers like TPIC6B595 can Sink current (connect to Gnd) 150mA per output, are a great way to turn on higher power devices like LEDs.
Other parts are also options - TPIC6D595 (100mA), TPIC6A595 (250mA), TPIC6595 (350mA).
If you need to Source current (connect to a High voltage) than MIC5891 shift register might do the trick.
It has a darlington like open emitter output, so voltage drop across the output can be up to 2V at higher currents.

@runaway_pancake
What is the advantage of your solution compared to a 2N2222 ? It seems to me that is does the same but with more pins and it looks like it is bigger.

@CrossRoads
I never really look into shift registers so my knowledge is limited.But it is a great learning experience^^
By shifting from the firts device to the second, does the first one gets turn off or can I specify that I want the first one the stay on ?
If so your solution looks very promising since no device will draw more than 80-100mA.

@rediron --
They're about an inch long.
Two pins are the switch contacts (one goes to 5V, the other to your device/s), two are the coil (one goes to an 'output pin', the other goes to GND), not complicated.
How do you propose to use a 2N2222? As a high-side driver emitter follower or switching ground? Given the ULN28xx's unsuitability, the latter is out. The former results an "output" less than 5V.

Another alternative in such a situation where a device has to be switched on and off by an Arduino pin, but that device exceeds the power capacity of that pin, is to use a load switch.

Here are examples:
https://www.mouser.ch/datasheet/2/308/FDC6330L-D-1806746.pdf

These allow you to switch higher voltages than the pin voltage which can be useful if you are using say a 3.3 volt MCU pin to switch on a 5v peripheral.

Some peripheral devices (e.g. boost converters) have their own shutdown or enable pin which can be used instead.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.