{"id":187,"date":"2019-02-17T13:44:48","date_gmt":"2019-02-17T08:14:48","guid":{"rendered":"http:\/\/www.jawed.in\/blog\/?p=187"},"modified":"2019-02-21T10:56:56","modified_gmt":"2019-02-21T05:26:56","slug":"instructable-temperature-logger","status":"publish","type":"post","link":"https:\/\/www.jawed.in\/blog\/instructable-temperature-logger\/","title":{"rendered":"Instructable : Temperature Logger"},"content":{"rendered":"\n<div class=\"wp-block-cover has-background-dim-30 has-very-light-gray-background-color has-background-dim aligncenter is-layout-flow wp-block-cover-is-layout-flow\" style=\"background-image:url(https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-cover-picture.jpg)\"><p class=\"wp-block-cover-text\"><strong>Cloud Based Temperature Logger &#8211; Jawed Ahmed<\/strong><\/p><\/div>\n\n\n\n<p>I have been wanting to document this instructable for quite a while. I finished the first prototype around 2 years ago and have made a few more full-fledged loggers since then. They are working properly in real life situations for more than a year now. This gives me the confidence to share the project on web.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What this accomplishes<\/h4>\n\n\n\n<p>The IoT device takes temperature data via a sensor and then using Wifi Internet saves it to a google sheet every 5 minutes. At the end of the day, the google sheet reads through the day&#8217;s data and then writes to a different sheet, the day&#8217;s max, min and average temperature. And during the course of the day, the google sheet keeps checking the real time temperature and if it exceeds the threshold at any given time then it shoots and email.<\/p>\n\n\n\n<p>The total cost for the BoM for this project is around Rs. 800 and requires an assembling time of 2 hours.<\/p>\n\n\n\n<p>We use the IoT service from Pushingbox to insert data from the logger to the google sheet.<\/p>\n\n\n\n<p>We have used the following components<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>NodeMCU<\/li><li>DS18B20 Temperature Sensor<\/li><li>TM1637 4-Digit Display<\/li><li>Connecting Wires<\/li><\/ol>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"433\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-components-ready-for-assembly.jpg\" alt=\"Components Ready for Assembly\" class=\"wp-image-189\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-components-ready-for-assembly.jpg 570w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-components-ready-for-assembly-300x228.jpg 300w\" sizes=\"auto, (max-width: 570px) 100vw, 570px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<p>This is the IoT Device. Its called NodeMCU and can be programmed via the Arduino IDE. Its available for around Rs. 350 on Amazon in India.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"436\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-Lolin-NodeMCU.jpg\" alt=\"\" class=\"wp-image-190\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-Lolin-NodeMCU.jpg 620w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-Lolin-NodeMCU-300x211.jpg 300w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<p>This is the display device. It uses 3.3v supply and is big enough to be seen clearly from around 8-10 feet. It has 4 7-segment digits.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"770\" height=\"667\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-TM1637.jpg\" alt=\"\" class=\"wp-image-191\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-TM1637.jpg 770w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-TM1637-300x260.jpg 300w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-TM1637-768x665.jpg 768w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Instruments required<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li>Soldering Iron ( for the DS18B20 Sensor which needs  a pull-up resistor<\/li><li>Insulating Tape<\/li><li>Wire Cutter<\/li><li>Computer with Arduino IDE Setup<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">High Level Design<\/h4>\n\n\n\n<p>The NodeMCU is a low-cost IoT device that has a lot of digital pins for connecting peripherals, has wifi capabilities and is powered from a easily available phone charger. The DS18B20 Sensor is connected to the devices for generating the temperature values. The TM1637 display is a small 4 digit 7-segment LED display for showing the real-time temperature. <br> The IoT device sends this data to Pushingbox API. Which in turn writes the data to a pre-configures Google Sheet.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Connection Diagram<\/h4>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"472\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-connection-diagram.png\" alt=\"Connection Diagram for the Temperature Logger using NodeMCU and DS18B20\" class=\"wp-image-200\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-connection-diagram.png 767w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-connection-diagram-300x185.png 300w\" sizes=\"auto, (max-width: 767px) 100vw, 767px\" \/><figcaption>Jawed Ahmed: Cloud Based Temperature Logger, Connection Diagram<\/figcaption><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Libraries Required<br><\/h4>\n\n\n\n<p>The NodeMCU is programmed using the Arduio IDE and uses the following Libraries<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Wifi Manager https:\/\/github.com\/tzapu\/WiFiManager<\/li><li>OneWire Library and <\/li><li>Dallas Temperature Library for the Sensor https:\/\/github.com\/PaulStoffregen\/OneWire<\/li><li>TM1637 Library https:\/\/github.com\/bremme\/arduino-tm1637<\/li><\/ol>\n\n\n\n<p>All of these libraries have to be imported into the Arduino IDE before you start compiling the code, otherwise the system will throw a lot of errors.<\/p>\n\n\n\n<p><strong>Software <\/strong><br> You need to transfer the arduino code given here to your device. The code is self-explanatory. If you use the same pin numbers which are shown in the connection diagram then you  only need to change the Device ID ( you will get this from the PushingBox website)<\/p>\n\n\n\n<p><strong>Cloud <\/strong><br> You will use two cloud services, namely Google Sheets and Pushingbox API.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"650\" height=\"421\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-pushingbox.png\" alt=\"\" class=\"wp-image-193\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-pushingbox.png 650w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-blog-temperature-logger-pushingbox-300x194.png 300w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/figure><\/div>\n\n\n\n<p>We have to use PushingBox as a intermediary between the IoT device and the Google sheet as, Google requires a https (secure) connection and currently there is no reliable way to make a https connection from the NodeMCU. So the IoT device connects to the PushingBox API service and this service in turn connects to the Google Sheets and inserts the data.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"511\" height=\"139\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/schematic.png\" alt=\"\" class=\"wp-image-204\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/schematic.png 511w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/schematic-300x82.png 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><figcaption>PushingBox converts the unsecured connection to an secure connection, which is required by Google Sheet<\/figcaption><\/figure><\/div>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Steps(Hardware Preparation)<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>Prepare the Temperature sensor by connecting the 4.7k resistor between the positive wire and the data wire<\/li><li>Solder the open ends of the connecting wires to the sensor.<\/li><li>Connect the other three ends of the connecting wire to the NodeMCU<\/li><li>Connect the TM1637 display to the NodeMCU using 4 wires.<\/li><\/ol>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"620\" height=\"673\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-pullup-resistor-DS18B20.jpg\" alt=\"\" class=\"wp-image-194\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-pullup-resistor-DS18B20.jpg 620w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-pullup-resistor-DS18B20-276x300.jpg 276w\" sizes=\"auto, (max-width: 620px) 100vw, 620px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"420\" height=\"320\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-soldering-connector-to-DS18B20-Sensor.jpg\" alt=\"\" class=\"wp-image-195\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-soldering-connector-to-DS18B20-Sensor.jpg 420w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-soldering-connector-to-DS18B20-Sensor-300x229.jpg 300w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Steps on the Cloud<\/h4>\n\n\n\n<ol class=\"wp-block-list\"><li>Create a new Google Account and then login.<\/li><li> Open the Google Sheets and create the sheet as shown<\/li><li> Using the same credentials as Google, login to Pushingbox and create a scenario to get your Device ID<\/li><\/ol>\n\n\n\n<p><strong>Steps to be followed on Arduino<\/strong><\/p>\n\n\n\n<p>Replace the Device ID mentioned in the Arduino code with the new Device which you got from Pushingbox.Transfer the code to NodeMCU<\/p>\n\n\n\n<p>On first boot, it will create a local Access Point to which you can connect from your  phone and then enter the WiFi credentials. When it boots the next time, you will notice that the access point does not start and it automatically connects to Internet using the username\/password which you entered earlier.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"520\" height=\"395\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-within-Enclosure.jpg\" alt=\"\" class=\"wp-image-196\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-within-Enclosure.jpg 520w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-within-Enclosure-300x228.jpg 300w\" sizes=\"auto, (max-width: 520px) 100vw, 520px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<p>Now you can login to the Google Sheets and see that the data is being inserted every 5- 6 minutes like shown below.<\/p>\n\n\n\n<p>That is all.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"566\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/Google-Sheet-screengrab.png\" alt=\"\" class=\"wp-image-197\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/Google-Sheet-screengrab.png 979w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/Google-Sheet-screengrab-300x173.png 300w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/Google-Sheet-screengrab-768x444.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><figcaption>Google sheets showing the Temperature Logger Output<\/figcaption><\/figure><\/div>\n\n\n\n<p>This is the image of the finished Temperature Logger<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"1020\" height=\"809\" src=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-finished-project.jpg\" alt=\"\" class=\"wp-image-198\" srcset=\"https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-finished-project.jpg 1020w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-finished-project-300x238.jpg 300w, https:\/\/www.jawed.in\/blog\/wp-content\/uploads\/2019\/02\/jawed-temperature-logger-finished-project-768x609.jpg 768w\" sizes=\"auto, (max-width: 1020px) 100vw, 1020px\" \/><figcaption>Jawed Ahmed : Cloud Based Temperature Logger<\/figcaption><\/figure><\/div>\n\n\n\n<p>Please download the source code from these links.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">IoT Code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;ESP8266WiFi.h>\n#include &lt;TM1637Display.h>\n#include &lt;ESP8266WebServer.h>\n#include &lt;WiFiManager.h>         \/\/https:\/\/github.com\/tzapu\/WiFiManager\n#include &lt;OneWire.h>\n#include &lt;DallasTemperature.h>\n\n\n\/\/const int CLK = D6; \/\/Set the CLK pin connection to the display\n\/\/const int DIO = D5; \/\/Set the DIO pin connection to the display\nconst char WEBSITE[] = \"api.pushingbox.com\"; \/\/pushingbox API server\nconst String devid = \"DEVICEID FROM PUSHINGBOX\"; \/\/device ID from Pushingbox \nunsigned int loopcount = 0;\n\n#define ONE_WIRE_BUS 2  \/\/this is the pin to which the data wire of DS18B20 is connected (IMP:2 corresponds to physical pin D4!!!)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Google Script Code<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>function doGet(e) { \n  Logger.log( JSON.stringify(e) );  \/\/ view parameters\n\n  var result = 'Ok'; \/\/ assume success\n\n  if (e.parameter == undefined) {\n    result = 'No Parameters';\n  }\n  else {\n    var id = 'GOOGLE SHEET ID';\/\/docs.google.com\/spreadsheetURL\/d\n    var sheet = SpreadsheetApp.openById(id).getActiveSheet();\n    var newRow = sheet.getLastRow() + 1;\n    var rowData = [];\n    \/\/var waktu = new Date();\n    rowData[0] = new Date(); \/\/ Timestamp in column A\n    <\/code><\/pre>\nTags: <a href=\"\/blog\/tag\/arduino\/\">Arduino<\/a>, <a href=\"\/blog\/tag\/jawed-ahmed\/\">Jawed Ahmed<\/a>, <a href=\"\/blog\/tag\/nodemcu\/\">NodeMCU<\/a>, <a href=\"\/blog\/tag\/temperature-logger\/\">Temperature Logger<\/a><br>","protected":false},"excerpt":{"rendered":"<p>I have been wanting to document this instructable for quite a while. I finished the first prototype around 2 years ago and have made a few more full-fledged loggers since then. They are working properly in real life situations for more than a year now. This gives me the confidence to share the project on [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":198,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[13,14,11,12],"class_list":["post-187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","tag-arduino","tag-jawed-ahmed","tag-nodemcu","tag-temperature-logger"],"_links":{"self":[{"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":9,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"predecessor-version":[{"id":210,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/posts\/187\/revisions\/210"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/media\/198"}],"wp:attachment":[{"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jawed.in\/blog\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}