Browse Source

HFS start.

master
Your Name 5 years ago
parent
commit
8633fe1ada
3 changed files with 276 additions and 9 deletions
  1. +184
    -0
      Resources/LM35HigherResolution.html
  2. BIN
      Resources/lm35.pdf
  3. +92
    -9
      ZMHW_Project_InfraredDiodeSensor.ino

+ 184
- 0
Resources/LM35HigherResolution.html View File

@ -0,0 +1,184 @@
<!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 &amp; 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 &amp; 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&amp;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&amp;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>

BIN
Resources/lm35.pdf View File


ZMHW_Project_LaserDiodeSensor.ino → ZMHW_Project_InfraredDiodeSensor.ino View File

@ -56,7 +56,7 @@
/***************Ethernet ENC28J60***************/
//Mac must be unique
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xEA, 0x11 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xEA, 0x15 };
//IP of Arduino
byte ip[] = { 192, 168, 1, 177 };
//IP of zm server
@ -69,9 +69,9 @@ String host="192.168.1.178";
//username and password to login to Zoneminder Server.
//If you don't have authentication, you will need to edit the
//script.
//NOTE: not needed for ZMTrigger. Only API.
String username="username";
String password="password";
//NOTE: not needed for ZMTrigger. Only API. DO NOT USE
//String username="username";
//String password="password";
EthernetClient client;
@ -79,14 +79,17 @@ EthernetClient client;
#define ZMTRIGGERPORT 6802
//set to 1 if using sick sensor (on analog pin)
#define SICK 0
/***************Pins***************/
#define SPEAKER_PIN 6
#define LED_PIN 9
#define RESETPIN 2 //may not be needed here
//#define RESETPIN 2 //may not be needed here
#define SENSORPIN A1
#define TEMPPIN A0
@ -95,8 +98,9 @@ EthernetClient client;
int MotionSensorRead = 0;
uint8_t AlarmActive = 0;
char* ZMTriggerMessage = "1234567890123456789012345678901234"; //Initialize this with dummy data
char* ZMTriggerMessage = "1234567890123456789012345678901234"; //Initialize this with dummy data
int TEMPERATUREVALUE = 0;
int TEMPERATUREVALUE2 = 0;
// Upper and lower limit for ADC to register motion
@ -138,6 +142,17 @@ char* source = "ZMHW MotionSensor"; //source
// Initialize the Ethernet server library
#define LISTENPORT 80// (port 80 is default for HTTP):
EthernetServer server2 = EthernetServer(LISTENPORT);
//Do not need to edit below
@ -189,11 +204,17 @@ void setup()
pinMode(SENSORPIN, INPUT);
pinMode(SPEAKER_PIN, OUTPUT);
pinMode(RESETPIN, OUTPUT);
//pinMode(RESETPIN, OUTPUT);
//Be careful. Areg is 1.1v!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
analogReference(INTERNAL);
Ethernet.begin(mac, ip);
server2.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
@ -247,13 +268,23 @@ void loop()
Serial.print("Motion Sensor Value: ");
Serial.println(String(MotionSensorRead));
//Serial.println(String(timer1));
delay(10);
TEMPERATUREVALUE = analogRead(TEMPPIN);
Serial.print("Temperature Value: ");
// See resources. uses 1.1 aref, converts to celcius, then to Fareinheit.
TEMPERATUREVALUE2 = (TEMPERATUREVALUE / 9.31)* 2 + 30;
Serial.println(String(TEMPERATUREVALUE2));
delay(10);
if(DEBUGMODE){
delay(10);
}
//Motion sensing for Sick Photoelectric sensor only
//upon boot, values are around 400 sometimes, so only alert at higher
if(SICK == 1){
if (MotionSensorRead > 500 && AlarmActive == 0){
Serial.println("Motion Detected");
@ -309,6 +340,7 @@ void loop()
delay(100);
}
}
}//end sick
@ -321,7 +353,58 @@ void loop()
//Serve Status Page
// listen for incoming clients
EthernetClient client = server2.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html><pre>");
client.println("<b>Steak Electronics</b>");
client.println("\"Steak it easy... That is, don't overcook steak\"");
client.println("");
//client.println("<b>IP Address:</b>");
//client.println(Ethernet.localIP());
client.println("<b>Sensor Location:</b>");
client.println("Bay Four - Tool Room");
client.println("<b>Type of Sensor</b>:");
client.println("Microwave - HFS-DC06H");
client.println("<b>Temperature Sensor Value:</b>");
client.println(TEMPERATUREVALUE2);
client.println("</pre></html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}

Loading…
Cancel
Save