• Hello ES! We could use some help to get us past the finish line on building the new knowledgebase for the forum.
    Can you donate? Please see our fundraising page. Thank you!

Tip for reading signals > mcu input pin level

TRS300

Established
Joined
May 31, 2025
Messages
117
Location
Los Angles
Hi all, thougt I'd pass on a tip I've been using for some time now. It has to do with input signals to a mcu device. Let's take a VESC for example. It's based on the STM32 which uses 3.3v I/O level. Let's say you want to capture a 12v brake light signal. Typically people would use a voltage divider to ensure that the input voltage does not exceed 3.3v. But depending on the resistors used its possible to damage the MCU if the ground on the divider resistor failed.
The tip is this... The STM32 does not get damaged from high input voltage, it gets damaged by excessive input current. If you were to wire your 12v brake light signal through a 10k ohm resistor it would drive the input pin high and not damage the STM32 chip. You can do the same thing with any high voltage signal. Just size the resistor to only pass >2ma of current. If you want to still use a voltage divider use a high ohm resistor on the signal line as extra protection. Like I sad, I don't use a divider at all. I've done this on arduino, esp32s, mbed, and STM32s. No issues on any of these devices.
I currently have two VESCs sharing a common throttle signal. The signal is fed through 10k resistors in parallel to each VESC. It works perfectly and if the signal for some reason went high to a high voltage (ie 5V), it would not damage the VESC. And each VESC could not damage the other one either. A loss of signal connection would result in no signal at all. It's actually safer.
Anyway, it's a technique I don't see mentioned often for some reason.
 
Last edited:
What!? this is cool, I'll have to try it out sometime.
I've never had a problem with 10k resistor at up to 12v. Use the highest resistor you can but low enough to get the pin to respond to a high / low signal. Maybe get a cheap 3.3v board and test with it.
 
Just size the resistor to only pass >2ma
You are funny. U=R*I rules. How much voltage drop will be at which point? How is the pin configured? Pull up? Pull down? Open drain?

I would be very careful with this kind of hints. There are clear specifications in the data sheets. At a STM32 there are some pins, that are specially marked as 5V tolerant.
Screenshot_20260104-105001~2.jpg
 
Last edited:
You are funny. U=R*I rules. How much voltage drop will be at which point? How is the pin configured? Pull up? Pull down? Open drain?

I would be very careful with this kind of hints...
You are right on 2 points. Absolutely yes you need to be very careful with what you are doing. And yes, I do think I'm funny actually, but not really with posting this tip. :)

Look. The point is that excessive current is really what you need to watch out for. I could set up a voltage divider using low ohm resistors and toast the MCU if the divider ground is interrupted. There are risks related to all circuits.

I can tell you for certain that 10k resistor at 12v provides protection. In past tests on a Esp32 with a standard I/O set up as digital input, 12v signal fed through a 10k resistor resulted in a high signal trigger, ~6v on the pin, and no damage. And the reason for that is because the current is so low. I would say that a 20k resistor probably would work on this curcuit as well.

If the signal voltage is higher I would for sure use a much higher resistor. And as a disclaimer I will say that this tip I posted truly has only been verified with signals up to 14v using a 10k resistor.

At 14v with a 10k resistor you get 1.4ma of current. 19.4mw of power not enough current to fry the I/O pin if that pin is set up as digital, regardless of it being a pullup, pull down, or floating.

It's just a tip. And like any circuit, it needs to be implemented properly.
 
Last edited:
If you want to use IO to detect a higher voltage, using a diode would be a good method.

High voltage will not burn out IO through diodes, while low voltage can be detected by IO.

However, in motor controllers, transistors are commonly used. This is safer1769062818730.png
 
I think my original post was to try and do the job in the most simple way as possible. There are many good ways to do this...
I will say however that using a single high ohm resistor as a digital signal capture circuit I know is safe for signals ~ 15v or less. I think if I were to try and capture a signal from a higher voltage I'd probably add more to the circuit.
 
Last edited:
Back
Top