Summary: The idea here was to create a temperature sensor that could easily be connected to an Apple Mac computer and have it display its readings inside an OSX application. More a demonstrator than anything someone might actually use in the real world, but who knows, maybe someone out there has a practical need for such a contraption…
Contents
Objective
The objective here was to create a temperature sensor that connects to an Apple Mac over USB, and works within an Mac OSX application to display the temperature.
Background
There was not a lot of reasoning behind this project other than for it to act as a demonstrator for integrating various technologies, namely, the DS18S20 temperature sensor, a USB connection, and the Mac OS. I have thought long and hard for actual real-world uses for this device but, unfortunately, I have to conclude that there are few reasons for using it over existing temperature-measuring methods since using much simpler hardware (like a regular thermometer) would likely be the better way to go from a practical standpoint. However, for completeness and on the off-chance that someone might find this project useful or better still, some bright indivdual finds a practical use for it, here it is all the same.

Methods
Temperature Sensor:
One of the most versatile temperature sensors available to electronic tinkerers today is the Maxim DS18B20 which is a one-wire device (ie. it can be configured so that it needs only one wire to work) that has a working temperature range from -55℃ to +125℃ and its use in electronic projects is well-documented on the web. To increase the device’s usability, the DS18B20 sensor itself needed to be waterproof so that it also could be used to measure the temperature of liquids in addition to gases and solids, so it made sense to chose a pre-wired version of the sensor that had been packaged within a stainless steel enclosure.
PCB:
The circuit design was based around an ATmega168 microprocessor that polls the DS18B20 temperature sensor at regular intervals. The circuit was designed by Mathias Dalheimer and described on the Objective Development page for V-USB here. The original code is available on GitHub or a slightly modified version of it specific for this project can be downloaded below (see the File Downloads section). An LED flashes when a new temperature has been obtained and also shows the device is functioning normally. The AVR microprocessor, at the same time, runs code designed to mediate the USB functionality of the device which is based around the V-USB design by Objective Development described elsewhere. The home-made PCB was made using the photo-etch method and holds mosts of the components including the USB socket. Since the PCB was destined to be placed inside an enclosure, the LED position on the circuit board was populated with header pins instead of the LED itself, with the LED inserted into the enclosure housing and connected to the PCB using wires. The whole device derives its
power from the USB connection so it needs no external power source to operate it once it is plugged into a Mac.
Enclosure:
To be as unintrusive as possible, the enclosure housing the temperature sensor electronics was designed to be as small as possible and to just fit around the electronic parts of the USB temperature sensor circuit board. Consequently, although the PCB uses two size 4 pan-head screws to secure it to the enclosure at one end, the other end of the PCB uses the two enclosure-securing screws to hold the PCB as well as the enclosure. A cable gland appropriately size-matched to the DS18B20 sensor cable diameter was integrated into one end of the enclosure design to provide stain relief, while the USB port that provides the connection to the computer protruding from the other end.
Software:
Since I am the owner of 4 Apple Macs and only 1 PC, the question of which operating system to make the software to operate the USB temperature sensor device seemed like a no-brainer. The software for the USB temperature sensor is written for the most part in C and Objective-C and runs on Mac OSX, having been tested on OSX Capitan, Yosemite and Mavericks. One important point to note here however, is that since we are using V-USB for the USB connection to the Mac, the free-to-download libusb library also needs to be installed on the Mac computer the temperature sensor is to be used with. What is the libusb library? Well it is best summed up by a line from the libusb Wiki on Wikipedia:
“libusb is a library that provides applications with access for controlling data transfer to and from USB devices on Unix and non-Unix systems, without the need for kernel-mode drivers”
The easiest way to install the libusb library on a Mac is to use MacPorts (also free to download), which is like an installer for the Mac but implements software installations via the commandline, so MacPorts itself has to be installed if it is not already on your Mac. For one’s own piece of mind, when it comes to downloading unusual software and libraries on to one’s precious Mac, it’s always best to have a good read around the software you are about to install, especially if you haven’t heard of them or used them before. Therefore, for libusb and MacPorts, I won’t provide any detailed description of their installations but simply provide their links to more information & downloads (see the ‘Resource Links’ section below). Suffice it to say, they are trustworthy & legitimate open-source resources for the Mac, so you have nothing to fear by incorporating libusb and MacPorts into your Mac computers even if you decide later not to make use of them.
Update : Upon further investigation, I have realised that one does NOT need to install libusb (nor MacPorts) for the device to work. It appears the libusb library is automatically linked into the Mac Application when it is built in Xcode. Consequently, one just needs to download the temperature application below and connect the device, everything should work fine. I have tested everything out on 2 different Mac Minis, neither of which had libusb installed (although they did both have MacPorts installed for other projects), and the whole system has been very robust. This makes life a hell of a lot simpler!
Using the TemperatureUSB MacOS app:
Most likely your Mac OS settings will be set to prevent apps from running if they have not been signed by the developer. Since I’m doubting this app is going to be much of a hit, and since I have not yet had the time to sort out my developer ID and figure out how to sign apps so that they don’t trigger the Mac OS warning, we will have to put up with this little inconvenience. This warning is easily circumvented by going into your Mac settings panel to the ‘Security & Privacy’ tab, where if you have tried opening the app for the first time, you should be presented with the following screen prompt and button to ‘open the app anyway’:
File Downloads
Eagle files
Photo-etching file
Firmware files for the AVR
.stl files of device enclosure
USB temperature sensor Mac App
Resource Links