I'm using an LM35 temperature sensor, and it outputs 190 mV (which agrees with 19°C). I'm using an external reference voltage which I measure as 417mV. (This is set by the pin "aRefCntrl"). So I should have a reading around 467, but I get 1023, i.e. the ADC overflows. When I use the internal 1.1V reference I get a correct reading. Any ideas?
This is my code (Arduino waits for a request from the PC to send the data):
#define lm35 A0
#define aRefCtrl 10
void setup() {
pinMode(aRefCtrl, OUTPUT);
digitalWrite(aRefCtrl, 0);
analogReference(EXTERNAL);
analogRead(lm35); // dummy read
Serial.begin(9600);
}
void loop() {
if ( Serial.available() ) {
Serial.read(); // PC's request is a single byte
int temperature = analogRead(lm35);
Serial.println(temperature);
}
}
follow-up on Ignacio's comment: would a decoupling capacitor do? (I can't test for the moment, I have to order some)
-
How much current is available from the reference?Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2015年04月07日 16:01:14 +00:00Commented Apr 7, 2015 at 16:01
-
@Ignacio: not much, the reference voltage comes from a 10k/1k divider on 5V. Isn't the voltage I measure at the aRef pin not the real reference voltage?Joris Groosman– Joris Groosman2015年04月07日 16:05:06 +00:00Commented Apr 7, 2015 at 16:05
1 Answer 1
The minimum reference voltage is 1.0 V according to the atmega328 datasheet. See table 29-15. ADC Characteristics.
-
Thanks a lot! I was looking for that information in the datasheet, scanning it for all occurrences of "Aref", but it seems to appear as "Vref" :-). (Page 310, FTW.)Joris Groosman– Joris Groosman2015年04月07日 16:45:24 +00:00Commented Apr 7, 2015 at 16:45
-
Hmm, Aref as in Analog Reference and Vref as in Voltage reference I think? But indeed 1.1V bandgap is a reliable (small voltage) source.aaa– aaa2015年04月07日 17:17:37 +00:00Commented Apr 7, 2015 at 17:17