AnalogRead on Seeeduino Film?

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.

Does anyone have any suggestions?

Regards,
Morrolan

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

retrolefty:

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.

5v
|
| |
| | R1
| |
|
|
|------------ Analog Pin (A1)
|
|
| |
| | R2
| |
|
|
GND

Regards,
Morrolan

hm

u could try a lower voltage (like 500mV instead of 1.63V)...
and c what happens...

u could call
analogReference(DEFAULT);
just to be sure, that it uses VCC as reference for the ADC...

Is AREF connected? Have you called analogReference() ?

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.

Do you recommend using analogReference()?

No I was just wondering if AREF was used and at ground potential which might explain the symptoms...

What if you tie A1 directly to ground? Does the A/D read 0? If you leave it floating do you get random values?

Have you tried using the other analog inputs?

Did you ever get this sorted out?

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.

cheers