but I'm actually getting 1.8V and if i remove the protection diode (D17), the same as the 2.7V
I'm getting.
So what's the reason behind it? Also, if i want to protect my stm32g0b1cet6 GPIO pin, how can I protect it, and also how can I purify the noisy signal that is fed at R64 and receive it at stm32 pin PB2?
The problem is the 100K resistor is too big. A zener will always draw some current even below the zener voltage, so you are getting an additional voltage drop across that resistor.
Try a 10K and 3K as the voltage divider or get rid of the zener and use a schottky diode connected to 3.3V.
The diode is probably not needed, as in the case of overvoltage, the 100K resistor should limit the current through the input protection diode to a safe value.
Due to the input capacitor, you cannot measure rapid changes in voltage.
You might also look at the equivalent circuit for the analog input in the datasheet for the mcu. Make sure the 100K source resistance is not too large.
I had a similar problem with a Schottey diode in a "similar" application with higher resistance (maybe 1M). I'm pretty sure a Zener would have been worse, but I had to switch to regular silicon diodes. It took me awhile to diagnose the problem. I didn't know that Schottkys had worse reverse leakage than regular silicon diodes.
If you want to protect against negative voltages AND over-voltage like the Zener this page shows you how to connect a pair of Schottky or regular diodes.
What is the max voltage you're measuring. If you calculate your voltage divider to dial down to 1.2volt, and switch to 1.2volt Aref in setup(), then you have a result that is less dependent of VCC voltage variations and three times higher protection (before it reaches 3.3volt). Then you might not need a zener.
If you insist on using a zener, then use it on the high voltage input side.
1k > 50volt zener > R64.
Leo..
What is the source of the voltage? If its a high impedance your circuit will load it and change the voltage you measure. You cant always just use a potential divider network; High resistances will affect the response time, and low resisytances will reduce the measured voltage.
@johnerrington My application is to measure the 14v max with 100k and 30k. I added zener for protecting my mcu pin in case of high voltage spikes and 0.1 µF for the ripple filter so thats all If its bad approach, then lets discuss which is good approach.
What is tyhe "14V" coming from? If its showing the state of charge of eg a car battery (lead-acid) then the voltage for a good battery will vary between 15V (on charge) and 11V (totally flat and [possibly damaged).
However the source impedance will be low so the potential divider wont affect your readings.