Search code examples
arduinoadkatmega

Using a non-5v analogReference voltage in the ADK2012


I have a the ADK2012 arduino due-like device. I am using google's copy of the arduino software, and I can compile and run various sketches without trouble.

I've got an LM35 that I've hooked up to an analog input. By default, the reference voltage is 5 volts. This seems to work fine, but I would like to use a different analogReference value, as documented here:

http://arduino.cc/en/Reference/AnalogReference

Unfortunately, I'm having some trouble. When I use DEFAULT or EXTERNAL like this:

analogReference(DEFAULT);

I get this when I compile:

AnalogReadSerial.cpp: In function 'void setup()':
AnalogReadSerial:12: error: invalid conversion from 'int' to 'eAnalogReference'
AnalogReadSerial:12: error: initializing argument 1 of 'void analogReference(eAnalogReference)'

If I try to set it to INTERNAL, INTERNAL1V1, or INTERNAL2V56, I get errors like:

AnalogReadSerial.cpp: In function 'void setup()':
AnalogReadSerial:12: error: 'INTERNAL' was not declared in this scope

I'm at a bit of a dead end here. I'm not familiar enough with Arduino or Wiring to know if this is a problem with the supplied device configuration, or an actual limitation of the physical hardware, or a bug or incompatibility internally.

It's unfortunate that the hardware I'm using is relatively rare, and doesn't seem to have much documentation. I'd appreciate suggestions on where to start looking to fix this issue.


Solution

  • It turns out (now that the arduino docs have caught up, 5 months later) that the answer is:

    These devices operate at 3.3 volts natively, and so the analogReference function isn't enabled.

    The Due’s analog inputs pins measure from ground to a maximum value of 3.3V. Applying more then 3.3V on the Due’s pins will damage the SAM3X chip. The analogReference() function is ignored on the Due.

    http://arduino.cc/en/Main/ArduinoBoardDue