Reading high voltage/current digital inputs

Hi,

I’m building an interface between my truck’s status signals and an Arduino Uno R4 Wifi.

The truck’s status signals are either 12-14V or ground and can provide up to 0.5A. For example the signal “Engine is running” is defined as [open circuit] when RPM is <450 and [12V] otherwise. The max current is 0.5A.

I’m not sure how to connect this signal to one of the Uno’s digital input pins. I read that Uno’s I/O pins are limited to 8mA and logic operates at 5V.

Can I simply connect this signal to an input pin? or should I reduce the voltage to 5V? Should I also limit the current?

Thanks for helping me out.

Only if you don't mind burning out the Uno's input pin and associated circuitry.

or should I reduce the voltage to 5V?

Input signals on an Uno should always be limited to 0-5V.

Should I also limit the current?

Your load determines how much current is required.

A simple voltage divider is one option, but as the automotive environment is a harsh one for electronics, an optoisolator would be safer. There are many other options as well.

Thanks @van_der_decken, duly noted.

What about the following signal, [open circuit] for one state and [ground] for the other, with the same max current?

An automotive electrical system is a hazardous environment for MCUs. If you want a robust solution, you should look for suitable optocouplers, etc., that meet the AEC-Q101/102 criteria.

You should be able to find the max current supported by the RA4M1 in the manual. My suggestion is to take a look at the M2 to see how they designed it to be (kinda) robust in a 12V environment. It's based on a 3.3V MCU (same one in the Arduino Due) but most of the same lessons apply and the design files are all open source.

In theory, this can be connected directly to the Arduino input pin. You would enable the Arduino's internal pull-up resistor in your code. The current that flows would be very small because the internal pull-ups are quite high resistance.

But as already mentioned, automotive environments are "unpleasant", so it might be safer to use an opto-isolator here also.

Is irrelevant in answering @myriaxis 's questions. If the signals are connected directly to the Arduino input pins (through a voltage divider if required), the Arduino input pins would be the "load" and these have a very high impedance (resistance) and so only a tiny current will flow, in the micro-amps range.. A tiny fraction of the max current these signals could provide.

If, as recommended, opto-isolators are used, the signals need to provide only a small current (a few milli-amps) to light the IR LED inside the opto-isolator.

You should never connect an open circuit to an Arduino input pin. It won't damage the pin, but it won't reliably read HIGH or LOW. It would be what is called "floating".

If the signal is ~12V or open circuit, you would need to connect a pulldown resistor from the pin to ground to prevent it floating when the signal is open circuit. Or use the Arduino's internal pulldown resistor, which most Arduino models don't have.

If the signal is ground or open circuit, you would need to connect a pullup resistor from the pin to 5V to prevent it floating when the signal is open circuit. Or use the Arduino's internal pullup resistor, which most Arduino models do have.

The exact value of pull-up and pulldown resistors isn't critical. They are usually around 5K~50K. With that kind of value, they can be easily "defeated" then the signal is 5V or ground. But if they are too low, like a few tens or hundreds of ohms, the signal may not be able to maintain the correct voltage level and the Arduino pin reading might become unstable. If they are too high, like hundreds of kilo-ohms or mega-ohms, they will leave the Arduino pin open to interference from the environment, like when the pin is floating.

Hi, @myriaxis

This may help, feel free to edit/change etc etc.

Tom.... :smiley: :+1: :coffee: :australia:

Hi @myriaxis

This is a safe way to inerface:

It will live forever.

Just a heads-up: a plain PC817 might not live very long in a real automotive environment.

On paper it works fine, but a 12 V car system is anything but “12 V”. You’ve got spikes, negative transients, load dump events… all the fun stuff. Without proper protection, the input LED in the optocoupler will eventually see conditions it really wasn’t designed for.

It may work on the bench and even for a while in the car, but long-term reliability is questionable. So unless you add proper protection (or use an automotive-rated part), don’t be surprised if it starts acting up at some point.

Just something to keep in mind.

@myriaxis
There will always be people who claim that something won’t work but provide no evidence supporting that claim and who also don’t provide an alternate solution. It’s best to just dismiss such forum posts.

Just something to keep in mind when reading posts here on the forum.

I like @anon95813201's post #10 but would make R1 2.7k (about 5mA) and put a bidirectional 24V TVS diode across PC817 pins 1 & 2.

Thank you all for your replies.

Thanks @PaulRB for the explanations. Thanks @anon95813201 and @TomGeorge for the schematics.

That’s what I was looking for.

The PC817 itself is fine, but only if you treat the car line as what it really is – a pretty nasty environment.

With a TVS for the big stuff and a small diode for the negative spikes, the input LED is no longer the weak point.

Car signal
|
[R1] 10k
|
+----|<|----+ D1 = TVS (e.g. SMBJ33A) to GND
|
|
|
[R2] 2.2k
|
+----|<|----+ D2 = 1N4148 (antiparallel protection) to GND
|
LED (>| PC817)
|
GND

  • R1 (max. 10k)
    Takes the hit from high voltage events (load dump, spikes). Limits current into the whole circuit.
  • D1 (SMBJ33A)
    Clamps bigger positive spikes to a sane level (~30–35 V).
  • R2 (approx. 2.2k)
    R1 + R2: Ends up around ~1–3 mA in normal operation, which should be enough.
  • D2 (1N4148, |<)
    Sits antiparallel to the LED and clamps negative voltage to about −0.7 V.
  • PC817 LED (>|)
    Only ever sees forward current in normal operation and is protected against reverse stress.

What should happen:

  • Normal 12–14 V → LED gets a small, controlled current → should work just fine
  • Positive spike → TVS + R1 limit the voltage/current → nothing dies
  • Negative spike → D2 conducts → LED never sees damaging reverse voltage

Remember that TVS diodes have only ONE life to give to protect your circuit. The second over voltage it will not be there.

I didn't think about reverse voltage on LED (6V max). :grimacing:

To, ( 13.8 - 1.2 ) / ( 10000 + 2200 ) = 1.0mA, not enough for the LED.

I'd try 1K for each resistor.

( 13.8 - 1.2 ) / ( 1000 + 1000 ) = 6.3mA, better figure.

Tom.... :smiley: :+1: :coffee: :australia:

I guarantee my that my circuits will work as is for your interfaces, no shoulds, coulds, or maybes.
Also, human made actual schematics not unreadable AI generated ASCII stuff.

I hear you. Thanks for your input. PC817 ordered.