Grumpy_Mike:
No it is the 3V3 pin, you have to connect it to the Vref pin and then set the board to use the external reframe with a software command. If you try and simply read the analogue input with it attached and without issuing the command you will damage your board.
Got that figured out now. Connected the pins marked "3V" and "RF" and used :
analogReference(EXTERNAL); // use AREF for reference voltage
And about the 3.3000V, should have just typed 3.3V to avoid confusion, sowwy.
But I thought, hey, lets do a test on the 3.3V pin. First curious about the voltage, then curious about whether a component connected to the arduino would have any influence.
So here is what I did on my arduino mega 2560:
- connected the 3.3v pin directly to A0
- connected a led
- turn on the led, take X readings, calculate and display average
- turn off the led, take X readings, calculate and display average
The code I used is this:
//--------------------------------------------------
// This code can be used to test the 3.3V Vref
//
// Tested here is the influence of a connected led that is switched on and off
// - The led is turned ON, a number of readings (intSamples) is done
// - The avarage of the readings is calculated and displayed
//
// - The led is turned OFF, a number of readings (intSamples) is done
// - The avarage of the readings is calculated and displayed
//
// - Format of one line is semicolon seperated: LED ON;3.3366;LED OFF;3.3255
// - Copy the data into a text file, import that text file into excel and calculate the grand total :)
//Number of samples
int intSamples = 500;
//Float that is used to calculate average
float fltTotal;
void setup() {
Serial.begin(9600);
//Pin number to which the led is connected
pinMode(52, OUTPUT);
digitalWrite(52, LOW);
}
void loop() {
//turn on the led
digitalWrite(52, HIGH);
Serial.print("LED ON;");
//set the total of all readings to 0
fltTotal = 0;
for (int i = 0; i < intSamples; i++) {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1024.0);
//add the sampled voltage to the total of all readings
fltTotal = fltTotal + voltage;
}
//After reading and adding samples calculate average and print with 4 decimals
Serial.print(fltTotal / intSamples, 4);
digitalWrite(52, LOW);
Serial.print(";LED OFF;");
fltTotal = 0;
for (int i = 0; i < intSamples; i++) {
int sensorValue = analogRead(A0);
float voltage = sensorValue * (5.0 / 1024.0);
fltTotal = fltTotal + voltage;
}
Serial.println(fltTotal / intSamples, 4);
}
After running the code for a few seconds and calculating the average of 80x500 samples the result is:
Average voltage on 3.3v pin
- with led ON : 3.3372
- with led OFF: 3.3264
So I guess it might be better to get an external 3.3V reference. For anyone interested, I found a nice pdf with info on voltage reference, attached below.
I hope to get the sensor in the mail tomorrow. First I'll need a program running and then I'll do some testing on behaviour, temparature and ambient light.
Voltage Reference Info.pdf (276 KB)