USB temperature sensor with Serial communication

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, I figured that I might be able to completely shut off the heat and still maintain the temperatures required to protect the pipes from freezing and bursting.

Because I retained an internet connection, and also a small always-on Mini ITX low power server, 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’d have to check manually. Because I could not check them when desired, this was non-optimal.

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 “Serial Temperature Sensor” project was conceived. At this point in time, I was relatively new to microcontrollers, and had really only used the DIP version of the ATMEGA328p. 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, FTDI gate was in full swing, so using an FTDI serial converter was probably not a good idea. The last thing I needed were some “bad” 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.


Because I wanted this to be a USB dongle type device, I needed everything to be small. To do this, I’d need to use as many SMD components as possible, and this would require having a PCB manufactured for me. This would also mean using components I’d 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)


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’ve used these boards for temperature logging and graphing I’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.


Leave a Reply

Your email address will not be published. Required fields are marked *