I have an STM32L452RE Nucleo 64 board with voltage divider. See schematic. The output should be 3.3 Volts, but instead it is steadily 3.25 V. Does anyone have an idea where I might be going wrong?
Page 154 of the datasheet mentions that the "Internal sample and hold capacitor" for the capacitor has a capacitance of 5 pF. Thought that might be relevant.
N.B. the rather large values for the resistors is for low power application, and the capacitor is to make up for the low current that results from this.
Code: Select all
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// Calculate the voltage of the voltage divider
Serial.print(analogRead(PC4)*(3.3/1023.0)*(4.7+2.2)/2.2);
Serial.print(" V, ");
Serial.println(analogRead(PC4));
delay(100);
}
output:
Code: Select all
17:59:10.945 -> 3.25 V, 321
17:59:11.038 -> 3.25 V, 321
17:59:11.163 -> 3.25 V, 321
17:59:11.255 -> 3.25 V, 321
17:59:11.333 -> 3.25 V, 321
17:59:11.457 -> 3.25 V, 321
17:59:11.550 -> 3.25 V, 321
17:59:11.645 -> 3.25 V, 321
17:59:11.738 -> 3.25 V, 321
17:59:11.862 -> 3.25 V, 321
17:59:11.954 -> 3.25 V, 321
17:59:12.065 -> 3.25 V, 321
17:59:12.155 -> 3.25 V, 321
17:59:12.248 -> 3.25 V, 321
17:59:12.340 -> 3.25 V, 321
17:59:12.466 -> 3.25 V, 321
17:59:12.560 -> 3.25 V, 321
17:59:12.654 -> 3.25 V, 321
17:59:12.748 -> 3.25 V, 321
17:59:12.841 -> 3.25 V, 321
17:59:12.965 -> 3.25 V, 321
17:59:13.058 -> 3.25 V, 321
17:59:13.152 -> 3.25 V, 321
17:59:13.246 -> 3.25 V, 321