Just a little background info, I'm designing a small standalone battery powered unit to be developed that will allow the output of a sensor to be displayed on an LCD screen and that the input to the unit will have a 0-5V range from the sensors.

My question is how could I protect the analogue input pins of my microcontroller from high/negative voltages while also being able to display values from sensors that do not have this output range?

EDIT: I am designing this device for others to use and will not know what kind of sensor they would be using, all I'm told is to expect a range of 0-5V and include protection from anything else.

  • \$\begingroup\$ What you need is an "input voltage clamp circuit", use Google with that and look at the images tab. Also see: electronics.stackexchange.com/questions/229589/… \$\endgroup\$ Mar 29, 2019 at 10:11
  • 2
    \$\begingroup\$ High? How high? How negative? What is the maximum input current value stated in the data sheet? \$\endgroup\$
    – Andy aka
    Mar 29, 2019 at 10:23
  • 2
    \$\begingroup\$ "anything else" is a crummy specification. 230VAC mains? 100kV distribution power? There's going to be a big difference between a protection circuit that works reliably up to 12VDC and one that can withstand even a momentary mains connection and still maintains whatever impedance (hint, you've not stated it) maximum your analog pins require. Also accuracy needs to be considered. \$\endgroup\$ Mar 29, 2019 at 12:44

1 Answer 1


Use clamping diodes to limit the input signal voltage. You can either connect external clamping diodes from input to the +5V line and ground, or use internal clamping diodes that are already built into your microcontroller. Make sure to use Schottky diodes, not regular ones.

How does it work: when Vin is higher than Val+, the top limit diode starts conducting, clamping the Vin to Val+ + 0.3V. When Vin is lower than Val-, the lower diode clamps. Current flowing through the diode is limited by the input resistor. 0.3V is the forward drop voltage of Schottky diode.

enter image description here

If you decide to use internal diodes, make sure the current through them would not exceed 1mA. This is achieved by increasing the input resistor to about 10㏀, which could degrade you ADC performance, so it would be a good idea to use external clamping diodes that could handle 200mA, and lower resistor value (200Ω to 1㏀).

  • \$\begingroup\$ Thanks for the answer! To clarify, what is meant by Val+ and Val- in your diagram and what are they connected to. \$\endgroup\$ Mar 29, 2019 at 11:11
  • \$\begingroup\$ @House_Byrne these are the maximum and minimum voltage limits for you input pin. In most cases they would be connected to power rail (+5V) and ground, respectively. \$\endgroup\$ Mar 29, 2019 at 11:13
  • \$\begingroup\$ @House_Byrne please also read the link I provided in the answer, it gives more detailed explanation on clamping circuit scienceprog.com/using-current-limiting-resistors-on-avr-io-pins \$\endgroup\$ Mar 29, 2019 at 11:19
  • \$\begingroup\$ I see now, thank you very informative. How would I power the clamping diodes if I were to use it externally? \$\endgroup\$ Mar 29, 2019 at 11:56
  • \$\begingroup\$ For external protection where you don't have a power line available, you have to use Zener/TVS diodes of appropriate breakdown voltage. For example, SA5.0A is a TVS diode rated to hold 5.0V and breakdown somewhere between 6.40 and 7.00V. \$\endgroup\$ Mar 29, 2019 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.