logo1.bmp (61374 byte)

build a DS1621 pc thermometer

simple

no calibration

no microcontrollers

 

So cool you can measure it!

This incredibly simple thermometer plugs on any free serial port. Does not make use of any programmable components as microcontrollers. It gives temperature readings accurate to 0.5C with no calibration. It's cheap, so I've put one on any PC I use. And it's soooo nice to have the temperature shown on the Windows taskbar, that a million friends asked me to build one!

Build yourself an accurate thermometer

Since I have no time to build a million pcTHERMs, I give you the plans and the software to build one on your own.
This project is easy enough for beginners, the only difficulties possibly arising from serial port hardware incompatibility from PC to PC. In the single-sensor version, you need only the sensor IC, a voltage regulator and and handful of diodes and resistors. Build it, and learn the secrets of IIC bus, how to implement IIC bus using only two resistors and a couple of zeners, how to drive it on a serial port using Visual Basic    .Components involved are available on the worldwide RS-components catalogue. 

Tech facts:

  • displays both indoor and outside temperature on the Windows taskbar (see figure)
  • plugs in any free PC com port
  • range -20 ... +125C   (-4 ... 257F)
  • basic accuracy and resolution 0.5C
  • Centigrade (C) of Farenheit (F) scale
  • data logging on easily readable text file (good for Excel)
  • sampling rate 1, 5, 30 or 60 seconds
  • one or two temperature sensors (upgradeable up to 8)
  • com port powered, no external power supply required
  • easy to build, no exotic nor programmable parts inside
  • no calibration required
  • full source code available for free (educational and non-commercial uses only)

therm_logo.gif (6521 byte)

temperature as shown on the Windows taskbar

Circuit diagram

thermometer schematics  (9 kB .gif file)

Making your PC-therm, SMT style

Building PCtherm is easy. I’ll detail the version using surface-mount parts. Those not familiar soldering oh-so-tiny SMT parts will be happy to know that a PCB layout for through-hole parts is also available.
First step is to collect all of the parts except the PCB. This is the parts list:

     
SMD version
Thru-Hole version
Reference
Type
Description
RS code
RS code
U1,U2 DS1621 or DS1631
(Dallas Semiconductor)
Digital temperature sensor
SO8 plastic case (SMD) or DIP (Thru-hole)
294-0994
218-3826
U3

LM2936Z-5.0
(National Semiconductor)

Ultra low dropout voltage regulator, TO92 case (both versions)
533-5604
533-5604
D1,D2 LL4148 Small signal diode (like 1N4148)
652-7494
544-3480
DZ1, DZ2 MMSZ5V1 5.1 Volts Zener diode 0.5 W
544-9753
544-3597
C1,C2 47 uF/16V Electrolytic capacitor
537-0180
414-9036
C3,C4 100nF Low voltage ceramic capacitor (SMD case size:1206)
434-8104
538-1635
R1,R2 4700 ohm 5% 0.25W resistor (SMD case size:1206)
223-2350
135-904
COM DB9F 9-pin female connector, straight (SMD) or angled (Thru-Hole)
480-3976
495-9855

And this is the enalrged assembly view of the SMT board (the small PCB is the optional outdoor sensor).

As soon as I collect all of the parts, I make a real-size printout of the PCB in order to verify dimensions of all parts against it. Should a part be too big or small to match its PCB pads, I can adjust PCB layout or try to findia compatible part before the hard work starts.  

Once all parts are verified, I prepare the PCB. As the SMT layout is single-sided, you can easily etch one yourself. It takes less than an hour and no special materials with the method described here.
The PCB must be spotlessly clean (no trace of oxidation of fingerprints) in order to etch and solder well. Clean it with a mild abrasive until shiny (kitchen scrubs, steel wool, and even a pen eraser work).
Remember to use the mirrored track layout for toner-tranfer! I love SMT prototypes because there aren't too many hole to bore before soldering begins.

 

