A code question to DUE and a senosr

Hi there

Im trying to connect a senosr to my DUE.

First of all I connected the AREF of the DUE board to the VREF of my sensor it is 2.5 Volt. This works so far somehow I cant use analogrefrence(external) I recive an error. Does it work with DUE ?

This is my TEST code

oid setup() {
  // put your setup code here, to run once:
analogReference(External);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue= analogRead (A0);
 // float Current= (sensorValue-4.0833)/2.1167;
 Serial.println(sensorValue);

}

No the Due is not really the same as ATmega chips and the AREF pin is restricted to the
range 2.4V to AVcc for 12 bit conversions and the range 2.0V to AVcc for 10 bit
conversions.

The AREF pin is internally connected to the 3.3V rail by a solderable jumper near
the ICSP header. You have to change this from 3.3 to 'EXT' in order to be able
to set it from the AREF pin. Its hard to solder because its sandwiched between
some tall components.

In other words you set the analog reference on the Due by hardware modiciation,
not software.

Hello Markt

I already removed the resistor from the 3.3 Volt sector and added it to the AREF.

I also measured my AREF pin after connecting 2.5 Volt to it andI got it..

My question is as I already wrote I recive a compiler error related to the analogReference(EXTERNAL) ; Do I have to include something or so ? Would you or anyother one try it with your arduino due board and tell me if it will work or not ? :slight_smile:

This is my code again

void setup() {
  // put your setup code here, to run once:
analogReference(External);
Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  int sensorValue= analogRead (A0);
 // float Current= (sensorValue-4.0833)/2.1167;
 Serial.println(sensorValue);

}

The Due is not an ATmega, there is only an analog reference pin and its always
the reference - you have to configure it in hardware, not in software. Is that clear?

[ hint: "analogReference (EXTERNAL)" would be configuring it in software ]

@ MARK

Why dont you just read my post carefully !!!

I said I changed the AREF per Hardware and now I have to tell my Ardunio DUE that my refrence voltage external and not internal and this is my problem !!

Again I followed this tip "The AREF pin is connected to the SAM3X analog reference pin through a resistor bridge. To use the AREF pin, resistor BR1 must be desoldered from the PCB." and now I just ask why I recive a compiler error when i write this line

analogReference(EXTERNAL) ;

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I guess the answer is, you do not need to have that line of code in your program as you have already configured the AREF by hardware manipulation.