{"id":1438,"date":"2012-09-23T18:36:09","date_gmt":"2012-09-23T21:36:09","guid":{"rendered":"http:\/\/wordpress.matbra.com\/?p=1438"},"modified":"2012-12-12T12:13:05","modified_gmt":"2012-12-12T15:13:05","slug":"sensor-de-temperatura-com-arduino-e-lm35-arduino-lm35","status":"publish","type":"post","link":"https:\/\/wordpress.matbra.com\/en\/2012\/09\/23\/sensor-de-temperatura-com-arduino-e-lm35-arduino-lm35\/","title":{"rendered":"Temperature Sensor with Arduino and LM35 (Arduino + LM35)"},"content":{"rendered":"<p>Hello,<\/p>\n<p>I&#8217;m starting to publish some experiments that I do with Arduino UNO\/Nano, sensors and other stuffs. Today I created a thermometer with LM35 sensor. <\/p>\n<p>The LM35 sensor is a temperature sensor, it will variate 10mV\/Celsius. It pins can be seen on image (pay attention, it is a bottom look)<\/p>\n<figure id=\"attachment_1439\" aria-describedby=\"caption-attachment-1439\" style=\"width: 113px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/wordpress.matbra.com\/wp-content\/uploads\/lm35.png\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/wordpress.matbra.com\/wp-content\/uploads\/lm35.png\" alt=\"\" title=\"lm35\" width=\"113\" height=\"120\" class=\"size-full wp-image-1439\" \/><\/a><figcaption id=\"caption-attachment-1439\" class=\"wp-caption-text\">LM35 Pins<\/figcaption><\/figure>\n<p>So to connect it to Arduino, you must connect VCC to Arduino 5V, GND to Arduino GND, and the middle pin you must connect to an Analog Pin, in my case I used A0.<\/p>\n<p>This projects doesn&#8217;t need any resistor or capacitor between the Arduino and the Sensor, so just connect it. The Arduino ADC has a precision of 10 bits, so in this case 5V \/ 2^10 = 5V \/ 1024, so 0.0049 is our factor. To get the temperature in Celsius,  we get the value and calculate like this:<\/p>\n<p>Temperature = (pin * 0.0049)*100<\/p>\n<p>But why multiply by 100? PIN * 0.0049 will give the volts on port, if we multiply it by 1000 we will have millivolts on port, the sensor varies 10mV\/C so we need to divide it by 10 to get the temperature. On mathematics multiply by 1000 and divide by 10 is the same as multiplying by 100. Understand? [Add on 12\/12]<\/p>\n<p>And to have it on Fahrenheit, we need to make a conversion <\/p>\n<p>TemperatureF = (Temperature * 1.8) + 32.<\/p>\n<p>The arduino code that I used is: <\/p>\n<p>[code lang=&#8221;c&#8221;]<br \/>\nint analogPin = 0;<br \/>\nint readValue = 0;<br \/>\nfloat temperature = 0;<br \/>\nfloat temperatureF = 0;<\/p>\n<p>void setup() {<br \/>\n  Serial.begin(9600);<br \/>\n} <\/p>\n<p>void loop() {<br \/>\n  readValue = analogRead(analogPin);<br \/>\n  \/\/Serial.println(readValue);<br \/>\n  temperature = (readValue * 0.0049);<br \/>\n  temperature = temperature * 100;<br \/>\n  temperatureF = (temperature * 1.8) + 32;<br \/>\n  Serial.print(&#8220;Temperature: &#8220;);<br \/>\n  Serial.print(temperature);<br \/>\n  Serial.print(&#8220;C &#8220;);<br \/>\n  Serial.print(temperatureF);<br \/>\n  Serial.println(&#8220;F&#8221;);<br \/>\n  delay(1000);<br \/>\n}<br \/>\n[\/code]<\/p>\n<p>Hope you like it,<br \/>\nMatheus<\/p>\n<p>References:<br \/>\n<a href=\"http:\/\/www.ti.com\/general\/docs\/lit\/getliterature.tsp?genericPartNumber=lm35&#038;fileType=pdf\" target=\"_blank\">LM35 Datasheet<\/a><br \/>\n<a href=\"http:\/\/arduino.cc\/en\/Reference\/analogRead\" target=\"_blank\">Arduino analog Read<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Hello, I&#8217;m starting to publish some experiments that I do with Arduino UNO\/Nano, sensors and other stuffs. Today I created a thermometer with LM35 sensor.&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/wordpress.matbra.com\/en\/2012\/09\/23\/sensor-de-temperatura-com-arduino-e-lm35-arduino-lm35\/\">Continue reading<span class=\"screen-reader-text\">Temperature Sensor with Arduino and LM35 (Arduino + LM35)<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[214],"tags":[215,276,278,279,277],"class_list":["post-1438","post","type-post","status-publish","format-standard","hentry","category-arduino","tag-arduino-2","tag-lm35","tag-sensors","tag-temperature","tag-uno","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/psjGE-nc","_links":{"self":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/comments?post=1438"}],"version-history":[{"count":4,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1438\/revisions"}],"predecessor-version":[{"id":1482,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/posts\/1438\/revisions\/1482"}],"wp:attachment":[{"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/media?parent=1438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/categories?post=1438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.matbra.com\/en\/wp-json\/wp\/v2\/tags?post=1438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}