1

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 Apr 7 '15 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 Apr 7 '15 at 16:05
4

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 Apr 7 '15 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. – Paul Apr 7 '15 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.