{"id":1425,"date":"2013-02-02T22:42:25","date_gmt":"2013-02-02T20:42:25","guid":{"rendered":"http:\/\/sickel.net\/blogg\/?p=1425"},"modified":"2013-04-03T15:39:46","modified_gmt":"2013-04-03T13:39:46","slug":"arduino-temperature-webserver","status":"publish","type":"post","link":"https:\/\/sickel.net\/blogg\/?p=1425","title":{"rendered":"Arduino &#8211; temperature webserver"},"content":{"rendered":"<p>I am using an arduino uno, an <a href=\"http:\/\/www.geeetech.com\/wiki\/index.php\/Arduino_ENC28J60_Ethernet_Module\">ENC28J60<\/a> ethernet module and a few <a href=\"http:\/\/www.geeetech.com\/wiki\/index.php\/DS18B20_Temperature_Sensor_Module\">DS 18B20<\/a> temperature sensors. Presently, it seems to be possible to connect up to 7 sensors (although I have only tested with 3) by optimizing the code a bit for memory usage, it should be possible to add some more sensors. It should not be too hard to reuse much of this to use DHT11 or DHT22 sensors, but as far as I have understood, it is not possible to run more of those on one bus. <\/p>\n<p>The temperatures may be read out in a browser or sent of as a json-string. The json-string also includes the sensors ids and a millisecond time stamp.<br \/>\nE.g.:<code>{\"temp\":[23.00,23.50,-4.00],\"address\":[\"2852932640040\",\"28A9D0264006D\",\"2895D76E40050\"],\"millis\":526288}<\/code><\/p>\n<div id=\"attachment_1435\" style=\"width: 860px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1435\" data-attachment-id=\"1426\" data-permalink=\"https:\/\/sickel.net\/blogg\/?attachment_id=1426\" data-orig-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1.png\" data-orig-size=\"490,348\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Web page snap shot\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1.png\" src=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1.png\" alt=\"The web page is pretty simple\" width=\"490\" height=\"348\" class=\"alignnone size-full wp-image-1426\" srcset=\"https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1.png 490w, https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/snapshot1-300x213.png 300w\" sizes=\"auto, (max-width: 490px) 100vw, 490px\" \/><\/a><p id=\"caption-attachment-1435\" class=\"wp-caption-text\">The web page as served from the arduino is pretty simple, Sensor 0 and 1 are measuring temperatures directly at my working desk, sensor 2 is just outside the window.<\/p><\/div>\n<p>This is just a small part of what I hope will grow up to be  a house monitoring system, adding on, among other things, devices for energy usage monitoring. I am planning to store the information in an sql database, but for the first stage testing, I am polling the server and <a href=\"http:\/\/sickel.net\/blogg\/?p=1447\">storing the results in a couchdb<\/a>.<\/p>\n<p>The sketch can be found here:<br \/>\n<a href=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/WebServer_temp_multi.zip\">Version 1.0 2nd feb 2013<\/a> or at <a href=\"http:\/\/github.com\/sickel\/tempserver\">github<\/a>. It runs well on an arduino uno, but it is close to the limit of RAM usage. Just by adding a bit more text-output, the sketch will hang. If you want to add something, look through the sketch and see what can be removed (I have some serial debug logging and depending on the needs, it may be possible to remove either the part that serves html or the part that serves json.)<\/p>\n<p>If using a newer ide than v 1.0, have a look at my description <a href=\"http:\/\/sickel.net\/blogg\/?p=1399\">how to use the ENC 28J60<\/a>.<\/p>\n<div id=\"attachment_1435\" style=\"width: 860px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/IMGP0001_small.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1435\" data-attachment-id=\"1435\" data-permalink=\"https:\/\/sickel.net\/blogg\/?attachment_id=1435\" data-orig-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/IMGP0003_smallJPG.jpg\" data-orig-size=\"850,1280\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;4.5&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;PENTAX K20D&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1359832822&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;35&quot;,&quot;iso&quot;:&quot;200&quot;,&quot;shutter_speed&quot;:&quot;0.022222222222222&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"Temperature sensors\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Two of the 18B20s can be seen. The gutted tp-cable runs to an outdoor one. (The Arduini Nano at the back end of the bread board is not in use in this project)&lt;\/p&gt;\n\" data-large-file=\"https:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/IMGP0003_smallJPG-680x1024.jpg\" src=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/IMGP0001_small.jpg\" alt=\"Setup of the system\" width=\"850\" height=\"1280\" class=\"size-full wp-image-1435\" \/><\/a><p id=\"caption-attachment-1435\" class=\"wp-caption-text\">Two of the 18B20s can be seen. The gutted tp-cable runs to an outdoor one. (The Arduini Nano at the back end of the bread board is not in use in this project)<\/p><\/div>\n<p>The data may also be forwarded to <a href=\"http:\/\/cosm.com\">cosm<\/a> (formerly known as Pachube). To get the data into the right format, make cosm call the <a href=\"http:\/\/sickel.net\/blogg\/wp-content\/2013\/02\/cosm_uploader.tar.gz\">cosm_uploader<\/a> that further back talks to the arduino. (<a href=\"https:\/\/github.com\/sickel\/homelog\/blob\/master\/cosm_102668.php\">cosm_uploader at github<\/a>). <\/p>\n<div id=\"cosm_graph\" style=\"width: 860px\" class=\"wp-caption alignnone\"><img decoding=\"async\" aria-describedby=\"caption-cosm-graph\" src=\"https:\/\/api.cosm.com\/v2\/feeds\/102668\/datastreams\/Ute.png?width=600&#038;height=250&#038;colour=%23777777&#038;duration=5days&#038;stroke_size=2&#038;show_axis_labels=true&#038;detailed_grid=true&#038;scale=auto&#038;timezone=UTC\"\/><p id=\"caption-cosm-graph\" class=\"wp-caption-text\">The last five days outdoor temperatures at my place (More data can bee seen at <a href=\"https:\/\/cosm.com\/feeds\/102668\">feed 102668<\/a>.)<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A simple Arduino based web-readable multi channel termometer. <a href=\"https:\/\/sickel.net\/blogg\/?p=1425\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"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":""},"categories":[33,1],"tags":[],"class_list":["post-1425","post","type-post","status-publish","format-standard","hentry","category-arduino","category-div"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pnVtD-mZ","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1425"}],"version-history":[{"count":31,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1425\/revisions"}],"predecessor-version":[{"id":1537,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=\/wp\/v2\/posts\/1425\/revisions\/1537"}],"wp:attachment":[{"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickel.net\/blogg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}