Protecting Arduino in car?

I appreciate there are a few topics on this already, but I want to ask a few added things within the context of my project. I have a setup where I want an Arduino (actually Attiny85 chip) to blink an LED when it detects an ignition live. I can do this in a few ways, either by wiring the ignition live to a digital pin and detecting a voltage through a digital read, or by doing an analogue read and setting the threshold sufficiently low enough e.g. 10. Both ways work perfectly for my application, but the question is how is it best to protect the Arduino against voltage spikes within the car?

  1. With protection in mind is it simpler to wire things up to the analogue pins or digital pins (both ways work equally well for my application)? I read that if wiring things up via the analogue pins there is more tolerance to damage - but not sure if this is true?

  2. Should I go for just a simple voltage divider? If so what resister values would people recommend?

All I/O pins of the ATtiny are digital pins, four of them have additional with analog input ability. There's no difference in robustness of these pins for that matter.

Best protection of inputs is achieved by optoisolating them.

Try reading this first: https://m.littelfuse.com/~/media/electronics_technical/application_notes/varistors/littelfuse_suppression_of_transients_in_an_automotive_environment_application_note.pdf
You can simply take a 5 Volt zener, a LED and a resistor connect them in series and connect between ignition and ground. You can purchase leds that blink without anything external. The zener is optional if you want a pseudo threshold voltage for the led to light. As mentioned opto isolation works but where do you get an opto isolator that is analog and the power on the other side. Resistors work great as do diodes to VCC and Ground. These are built into the micro so if you keep your resistance high enough no other protection is required. A resistor divider would work great, just add a series resistor to the analog pin. 10K will protect you from about everything you will see from the output of the voltage divider. You can simply use a voltage divider that will give about 2.5 volts when you reach the minimum voltage for the ignition to be on and connect to a digital pin. Keep the resistance that the pin will see around 20K. Renenber you have to protect the Arduino power as well.
Good Luck & Have Fun!
Gil

gilshultz:
A resistor divider would work great, just add a series resistor to the analog pin. 10K will protect you from about everything you will see from the output of the voltage divider. You can simply use a voltage divider that will give about 2.5 volts when you reach the minimum voltage for the ignition to be on and connect to a digital pin. Keep the resistance that the pin will see around 20K. Renenber you have to protect the Arduino power as well.
Good Luck & Have Fun!
Gil

Thanks for your reply. I think a simple voltage divider may be the way to go. What sizes of resistors would you use for the divider? I heard voltage spikes in a car can go as high as 80V! I am really not bothered about the precise reading of voltage, as long as the arduino detects a voltage that is good enough for me.

As for protecting the Arduino power, I won't power the Attiny85 from the car. I will simply use a small cr032 coin cell battery. As I say, all I want to do is use the Attiny85 to detect a voltage (the precise voltage reading does not even matter). Also I am not bothered whether I use digital or analog pins for this.

You can simply rely on the clamping diodes as well to protect the Arduino. Keep the current to <0.5 mA and no problem there.

So an 80V spike on an input, Vcc = 5V, so 75V over. Max current 0.5 mA gives a resistor of at least 15k. If that’s the the value of the top resistor of your voltage divider - which normally brings down 14V to 5V, let’s make that a 2:1 divider - you’re protected from that voltage. Higher is better of course, less current leakage.

The other concern is the input impedance of the ADC pin which is best kept under 10k. It sees the two resistors in parallel. A voltage divider of 20K + 10k would do fine here, giving an input impedance for the ADC of ~6k7 which is comfortably below the 10k recommended maximum.