Hi, welcome to an Arduino tutorial for Robojax. my name is Ahmad Shamshiri. in
this tutorial we are going to learn how we can use this 3 pin lm35 temperature
sensor to measure the temperature and displayed on serial monitor as Celsius
Fahrenheit Kelvin or use it for other purpose to take action based on
temperature. you can get the code for this by clicking at the link below the
video in the description which will take you to www.robojax.com/learn/arduino
let's get started with this
I am presenting this tutorial from Canada
this is the lm35 temperature sensor and have just three pins the left pin is the
voltage or main power which you can connect it from 4V to 30V volts and the
middle pin is the output where you can get a voltage proportional to the
temperature. and the right pinis ground. this module outputs 10 millivolts per every
degrees of Celsius. and we are using that formula to calculate the temperature
proportional to the voltage. and here is that datasheet for this it's precision
centigrade temperature sensor but this you can measure from - 55° to 150°C degrees
Celsius and accuracy of 0.5 degrees Celsius up to 25 degrees. the current
that it needs is 60 micro ampere. The voltage that it can operate is from 4 to
30 volts not 20 volts. And output impedance is 0.1 ohm for 1
milli 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 TO-92 but it is offered in
NDV package and here are the pins. for TO-92 the left pin is the voltage source
the middle is the output and the right turn is a ground you might see it in
this shape like an IC but you can see not connected not connected all these
pin so we have out if number one and voltage sources on this side and ground
this number 4 or you might see it a little in larger shape of to-220 we will
see different variation of this we have lm35 or lm35A. it will be from minus -55
150°C if it is LM35 C or CA it will be from minus 40 °C to 110°C. but if you
get lm35 d be from 0° to 100°C so it
doesn't go to the negatives. the sensing thing gain is as you can see for LM35A
here's typical for an M 35 C so the typical for lm35 a is 10mV/°C
per degree Celsius so that's what I'm using. I'll provide you the datasheet in
case if you need it for further study.
Wiring Explained
and now here is the wiring. the wiring is very simple the last one is the VCC
this is connected to five volts and here and the pin on the right side is the
ground using green have been connected to the ground and the middle pin is the
output where we read that and pressure has been connected using blue wires to
analog zero A0. if you need the wiring diagram for this it is available as part
of my Arduino course at udemy.com. if you want to learn Arduino I have a
best seller course on udemy where you can learn Arduino from ground up with
hundreds of projects all course material library codes wiring diagram everything
available in one place. the link for Arduino courses below this video in the
description.
Code explained
now let me explain the code. first we initialize our constant integer inPin
this is the pin that you are connecting the middle pin of the temperature sensor
and this is LM35 factor that is ten millivolts per degree Celsius
0.01 do not change this you can change this to any other analog pen in your
Arduino and this iteration is number of iterations for average we do take 1,000
measurement and we divided by thousand so we can get the average if you want to
reduce it for some application for very fast measurement you can make it even
one it's up to you. inside the set up we initialize the serial monitor with 9600
baud and that is a value if I click here and on the right side come down that is
9600 baud on this side so to display the value for us. inside the loop these are
the value that will be read continuously. printTemperature('C') when you put with
unit Celsius you just put that and it's apparent this Celsius and if you need it
Fahrenheit this Fahrenheit is printed in here so this is a function that I have
written that will print it. including the sample for the Fahrenheit,
Celsius and for the Kelvin. but if you want to get the temperature and do
something so this is getTemperature inside a single quote put C
these are also single quotation. pay attention if you put double quotation or lowercase it
will not work. make sure to put single quotation uppercase. and if you don't want to
just print it like that but you want to take action for example IF(
getTemperature('C') this is a temperature and you want to compare it
if it is greater than 87 you want to do something so that doing something or
action is between this opening parenthesis and curly parenthesis are closing and put
your action in here like turning on a light or writing something or saving
something or doing something so action will happen in here. if you need
full explanation of the code with other functions that I've written it is
available as part of my vehicles at udemy.com
Demonstration of measuring temperature
Let me now demonstrate it. now that the sensors have twenty five point three nine
degrees Celsius or 78 degrees Fahrenheit and this is converting data now and you
can see we are getting the three values on the screen now I'm going to apply
heat using this heat gun.
and as you can see the temperature increase about 80° degrees and if one
hundred and sixty or seventy nine is decreasing
and if I remove this you will see that it shows some random value 200 degrees
and something so when the wiring is incorrect that's how you know that
something is wrong. and now you can see also because the wires are one is one
wire is connected the other is not connected
you saw zero now this is actual temperature slowly decreasing
and here if you want to take some action based on temperatures you will say get
temperature let's say in in Celsius if the temperature is above 87 degrees this is
just an example take some action between these two curly parenthesis and put your
action in here so this is where your action will be where you can turn on a
relay or do something. thank you for watching this was how to use the LM 35 and display that
temperature or get the temperature I have more videos on this that you can
defer the temperature on the screen and CD 1602 or 2004 and also on the TM 1637
LED display many other applications and or turning on and off and light base and
temperatures
I would like to thank my Patrons from Patreon.com
Subtitle typed and corrected by Ahmad Shamshiri in Canada on July 21, 2020
I did my part to help you learn. Now it's your turn.
You can subscribe to my channel, thumb up 👍 the video and say "thank you" in the comment section.
The link to my PayPal account is below this video if you want to send me chase donation. Thank you.
if you liked this video and learned something please thumb up 👍 as this will
help my video in the search algorithm of YouTube if you have comment or question
posted at a comment section below I try to answer and reply if you want to get
updates of my upcoming videos make sure to subscribe.
if you want to learn arduino i have a best seller course on udemy where you
can learn Arduino from ground up with hundreds of projects all course material
library codes wiring diagram everything available in one place the link to my
Arduino course is below this video in the description.
now it's 96 degrees or 205 degrees Fahrenheit
very hot almost going to burn but I just removed the heater 88 degrees 190
degrees Fahrenheit
if I hold it my body temperature will bring it down let's see the humidity
already increased