Hi,

I'm trying to get readings on the voltage of my battery. Since the voltage of the battery exceeds 3.3V, I'm using a voltage divider with two 25 kohm resistors. See the attached picture for the schematic.
Before using the battery, I tried with a benchtop power supply so I can play with the voltage. I plugged the output voltage to the analog pin A16 (pin number 35) on my teensy 3.6 but when I use the analogRead() function, I keep getting random values. I then tried to put a 0.1 uF capacitor in between the + and GND but that did not resolve the problem.

Here is the simple code I used. And I keep getting random values. Can someone help me?

Thank you!
Roman

PS: I tested the voltage output with a multimeter and I had a very stable voltage of 3V after the divider, which should give me readings near 1000.

Click image for larger version. 

Name:	volt_div_analog_read.jpg 
Views:	10 
Size:	20.6 KB 
ID:	21888

Code:
void setup()
{
Serial.begin(9600);
}

int val;

void loop()
{
val = analogRead(A16);
//val = analogRead(35);
Serial.print("analog is: ");
Serial.println(val);
delay(250);
}