ESP32 to ULN2004A

thatzmatt
Posts: 1
Joined: Sat Nov 01, 2025 6:35 pm

ESP32 to ULN2004A

Postby thatzmatt » Sat Nov 01, 2025 7:03 pm

Ok so I have this project I'm working on to add a little bit of smarts to a RV HVAC unit. The dumb thermostat simply provides -12V to each output for heat/cool and a 3 speed fan. The relay board in the air handler is as simple as it gets, just some relays with fuses driven by the thermostat through a ULN2004A. No other components at all. I have two concerns (and this my first real go at designing a circuit, so go easy on me! XD)..

First, will I be able to drive this chip directly from the ESP32 GPIO? The datasheet suggests I should, even though it says it's designed for 6-15V the VI test voltage was 5V.. Can I get away with feeding it 3.3V or do I need to level shift?

Second, while pinning out which wires do what, I was reading +12V (backfeed) from the inactive outputs. It's definitely coming from the chip as it went away whem I disconnected the relay boatd and just probed the thermostat. Does that mean I need to isolate the ULN inputs from the ESP with optocouplers or will pulldown resistors on the GPIO be sufficient to sink that and prevent damage (and if so, is 10k good enough or do I need to go higher?).

Third, as I said the datasheet suggests the ULN2004 needs a high input, but the current thermostat is using low triggers. What am I missing here?

Thanks for any help!

Sprite
Espressif staff
Espressif staff
Posts: 10617
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP32 to ULN2004A

Postby Sprite » Mon Nov 03, 2025 2:41 am

I think you technically need an ULN2003A rather than an ULN2004A. The -2004 has a base resistor that is higher, meaning you may not be able to shift the current you need with a 3.3V input. It's kind-of hard to say if it would work anyway, you may be able to get away with it if your relays don't use too much current, but I'd switch to a -2003 just to be safe.

The ULN outputs effectively pull down the lines it's connected to, so you'd expect a high voltage on a non-active output. The way the ULN chips works are such that (as long as you don't exceed the max Vcc (which is 50V according to the datasheet) and connect the ground properly, the input of the chip will never 'see' the voltage connected to the output and you don't need optocouplers or anything alike. (Technically, the B-E junctions of the darlington BJTs will make sure the base can never be more than 1.4V, meaning it's safe for anything that runs on more than that voltage.)

The ULN kind-of inverts its output compared to the input (grounds the output when the input is high) but from your text I cannot quite determine if this is an issue or not. I wouldn't worry too much about this, though: worst case you can always invert the logic in software.

Who is online

Users browsing this forum: Qwantbot, trendictionbot and 3 guests