|
<!DOCTYPE html>
|
|
<!--html5-->
|
|
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
|
<head>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta charset="utf-8" />
|
|
|
|
<title>Arduino Playground - LM35HigherResolution </title>
|
|
<link rel="shortcut icon" type="image/x-icon" href="https://playground.arduino.cc/favicon.ico" />
|
|
|
|
<link rel="stylesheet" href="//content.arduino.cc/legacy/fonts/fonts.css" type="text/css" />
|
|
<link rel="stylesheet" href="//content.arduino.cc/legacy/css/arduino-icons.css">
|
|
<link rel="stylesheet" href="//content.arduino.cc/legacy/css/animation.css"><!--[if IE 7]>
|
|
<link rel="stylesheet" href="//content.arduino.cc/legacy/css/arduino-icons-ie7.css"><![endif]-->
|
|
<!--[if gte IE 9]><!-->
|
|
<link rel='stylesheet' href='//content.arduino.cc/legacy/css/foundation2.css' type='text/css' />
|
|
<![endif]-->
|
|
<!--[if IE 8]>
|
|
<link rel='stylesheet' href='//content.arduino.cc/legacy/css/foundation_ie8.css' type='text/css' />
|
|
<![endif]-->
|
|
<link rel='stylesheet' href='//content.arduino.cc/legacy/css/arduino_code_highlight.css' type='text/css' />
|
|
<link rel="stylesheet" type="text/css" media="screen" href="//content.arduino.cc/legacy/css/typeplate.css">
|
|
<link rel='stylesheet' href='//content.arduino.cc/legacy/css/common.css' type='text/css' />
|
|
<link rel='stylesheet' href='https://playground.arduino.cc/pub/skins/arduinoWide_SSO/css/arduinoWide_SSO.css?nocache=1' type='text/css' />
|
|
<link href="https://plus.google.com/114839908922424087554" rel="publisher" />
|
|
<script src="//content.arduino.cc/legacy/js/vendor/custom.modernizr.js"></script>
|
|
</head>
|
|
<body>
|
|
<div id="header"></div>
|
|
<div id="menuWings" class="fixed"></div>
|
|
<div id="page">
|
|
|
|
<br class="clear"/>
|
|
|
|
<!--PageLeftFmt-->
|
|
<div id="pagenav">
|
|
<p><em>The <a class='wikilink' href='https://playground.arduino.cc/Main/HomePage'>playground</a> is a publicly-editable wiki about <a class='urllink' href='http://www.arduino.cc/' rel='nofollow'>Arduino</a>.</em>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/ManualsAndCurriculum'>Manuals and Curriculum</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='urllink' href='http://arduino.stackexchange.com' rel='nofollow'>Arduino StackExchange</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/ArduinoCoreHardware'>Board Setup and Configuration</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/DevelopmentTools'>Development Tools</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'> <a class='wikilink' href='https://playground.arduino.cc/Main/ArduinoOnOtherAtmelChips'>Arduino on other Chips</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware'>Interfacing With Hardware</a>
|
|
</p><ul><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#Output'>Output</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#InputTOC'>Input</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#ui'>User Interface</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#Storage'>Storage</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#Communication'>Communication</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/IntWithHW-PwrSup'>Power supplies</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithHardware#General'>General</a>
|
|
</li></ul><p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/InterfacingWithSoftware'>Interfacing with Software</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/GeneralCodeLibrary'>User Code Library</a>
|
|
</p><ul><li><a class='wikilink' href='https://playground.arduino.cc/Main/SketchList'>Snippets and Sketches</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/LibraryList'>Libraries</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/TutorialList'>Tutorials</a>
|
|
</li></ul><p class='vspace'></p><p class='sidehead'><a class='urllink' href='https://github.com/arduino/arduino/issues' rel='nofollow'>Suggestions & Bugs</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/ElectroInfoResources'>Electronics Technique</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/Resources'>Sources for Electronic Parts</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/SimilarBoards'>Related Hardware and Initiatives</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='urllink' href='http://playground.arduino.cc/Main/People' rel='nofollow'>Arduino People/Groups & Sites</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='urllink' href='http://playground.arduino.cc/Projects/ArduinoUsers' rel='nofollow'>Exhibition</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='urllink' href='http://playground.arduino.cc/Projects/Ideas' rel='nofollow'>Project Ideas</a>
|
|
</p>
|
|
<p class='vspace'></p><p class='sidehead'><a class='wikilink' href='https://playground.arduino.cc/Main/Languages'>Languages</a>
|
|
</p>
|
|
<p class='vspace'></p><hr />
|
|
<p class='vspace'></p><p class='sidehead'> <a class='wikilink' href='https://playground.arduino.cc/Main/Participate'>Participate</a>
|
|
</p><ul><li><a class='wikilink' href='https://playground.arduino.cc/Main/Participate#contribrules'>Formatting guidelines</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Site/AllRecentChanges'>All recent changes</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/PmWiki/PmWiki'>PmWiki</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/Main/WikiSandbox'>WikiSandBox training</a>
|
|
</li><li><a class='wikilink' href='https://playground.arduino.cc/PmWiki/BasicEditing'>Basic Editing</a>
|
|
</li><li><a class='urllink' href='http://www.pmwiki.org/wiki/PmWiki/DocumentationIndex' rel='nofollow'>Documentation index</a>
|
|
</li></ul><p class='vspace'></p>
|
|
|
|
</div>
|
|
<!--/PageLeftFmt-->
|
|
|
|
|
|
|
|
<div id="pagetext" class="playground">
|
|
<!--PageText-->
|
|
<div id='wikitext'>
|
|
<p>The <span class='wikiword'>LM35</span> is a common TO-92 temperature sensor. It is often used with the equation
|
|
</p>
|
|
<p class='vspace'></p><p>
|
|
<div class='sourceblock ' id='sourceblock1'>
|
|
<div class='sourceblocktext'><div>temp = (5.0 * analogRead(tempPin) * 100.0) / 1024;<br/></div></div>
|
|
<div class='sourceblocklink'><a href='https://playground.arduino.cc/Main/LM35HigherResolution?action=sourceblock&num=1' type='text/plain'>[Get Code]</a></div>
|
|
</div>
|
|
|
|
</p>
|
|
<p class='vspace'></p><p>However, this does not yield high resolution. This can easily be avoided, however. The <span class='wikiword'>LM35</span> only produces voltages from 0 to +1V. The ADC uses 5V as the highest possible value. This is wasting 80% of the possible range. If you change aRef to 1.1V, you will get almost the highest resolution possible.
|
|
</p>
|
|
<p class='vspace'></p><p>The original equation came from taking the reading, finding what percentage of the range (1024) it is, multiplying that by the range itself(aRef, or 5000 mV), and dividing by ten (10 mV per degree Celcius, according to the datasheet: <a class='urllink' href='http://www.ti.com/lit/ds/symlink/lm35.pdf' rel='nofollow'>http://www.ti.com/lit/ds/symlink/lm35.pdf</a>
|
|
</p>
|
|
<p class='vspace'></p><p>However, if you use 1.1V as aRef, the equation changes entirely. If you divide 1.1V over 1024, each step up in the analog reading is equal to approximately 0.001074V = 1.0742 mV. If 10mV is equal to 1 degree Celcius, 10 / 1.0742 = ~9.31. So, for every change of 9.31 in the analog reading, there is one degree of temperature change.
|
|
</p>
|
|
<p class='vspace'></p><p>To change aRef to 1.1V, you use the command "analogReference(INTERNAL);"
|
|
</p>
|
|
<p class='vspace'></p><p>Here's an example sketch using 1.1 as aRef:
|
|
</p>
|
|
<p class='vspace'></p><p>
|
|
<div class='sourceblock ' id='sourceblock2'>
|
|
<div class='sourceblocktext'><div><br/>float tempC;<br/>int reading;<br/>int tempPin = 0;<br/><br/>void setup()<br/>{<br/> analogReference(INTERNAL);<br/>Serial.begin(9600);<br/>}<br/><br/>void loop()<br/>{<br/>reading = analogRead(tempPin);<br/>tempC = reading / 9.31;<br/>Serial.println(tempC);<br/>delay(1000);<br/>}<br/><br/></div></div>
|
|
<div class='sourceblocklink'><a href='https://playground.arduino.cc/Main/LM35HigherResolution?action=sourceblock&num=2' type='text/plain'>[Get Code]</a></div>
|
|
</div>
|
|
|
|
</p>
|
|
<p class='vspace'></p><p>With this sketch, approximately a tenth of a degree resolution is possible. Of course, such small numbers are going to be somewhat inaccurate because aRef will not be exactly 1.1V. Also, the <span class='wikiword'>LM35</span> is only guaranteed to be within 0.5 degrees of the actual temperature. However, it does yield higher resolution, if only for appearances' sake.
|
|
</p>
|
|
<p class='vspace'></p><p>A side note: with aRef at 1.1V, the temperature range of the <span class='wikiword'>LM35</span> is limited to 0 to 110 degrees Celcius.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
|
|
</div> <!-- eof pagetext -->
|
|
|
|
<br class="clear"/>
|
|
|
|
</div> <!-- eof page -->
|
|
|
|
|
|
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
|
|
<script src="//content.arduino.cc/legacy/js/foundation.min.js"></script>
|
|
<script>
|
|
$(document).foundation();
|
|
</script>
|
|
<!--<![endif]-->
|
|
<!--[if IE 8]>
|
|
<script src="//content.arduino.cc/legacy/js/foundation_ie8.min.js"></script>
|
|
<script src="//content.arduino.cc/legacy/js/ie8/jquery.foundation.alerts.js"></script>
|
|
<script src="//content.arduino.cc/legacy/js/app.js"></script>
|
|
<![endif]-->
|
|
|
|
<script type="text/javascript">
|
|
var _gaq = _gaq || [];
|
|
_gaq.push(['_setAccount', 'UA-22581631-3']);
|
|
_gaq.push(['_setDomainName', 'arduino.cc']);
|
|
_gaq.push(['_trackPageview']);
|
|
|
|
(function() {
|
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
})();
|
|
</script>
|
|
<div>
|
|
<div id="newsletter-modal"></div>
|
|
<div id="footer"></div>
|
|
</div>
|
|
<script src="https://cdn.arduino.cc/header-footer/loader.js" type="text/javascript"></script>
|
|
<script>
|
|
var auth = {
|
|
token: function() {
|
|
return false ? Promise.resolve({
|
|
token: null }) : Promise.reject('loggedout')
|
|
},
|
|
redirectURI: function() {
|
|
return 'https://auth.arduino.cc/login?client_id=playground&redirect_uri=https%3A%2F%2Fplayground.arduino.cc%2F&state=92170800&scope=profile%3Acore+profile%3Apublic+profile%3Acontact+offline&response_type=code';
|
|
}
|
|
};
|
|
ArduinoHeaderAndFooter({
|
|
auth: "custom",
|
|
authOptions: auth
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|