Lm35 is a precision temperature sensing IC series released by US National Semiconductor (later acquired by TI). Its signal output mode is analog output, and the output voltage value is proportional to the Celsius temperature value, the user can obtain high measurement accuracy without any extra correction. Its main features include:
- Power supply voltage: 4 ~ 30 V
- Measurement Range: Related to the chip. The maximum value is + 2 ~ + 150 °C
- Measurement Accuracy: it is related to the chip and measurement temperature, for example. It can be seen that the typical error value near the room temperature is about +-0.5 °C, and the maximum value is between +-0.5 °C and +-1.5 °C. The lm35d used in this article is the most accurate chip, with a maximum error of about +-1.5 °C.
- Power Consumption: it is related to the measurement circuit and temperature, which is about 50 ~ The value range is 100 μA.
- Sensor gain: 10mV/°C. The relationship between voltage and temperature is vout = temperature × 10mV/°C.
- Long-term stability: the maximum temperature of the range is 1000 hours of drift +-0.08 °C.
- Encapsulation: To-92, metal can, SOIC-8, to-220. The lm35d used in this article is the to-92 encapsulation.
Circuit connection
The lm35d is powered by 5 V voltage on the Arduino uno board, and the signal output end is connected to the A0 pin.
Simple voltage reading and conversion
The conversion is implemented using the Arduino ADC function. The relationship between the voltage and the ad sample value is as follows:
Among them, vin is the measured (input) voltage; vref is the reference voltage. If not specified, it is the power supply voltage, and for the UNO board is 5 V; resolution is the number of bits of the ADC (excluding the symbol bit). For atmega328p, the value is 10 bits, and the ADC is the read conversion result. Strictly speaking, the denominator of the above formula should be subtracted from 1, but whether to subtract 1 will not affect the result. The implementation code is very simple:
1 /* 2 Measuring the temperature using the LM35 sensor 3 Connection: 4 LM35 UNO 5 Vs <------> 5V 6 GND <-----> GND 7 Vout <----> A0 8 9 */10 11 const int PIN_LM35 = A0; //pin connection12 13 float sensorVolt; //unit: mV14 float temperature; //unit: centigrade15 16 void setup()17 {18 Serial.begin(115200); //initialize serial communication19 }20 21 void loop()22 {23 sensorVolt = analogRead(PIN_LM35)*5000.0/1023; //do conversion24 temperature = sensorVolt/10.0;25 26 Serial.print("Temperature: "); //print the result27 Serial.print(temperature); 28 Serial.println(" `C"); 29 30 delay(1000); //delay 1s31 }
Higher Resolution
In addition to using the power supply voltage as the reference source, atmega328p provides an internal reference source of 1 v. When measured at room temperature, the output voltage of lm35 is several hundred MV magnitude. Therefore, an internal reference source can be used to obtain a higher measurement resolution.
- If the 5 V power supply voltage is used as the reference source, the measurement resolution is 5000mV/1024 = ~ 9mV, corresponding temperature 0.49 °C;
- If the internal reference source of 1.1v is used, the measurement resolution is 1100mV/1024 = ~ 1mV, corresponding to the temperature of 0.11 °C, the resolution capability is significantly improved.
The Code is also very simple. You only need to add the analogreference () Statement and change the conversion parameter:
1 /* 2 Measuring the temperature using the LM35 sensor 3 Connection: 4 LM35 UNO 5 Vs <------> 5V 6 GND <-----> GND 7 Vout <----> A0 8 9 */10 11 const int PIN_LM35 = A0; //pin connection12 13 float sensorVolt; //unit: mV14 float temperature; //unit: centigrade15 16 void setup()17 {18 analogReference(INTERNAL); //use internal voltage reference19 Serial.begin(115200); //initialize serial communication20 }21 22 void loop()23 {24 sensorVolt = analogRead(PIN_LM35)*1100.0/1023; //do conversion25 temperature = sensorVolt/10.0;26 27 Serial.print("Temperature: "); //print the result28 Serial.print(temperature); 29 Serial.println(" `C"); 30 31 delay(1000); //delay 1s32 }
However, the error in the atmega328p manual describing the internal benchmark source itself is about +-9%. Therefore, the use of internal benchmark sources also introduces additional measurement errors while improving resolution capabilities. A better method is to use an external high-precision benchmark source.
References
Datasheet: lm35 precision centigrade temperature sensors-Ti
Tutorial: analog to digital conversion-thanks to sparkfun
How to build a lm35 Temperature Sensor Circuit
Arduino lm35 sensor (contains a program that visualizes results using processing)
Tmp36 temperature sensor-from Adafruit
Arduino ADC + analog temperature sensor lm35d