Soldering requires a fine-tip iron, sharp tweezers and a steady hand. I tape the board to the desk to keep it in place while soldering. Actually, I tape it to the parts layout printout so its easier to check during soldering.
In order to avoid inadvertent swaps, keep parts in their original packaging until needed. I suggest you to start soldering smaller parts (resistors, diodes…) and to end with the cumbersome ones (electrolytic), as tall components can make difficult to access and solder small part’s pins.

 
Don’t apply too much solder, and be careful not to overheat parts (especially diodes and ICs). If necessary, let the part cool down before reworking. Most parts are polarised so be careful not to reverse them. Diode’s cathode (K) is marked by a black ring, and electrolytic capacitors negative pin is designated by a black strip. If you prefer to use tantalum capacitors, remember that their marking is reversed, with the black strip designating the positive leg!
Keep an eye on the photos and check twice whenever you spot any difference.

 
Those inexperienced with hand soldering SMT parts might be concerned soldering sensor ICs.
I clean soldering iron tip before each solder joint, and use smallest diameter soldering alloy in order to apply as little solder as possible. I start applying a very small quantity of solder on the pad designed for pin 1 ONLY.
I place the IC over the pads, and when all pads are perfectly aligned I clean the tip and put it on pin 1 until it gets soldered. I verify that the IC is still correctly positioned (all pins centered and touching their respective pads). If it moved, I heat up pin 1 and restart, otherwise I continue soldering remaining pins, always cleaning soldering iron’s tip before each joint and applying very little solder. Last step is soldering again pin 1 as its initial joint was made with very little solder.
 
The LM2936Z5 voltage regulator needs special preparation for soldering. I had a through-hole part at hand, but I wanted it to solder on the SMT side of the board. The picture should make it clear how to bend and cut its pins for this purpose.  
The PCB is designed to fit between the pins of the serial port connector. This is the last part to solder. Don’t forget to bridge its pin 7 and 8 on the opposite side of the PCB.
I usually clean residues of solder flux with a solvent like acetone, letting the circuit to dry completely before powering it. Once the board is tested and working, I apply a coat of spray clear varnish to protect the copper from oxidation.
 
Last step is to download and install the software. If you get confused by Microsoft Installer prompts (...in Italian) these screenshots (first and second) should make it clear.
On first run, you need to select the serial port number where the circuit connects, and you're ready to take temperatures. Have fun!
 

software screen shot (4,3kB)

pcTherm window expanded

 

In depth: how it works

The circuit is derived from the Claudio Lanconelli's PONYPROG programmer. The key component is Dallas Semiconductor's DS1621 temperature sensor. It is a digital temperature sensor, meaning that it measures the temperature transforming it in a digital value (a binary number, that is a sequence of zeroes and ones as the bytes in your computer).

Just apply 5V stabilized power, and the DS1621 is capable to transmit ambient temperature via an IIC (Inter-Integrated Circuit bus, also written I2C) serial bus. This is a standard transmission scheme developed by Philips Semiconductors for connecting a moltitude of ICs together using just two wires: a clock wire (SCL) and a data wire (SDA).

See the references for more details about how the bus works; for now, it is sufficient to know that any I2C chip has its own address (a number in the range from 0 to 127) and command set. So you can connect many ICs in parallel and still be able to talk to each one individually starting each message with the relevant address.

Right from the factory, all DS1621 are shipped with the same a base address ($40), but you can customize it, connecting the address pins (A0, A1, A2), to 5V or GND respectively (see table). So you can connect up to 8 sensor chips in parallel on the same bus, although supplied sofware supports only the firts two in the table (you can add more sensor changing the software).

So we can power the DS1621 with 5Vdc and connect its SCK and SDA wires to PC's I2C interface, right? Unfortunately, PCs don't have 5Vdc power outlets and I2C ports, so we need to hack 'em!

 

pin A2
pin A1
pin A0
resulting address
chip
GND
GND
GND
$48
board sensor
GND
GND
+5V
$49
optional external sensor
GND
+5V
GND
$4A
not used
GND
+5V
+5V
$4B
not used
+5V
GND
GND
$4C
not used
+5V
GND
+5V
$4D
not used
+5V
+5V
GND
$4E
not used
+5V
+5V
+5V
$4F
not used

DS1621/DS1631 address selection table

Hack #1: COM-port phantom power

The temperature sensor does'nt require much power to work, so why not to eliminate the need for a power supply "stealing" that power from the signals already available on the RS232 port?
The +12V from the RS232 lines are conveyed to the regulator by diodes D1, D2, filtered by C1 and regulated to +5V by the LM2936-Z5. This is a special regulator capable to work with minimal input voltages and conserving every mA of current. The LM2936 is capable to regulate with an input voltage as low as 5.2V (most serial port supply only 6V). By comparison, ordinary 78L05 regulators need at least 6.7 volt as input and consume 100 times the current needed by the LM2936-Z5.

