Arduino 12V digital input

Thread Starter

Lucky-Luka

Joined Mar 28, 2019
181
Hi all
I want to detect a 12V signal using an Arduino Nano v3.
I've decided to use a NPN transistor to do so. Is it a valid solution?
I've tried the circuit and it looks like it works fine.
I've tried to use the 100k res at the base but I don't really know if it's the best value. How to chose it?
Thanks
 

Attachments

KeithWalker

Joined Jul 10, 2017
3,063
mmmh... I knew that solution, there is even the zener diode one but I thought that using a bjt could be a better solution... btw I would like to know how to dimension the base res...
Why do you think using a transistor is a better solution? It is adding unnecessary active components and increasing the potential risk of failure. Usually the simplest solution is the best solution!
 

ericgibbs

Joined Jan 29, 2010
18,766
hi LL,
If you reread your initial post, you say you want to detect a 12V signal, no mention of over voltage.

If you had explained the purpose of the circuit correctly, we could have given the correct response

How greater an over voltage.??

E
 

Thread Starter

Lucky-Luka

Joined Mar 28, 2019
181
I haven't mentioned because I am still not really sure if it is present. I want to connect this circuit to an alarm system for home that has a 12V output.
 

John P

Joined Oct 14, 2008
2,025
You don't need more than one resistor--the processor input pins are protected from overvoltage by diodes, so all you need to do is keep the current limited. Your transistor circuit looks OK if you want to do it that way, but that transistor is a pretty expensive one! Something like the 2N3904 would be good enough. People do often add a pull-down resistor on a transistor base, just to assure themselves that if there is some leakage current coming into the circuit, it won't turn the transistor on.

I have some R1009 "logic transistors" that I picked up cheap a long time ago. They're just a small transistor with a built-in base resistor, which saves a little fiddling around with breadboard circuits. Open-collector drivers are things we use all the time!
 

ericgibbs

Joined Jan 29, 2010
18,766
hi John.
The downside of using just one series input resistor, is the TS shows a switch in the 12V input line.
When the switch is Open the MCU Input would be floating and could assume an undetermined state.

E
 

Thread Starter

Lucky-Luka

Joined Mar 28, 2019
181
hi John.
The downside of using just one series input resistor, is the TS shows a switch in the 12V input line.
When the switch is Open the MCU Input would be floating and could assume an undetermined state.

E
Arduino has internal pullup resistors though
 

John P

Joined Oct 14, 2008
2,025
The diodes are oriented so that a voltage above the power supply or below ground will cause current to flow, and keep the voltage on the input from getting excessively high or low. But they have a very low current rating, so if you rely on using them, you've got to limit the input current.
 

KeithWalker

Joined Jul 10, 2017
3,063
The diodes are oriented so that a voltage above the power supply or below ground will cause current to flow, and keep the voltage on the input from getting excessively high or low. But they have a very low current rating, so if you rely on using them, you've got to limit the input current.
Depends on which ones you choose. 15SQ045 is rated at 15A. That's not a low current.
 

dendad

Joined Feb 20, 2016
4,451
If you are really worried about protection for the Arduino input, use an optoisolator.
That way, there is no electrical connection between the 12V and the Arduino.
Almost all the industrial control equipment we have designed use this.
 
Top