I am trying to read an analog voltage on my Seeeduino Film - using the exact same circuit on my ArduinoUno works exactly as expected and I receive a value of ~335 (expected value when measuring 3.3v), but when I wire it up to my Film I get a constant result of 1023 in return.
I am using 2 10k resistors in a standard potential divider circuit.
Please see my code below:
int val;
void setup()
{
pinMode(1, INPUT);
Serial.begin(9600);
}
void loop()
{
val = analogRead(1); // read the input pin
Serial.println(val);
Serial.println(val);
delay(1000);
}
My code is as simple as it can get, and I am using the exact same code on both.
It is definitely wired up to Analog pin 1 - all other pins return floating value as would be expected when not tied to anything.
I am using 2 10k resistors in a standard potential divider circuit.
What value voltage is wired to the top resistor? Is the bottom resistor wired to arduino ground pin as well as the negative terminal of the external voltage being measured?
I am using 2 10k resistors in a standard potential divider circuit.
What value voltage is wired to the top resistor? Is the bottom resistor wired to arduino ground pin as well as the negative terminal of the external voltage being measured?
Lefty
The top resister has 3.3v going to it, and yes the bottom resistor is going to ground. I measure 1.63v across each resistor so the divider is working as a standard divider.
On my Uno, when I tie the top of the divider to 5v, I see an analog input of around 510 as expected (half of the measurable 1023 for 5 v) and when I tie the top resistor to 3.3v, I see the figure of 335 on the analog pin - again as expected.
MarkT:
Is AREF connected? Have you called analogReference() ?
AREF isn't connected and no I haven't called analog reference - as it is a battery powered circuit, I was going to simply compare the analog reading to a known value for a full battery.
I set up two Films with analog sensors and they worked just the same as it had on my conventional duinos. Then I bought two more from a different supplier, and they do just what you describe: repeating 1021s regardless of which input port I use.
They also came loaded with a sketch of some kind that outputs a 'test failed' message.