Pages: [1]   Go Down
Author Topic: Sensor Accuracy Aref or VCC?  (Read 501 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Guys!

I know for some point, people like myself tend to ask questions about the accuracy of sensors and readings. 

Background of my setup:
1x LM35 sensor
2x 220 ohm resistors acting as voltage divider

My objective:
measure temperature and voltage across the divider smiley-lol

I know people tend to use 5v*sensor reading/1024 to get the feed back voltage.  And i know it is not accurate, after googling i have found this to get the real voltage reading, codes are here :
  long result;
  // Read 1.1V reference against AVcc
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
  delay(2); // Wait for Vref to settle
  ADCSRA |= _BV(ADSC); // Convert
  while (bit_is_set(ADCSRA,ADSC));
  result = ADCL;
  result |= ADCH<<8;
  result = 1126400L / result; // Back-calculate AVcc in mV
  return result;
(adopted from

and i have also read up some information about using the Aref in

So, lets keep it short, which method is better? smiley-mr-green

Thanks in advance!! smiley-wink smiley-wink

Massachusetts, USA
Offline Offline
Tesla Member
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you notice in the datasheet that the 1.1V reference is only accurate to about 10%  (1.0V to 1.2V) you will learn that measuring Avcc that way will be no more than 10% accurate.

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Online Online
Shannon Member
Karma: 215
Posts: 12489
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can calibrate the internal reference for much better performance, but then you have to keep the calibration value somewhere (eeprom?).

The datasheet doesn't say anything about the repeatability or tempco of the bandgap reference, alas, its unclear how well it performs once calibrated.

[ I won't respond to messages, use the forum please ]

Left Coast, CA (USA)
Offline Offline
Brattain Member
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Probably better to state what your accuracy desires are, what range voltages you wish to measure, and what minimum step size resolution you need. Then possible references can be offered. The built in arduino ADC is very useful and easy to use, but it should not be confused with instrumentation quality ADC. There are lots of I2C and SPI driven ADC chips available these days if your specifications require the performance they bring to the table.


Pages: [1]   Go Up
Jump to: