Interfacing Arduino with LM35 Temperature Sensor
Hello guys in today vedion will explore together the famous temperature sensor LM35 which use widely in electronics and DIY projects, we will dive into it's working principal then we will interface this sensor with arduino Uno board in order to make a small temperature measurment projects .The LM35 is one of the most common temperature sensors in small electronics projects due to its low cost, easy to interface with it and offers a good range of signal (acceptable range) .it comes as an integrated circuit IC , it have shape same as BJT transistor with 3 terminals
- Vcc
- Gnd
- Output data (10mV for each 1C°)
Working Principal:
the LM35 is an analog temperature measuring device, with an analog output voltage proportional to the temperature ,It provides output voltage in Centigrade (Celsius) which mean It does not require any external calibration circuitry, also the sensitivity of LM35 is 10 mV/degree Celsius which give a good temperature precision . As temperature increases, output voltage also increases. Iit have an operating range varying from temperature -55 °C to 150 °C.LM35 gives temperature output which is more precise than thermistor output.there is two main configuration of the Lm35 temperature sensor
- Basic temperature measurement
- Full range temperature measurement
So the programmer can use the appropriate configuration according to his need eg: if he need to measure temperature below 0C° he will choose the Full range temperature measurement , and if he need just to measure temperature above 0C° like room temperature he will choose the Basic temperature measurement below some of the main specification of the LM35 Sensor
- Operating Voltage: 4 V to 30 V
- Output Voltage: 10mV/°C
- Sensitivity: 10mV/°C
- Linearity Error: ±1°C (for 0°C to +100°C)
- Operating Temperature: -55°C to +150°C
- Output Impedance: 100 Ω
Interfacing LM35 with Arduino Uno:
Now we will link the LM35 with an Arduino Uno and write a code that read the temperature value given by the sensor and display it in the serial monitor ,we need as hardware : Arduino Uno , LM35 Sensor, and some wires ,the circuit is very easy we drag each terminal of the sensor in the appropriate Pin of arduino Gnd with Gnd, 5V with VCC , and A0 pin with the output terminal of the LM35 Sensor like the figure given below:
Now we pass through the software phase , for the program we need to declaring variable which is the LM35 Data_Pin , like the data is analog value it will be readed by the ADC and converted into ADC value and this value it will be converted to temperature so we need two more variable which are the Temp_ADC_Val and the Temp_val
after declaring variables , we run the Serial monitor with Serial.begin command
then in the void loop we read the ADC value of the LM35 , then we convert this value into voltage with the following relation
the Adc is 10 bit so ADC max : 1023 that give 5 V (5000 mV)
Temp_Adc_Value X
so X=(TempAdcVal*5000)/1023= TempAdcVal*4.88 (by mV)
then we convert this value to temperature by devide it by 10
Temp= X/10
the full code script is given below :
the Simulation files with the circuit drawing are
given on TinkerCad in the link below :
https://www.tinkercad.com/things/0N7g7srpbnV-lm35-telperature-sensor