{"id":121,"date":"2018-12-26T16:24:59","date_gmt":"2018-12-26T16:24:59","guid":{"rendered":"http:\/\/pi.peernix.com\/?p=121"},"modified":"2018-12-26T16:24:59","modified_gmt":"2018-12-26T16:24:59","slug":"usb-temperature-sensor-with-serial-communication","status":"publish","type":"post","link":"http:\/\/peernix.com\/?p=121","title":{"rendered":"USB temperature sensor with Serial communication"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A few\nyears ago, I was spending a considerable amount of time away from my\napartment. Some of this time arose during the winter months, and I\nfound myself wanting to reduce the heating costs of the apartment,\nand therefor the temperature while I was away. Because the unit is\nadjacent to a few others, I figured that I might be able to\ncompletely shut off the heat and still maintain the temperatures\nrequired to protect the pipes from freezing and bursting. \n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because I retained an internet connection, and also a small <a href=\"https:\/\/www.newegg.com\/Product\/Product.aspx?Item=N82E16813121442\">always-on Mini ITX low power server<\/a>, I figured that I should be able to find a small USB based temperature sensor that I could connect to the server and log in to take a reading. After searching the internet for one, and being unsuccessful,  I instead went with some regular thermometers that I\u2019d have to check manually. Because I could not check them when desired, this was non-optimal.  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Not long after, I decided that perhaps I could design such a device for this task using a microcontroller, and a USB to serial converter. The \u201cSerial Temperature Sensor\u201d project was conceived.  At this point in time, I was relatively new to microcontrollers, and had really only used the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Dual_in-line_package\">DIP<\/a> version of the <a href=\"https:\/\/en.wikipedia.org\/wiki\/ATmega328\">ATMEGA328p<\/a>. I also had never used any sort of serial to USB converter, which would be required to interface the microcontroller to the PC. There are a few things that led me to use the USB to serial converter I decided on; for one, <a href=\"https:\/\/hackaday.com\/tag\/ftdi-gate\/\">FTDI gate<\/a> was in full swing, so using an FTDI serial converter was probably not a good idea. The last thing I needed were some \u201cbad\u201d chips off of Ebay that would never work. On the other hand, I was using a relatively inexpensive USB to serial programmer to write code to, and communicate with my microcontrollers. This programmer used a CH340 chip, an inexpensive Chinese converter that seemed relatively easy to use. One of the main problems though, was documentation. This was a Chinese chip, and the datasheets were in Chinese. However, there were a few basic English translations of these sheets, so I got myself a SOP breakout board, and decided to give it a go.  After a short time, I had a working setup; now time to write the code, and design the board.  <\/p>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/VmwQV0d\/Screenshot-2018-12-26-09-57-23.png\" alt=\"Screenshot-2018-12-26-09-57-23\" border=\"0\"><\/a>\n\n\n\n<p class=\"wp-block-paragraph\"> Because I wanted this to be a <a href=\"https:\/\/en.wikipedia.org\/wiki\/Dongle\">USB dongle<\/a> type device, I needed everything to be small. To do this, I\u2019d need to use as many <a href=\"https:\/\/en.wikipedia.org\/wiki\/Surface-mount_technology\">SMD<\/a> components as possible, and this would require having a PCB manufactured for me. This would also mean using components I\u2019d never used before, such as the TQFP version of the ATMEGA328P. I decided that 0805 SMD discrete components would be a good size, as they seemed manageable without being too small. I also settled on the venerable DS18b20 one wire temperature sensor. I designed a board in Kicad and had it sent off to be made, unsure of what to expect when they arrived. (not long after I submitted the design and before they arrived, I noticed I made some errors, and corrected them, and re-submitted the designs for another batch to be made, oops)  <\/p>\n\n\n\n<a href=\"https:\/\/ibb.co\/sVKM01r\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/BCySX6R\/2017-10-10-13-23-40.jpg\" alt=\"2017-10-10-13-23-40\" border=\"0\"><\/a>\n\n\n\n<p class=\"wp-block-paragraph\"> When the boards arrived, I used for the first time a method that seemed like the way to go; hot air and solder paste. This worked well, and I still use this method. For the program the device would run, I wrote a little code that would output the temperature as well as the date at a set interval, in case logging was desired. I discovered a few other errors in the board design, but things worked, and I made note of what to change for future designs. Since then, I\u2019ve used these boards for temperature logging and graphing I&#8217;ve since installed a WiFi enabled thermostat I can control from my phone, rendering their original intended purpose obsolete. However, the design and construction served as a valuable learning tool, and they are still useful in other areas where remote sensing is needed.<\/p>\n\n\n\n<a href=\"https:\/\/imgbb.com\/\"><img decoding=\"async\" src=\"https:\/\/i.ibb.co\/6W8ZK1V\/Screenshot-2018-12-26-10-03-02.png\" alt=\"Screenshot-2018-12-26-10-03-02\" border=\"0\"><\/a>\n","protected":false},"excerpt":{"rendered":"<p>A few years ago, I was spending a considerable amount of time away from my apartment. Some of this time arose during the winter months, and I found myself wanting to reduce the heating costs of the apartment, and therefor the temperature while I was away. Because the unit is adjacent to a few others,<\/p>\n<div class=\"more-link\"><a href=\"http:\/\/peernix.com\/?p=121\">Read More<\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3],"tags":[10,12,17,24,44,47,61,69,73],"class_list":["entry","author-datz","post-121","post","type-post","status-publish","format-standard","category-computerwelt","category-electronics","tag-arduino","tag-atmega328p","tag-ch340","tag-ds18b20","tag-onewire","tag-pcb","tag-smd","tag-temperature-sensor","tag-usb-to-serial"],"_links":{"self":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts\/121","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=121"}],"version-history":[{"count":0,"href":"http:\/\/peernix.com\/index.php?rest_route=\/wp\/v2\/posts\/121\/revisions"}],"wp:attachment":[{"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/peernix.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}