Type Here to Get Search Results !

LM35 temperature sensor using Arduino

Hi everyone, welcome to another informative tutorial of My Tech Studio. In this tutorial we are going to learn how we can use this lm35, 3 pin temperature sensor and display the temperature as Celsius Fahrenheit and Kelvin on the LCD 1602 or LCD2004 using arduino. Here we used LCD1602 or 2004 with just four wire because it has this I2C module. So make sure to use this separately download the library and make sure that you are able to display a text on this. After that then run the code for this and make sure that you are able to read the temperature and displayed on the serial monitor. After that we are combining this together.

LM35 temperature sensor using Arduino -

We are using this 3-pen lm35 temperature sensor to measure and display the temperature in Celsius Fahrenheit and kelvin or take action based on temperature. This is the lm35 temperature sensor and has just three pens the left pen is the voltage or main power which you can connect it from four to 20 volts and the middle pin is the output where you can get a voltage proportional to the temperature. And the right one is ground this outputs 10 millivolts per every degrees of field use and we're using that formula to calculate the temperature proportional to the voltage and here is the data sheet for this its precision centigrade temperature sensor. But this you can measure from minus 55 to 150 degrees Celsius and accuracy is 0.5 degrees Celsius up to 25 degrees.

LM35 temperature sensor Arduino formula –

The current that it needs is 60 microampere the voltage that it can operate is from 4 to 30 volts not 20 volts and output impedance is 0.1 ohm for 1 Mili ampere load which means it can drive that type of load. But for Arduino we are not worried about it and here this module is offered in different package the one that we are using is  to 92 so this is a 292 but it is offered in the v package and here are the pens for to 92 the left  pen is the voltage source the middle is the output. And the right one is the ground you might see it in this shape like an IC but you can see not connected not connected all these pens so we have out is number one and voltage source is on this side and ground is number four or you might see it a little in larger shape of to 220 we will see different variation of this we have lm-35 or lm35a. It will be from minus 155 to 150 if it is my lm35c or can it will be from minus 40 to 110 but if you get lm 35d it will be from 0 to 100 degrees. So it doesn't go to the negative the sensing gain is as you can see for lm35a here typical for an m35c. So the typical for lm35a is 10 10 millivolts per degree Celsius.

LM35 sensor with Arduino Circuit Diagram –

Now let me explain the wiring. The left end of lm35 is connected to pin 2 where we have defined it as extra 5V inside the code you can change it you can select any other pin you want. The metal pin is the output using green wire it has been connected to analog 0 A0 and the right pin is a ground it has been connected to the ground. For the LCD module we have four wires this pin from this side it is ground that has been connected to ground of Arduino. The second pin is VCC it has been connected using white wire to 5 volts. Then we have SDA using grey wire have been connected to analog A4 and SCL is connected the last pin using this purple wire to analog 5 A5. You can also connect it to this SDA and SCL accordingly.

Arduino LM35 temperature sensor code –

Now let me explain the code we are defining analog zero as an input pin and then we are defining pin 2 for extra VCC (5V) for lm35 because we have only one five volts and I did not want to use a breadboard. And then this 1,000 iterations is for then the same as the introduction video which takes 1000 measurement and gets it gives the average and this a lintel if I factor is the 10mV/°C Celsius do not change it. This portion is for LCD screen and this is the class of library and we are taking the class create an object called LCD and this is a I2C address for this module we are passing it and if you don't know it here is how you get it. I will provide you the code with I2C scanner this is a code I will provide you just put it on a sketch upload it to the Arduino and then open the serial monitor then you will read it if the wiring everything is ok you will be able to see the I2C address. And it will continuously print that for you. So that is 0X26 that is why I am using that and 16 means 16 character and 2 means 2 line because here we have 1 2 3 up to 16 characters and we have 2 lines and that is the sample here either as Kelvin Celsius or Fahrenheit. 

And I've given it two seconds before printing Fahrenheit. at the same way this is a temperature this is assemble and you must pass it inside a single code with capital C capital F or Fahrenheit and capital K for Kelvin. And if you want to take some action based on temperature so this is giving you the temperature and feel safe and you want to say F the temperature is greater than 87 degrees do something so this is the opening and closing for the condition and whatever action you want to take put it in here like turning on a relay or fan or something so you can do the action here. If you need the full explanation of this code, then follow my upcoming blog post.

How do you convert LM35 to Celsius?

Now let me demonstrate it now this is showing the room temperatures and I'm using this heat gun to apply some heat on this so the compressor is increasing have weakened future 55 and now it will cool down slowly 83 degrees and slowing down perfectly working currently a live connected to five volts but let me connect it to 3.3 volts and see if it works so when I remove it will read incorrect value or zero so now I'm connecting it to 3.3 volts and let's see what we are reading so still it's working. But manufacturer suggests that should be connected to minimum of 4V. But still we are reading value I don't know how accurate is when you connect it and 3.3 volts for that reason corrected to 5 volts.