Hack #2: Making a COM-port to pretend it's an I2C-bus

PC-therm software emulates the I2C-bus wires driving two pins of the COM port available in all motherboards.
The SCL wire is implemented driving the RTS signal (Request To Send, pin 7), while the SDA wire uses the wire originally designed for serial port's DTR (Data Terminal Ready, pin 4). These signals are accessible from Visual Basic setting the DTR and RTS properties in the MsComm object.
You can't connect COM port signal to the DS1621 directly, as the voltage levels need to be adapted. As required by EIA-RS232 standards, most PCs output voltages as high as +15Vdc and as low as -15Vdc on their COM port connectors, so we must limit them to the more confortable 0 to +5Vdc level before connecting to DS1621 SDA and SCL pins.
A 5.1V zener diode and 4700 ohm limiting resistor are sufficient for this purpose.
If you look the schematic closely, you'll notice that the SDA pin connects also to the CTS pin (Clear To Send, pin 8). This way PC-therm software can monitor SDA logic level to read chip responses, making this wire bidirectional. Although theoretically serial ports require a negative swing of the inputs, signals in the range 0...5Vdc work equally well on practically every PC on earth.

 

The software

The software comes precompiled and with an installer (setup.exe), but for those interested in programming the source code is included.

I wrote the software in Visual Basic. I've done it the straight way, intentionally avoiding optimizations that would make it less readable. This is no limitation, as the I2C-bus runs at a respectable 1,5 kHz even on the slowest machine I tried (P90 in interpreted mode).
The I2C-bus functions are grouped in a file that can be reused for other applications. It provides functions for all the basic I2C-bus operations: like starting and stopping the bus, or sending and receiving single byte.

The main program implements a function, temperature( chipaddress ), that issues the I2C-bus commands to get a temperature from a chip.
To read chip temperatures from Visual Basic, all you need is to call
temperature( $&48 ) , where $&48 is the address for the first chip, $H49 is the address for the second chip, and so on according to the table above. My software uses two sensors, but it is not difficult to modify it to support up to 8 chips.

The very first time you run the program, you will be warned that the configuration file does not exists (it will be automatically created at the end of the session) and defaults will be used for configuration. Select the serial (Com) port you use, if your device includes the U2 for reading the outdoor temperature, the interval between successive measurements, the measuring unit and if you want to log temperatures on the file "pc_thermometer.txt" (an ASCII text file you can import in Excel for processing or making graphs).

Checking the "start minimized" box, on successive run the program won't open the window on the desktop, instead it runs minimized on the taskbar, providing a "temperature icon". This is my preferred way to use it, just like the "clock" icon provided with Windows.
Clicking on the icon opens up the window again.

Files available:

Software installer and Visual Basic sources (VB5 or VB6) (1,5 MB) includes also most pdf's (PCB, schematics...)

Printable schematic diagram (pdf file)

Printable PCB tracks of SMD version (1:1 scale pdf file) also as mirrored view for toner-transfer

Parts layout of SMD version (pdf file)

PCB and schematic, using through-hole components of the single-channel simplified version (fixed .pdf file from a Czec site wich originally missed the connection between VDO and +5V)

Schematic for a 4-sensor setup and instructions for connecting up to 8 sensors. You need to change the software to make it read the new sensors - some programming skills required.

Schematic for an USB-powered version in case you can't find the LM2936Z5, courtesy of James Maloway

Be sure to check the FAQ page for further information about the thermometer.

 

PCB using through-hole parts.

 

References:

Using the I2C Bus, a C software implementation and explanetion

Official I2C bus specification by NXP (formerly Philips) semiconductors. They keep changing company name, site and position, but you can Google for "I2C bus specification".

IIC bus definition on Wikipedia


Interesting links:

PCTherm software ported in JAVA language (in italian only)

WEBTHERM, Claudio's WEB accessible thermometer

A C-language Linux software

Interfacing the DS1621 to a Basic Stamp

Interfacing the DS1621 to a PIC16F84

A thermometer in C with 7-segment displays and AVR 2313

A thermometer in JAL with LCD using the PIC16F84

Send temperatures in ASCII over the serial port: C sources for PIC16F84

Another serial port thermometer using the DS1820

An RS485 network node using C and a PIC16F84

 

 

home

nutchips

designs f.a.q.

provokations

crc guide who am I ? awards
home | nutchips | designs | f.a.q. | provokations | crc guide | who am I ? | awards