Hi everyone,
I am using the Arduino Giga R1 and take multiple readings from an sensor. The analog data needs to be converted to digital via ADC pins.
Without connecting the AREF to anything, the output gave value ~ 85, now that I have connected the AREF to 5 V, it gives value ~ 1005. However, this value never changes according to actual sensor measurements. I have tried multiple ADC pins but it didn't helped. I've also checked my sensor wiring, but it seems to be fine.
Ideally, I want the values to range between 0 - 1023 as is normal for 10-bit ADC. I have done something similar previously with the Arduino Micro and there it worked fine.
I saw that in case of the GIGA, you just need to connect the AREF without giving analogReference()
in the code as it recognises AREF automatically. I am using the typical analogRead()
to get my sensor readings.
Any ideas or suggestions what is going wrong??
Best, Lea
PS. Here's the code snippet:
const int pin = A0;
const int numReadings = 20; // Number of total sensor readings to take
int rawReading = 0;
int takeMultipleReadings(int pin) {
int totalReadings = 0;
for (int i = 0; i < numReadings; ++i) {
totalReadings += analogRead(pin);
delay(10);
}
return totalReadings / numReadings; // Averaging
}
void setup() {
Serial.begin(115200);
analogRead(pin);
pinMode(turbidostatPin, INPUT);
}
void loop() {
rawReading = takeMultipleReadings(pin);
Serial.println(String(rawReading));
delay(2000);
}