Assembled Serial Temperature Measurement - TM #127A

Two Run to Multiple DS18S20 / DS18B20 and Single TTL Output

Peter H. Anderson
915 Holland Road, Bel Air, MD 21014,

Note. Prior to May 28, '04, the TM #127 could interface only with the DS18S20 (and older DS1820). It is now capable of interfacing with the DS18B20 as well. The unit is now identified as TM #127A.

For users who wish an updated PIC, it is $3.00.


This is an assembled unit which interfaces with a PC COM port and provides the capability of measuring the temperatures at each of several DS18S20 (or DS18B20) on each of two twisted pair runs. It also provides a single TTL output which may be set high or low. The package includes an assembled printed circuit board, a 12 VDC wall power unit, a six foot serial cable (DB9) and a single DS18S20. Additional DS18S20s and DS18B20s may be purchased separately.

In theory, up to 256 DS18S20 (or DS18B20) temperature sensors may be accommodated each of the two twisted pairs. However, the limiting factor is the capacitance and my suggestion is up to sixteen DS18X20 devices on a maximum of 200 feet of twisted pair cable on each of the two runs.

The PCB is professionally fabricated.

The module includes a female DB9 connector, RS232 level shift circuitry, an on-board 5 VDC supply, a Microchip PIC processor and a six conductor screw type terminal block. There are four holes on the PCB to permit the user to mount the module in a box or on a plate. Four one-half inch nylon spacers and associated 4-40 pan head screws are provided.

Note that this is the documentation for this module. No additional paper documentation is shipped with the unit.

The module is 1.5 X 2.1 inches.


The intent is designing modules such as this is to involve my undergraduate students in meaningful design experiences, while at the same time providing useful low cost products for hobbyists and tinkerers.

In the spirit of this activity, I don't want people buying items that do not work for them or do not meet their expectations. Thus, this unit may be returned at any time for a full credit.

Detailed Description.

The PC interfaces with the temperature measurement and single output module using 9600 baud, 8-bits, no Parity, either 1 or 2 stop bits, no flow control.

The command structure is relatively simple. Commands issued by the PC are "H" (high), "L" low, "S" (status) and "T" (temperature).

The "H" command causes the single output to go high (near +5 VDC). The processor echoes the command followed by the state of the output.

The "L" command causes the single output to go to low (near ground). The processor echoes the command followed by the state of the output.
The "S" command causes the processor to read the status of the single output and return its state.
The "T" command causes the processor to find each temperature sensor on each of the two twisted pair runs and perform a temperature measurement.

The processor echoes the command followed temperature measurements.

	1 00 27.55 10D6F33A 00000036
	1 01 26.67 10773B3B 000000CE
	2 00 -5.26  etc
	2 01 105.04 etc
Note that in this example, four devices were found, two one run 1 and two on run 2 As each was found, it was assigned a sequential number in the range of 00 - ff. This is followed by the temperature in degrees C, followed by the unique 64-bit serial number expressed in hexadecimal.

If no sensor is found on the designated run, the command is echoed, but no other data is returned.

Note that fields are delimited by single spaces and the line is terminated by a new line consisting a CR and LF.

The range of the temperature is -55.00 to 125.00 degrees C. The unit provides a resolution of 0.03125 degrees C. Please refer to the DS18S20 and DS18B20 data sheets at Dallas Semiconductor for absolute accuracy over the full temperature range.

The serial numbers of the devices are provided to permit the user to ascertain which sensor is which. Note that the two digit device number DD is simply a running number beginning at 00 which is assigned as each device is found using a binary search on each of the twisted pair runs.

Thus, 00 might correspond to a DS18S20 in your PC, 01 to the living room, 02 to the freezer. Assume you then add one on a cold water pipe in the basement. You may well find 00 is still your PC, but 01 is now the water pipe, 02 is the living room and 03 in the freezer.

However, note that once a system is in place, 00 will always be the PC, 01 the water pipe, etc. But if your cat pulls off the sensor in the living room, 02 will then be the freezer.

If you don't wish to use the serial number information, you might consider initially connecting the sensors on a breadboard and use your finger to determine which device is 00, which is 01, etc and then label each of the sensors and then install them with 00 in the PC, 01 in the living room, etc.

Note that all DS1820 devices are operated in the parasitic power mode (the DS1820s use the signal lead for power) and thus a single twisted pair may be multipled from one device to the next.

The PIC is theoretically capable of finding and measuring the temperature of each of 281,000,000,000,000 devices on the single twisted pair run. However, the limiting factor is the capacitance of the cable and the capacitance of each DS1820. My guesstimate is that 16 devices on a total of 200 feet of twisted pair is realistic. Note that the use of the parasitic power mode does not limit the amount of cabling nor the number of devices.

Setup and Test.

The layout of the screw type terminal block is shown with the PCB oriented such that the power connections are at the lower left. The unit is shipped with small lengths of wire of various colors to aid in identifying the functions.

White - TTL ouput
Blue - Reset.  Momentarily GRD to reset the processor.  This should not normally be necessary.
Yellow - DQ lead for one Dallas twisted pair run
Yellow - DQ lead for the other run
Black - Ground
Red - +5 VDC output.  Limit drain to 25 mA.

When making or changing connections to the terminal block it is suggested that the unit be powered down.

Connect the module to a PC COM Port using the DB9 serial cable.

Use a terminal emulator such as HyperTerm which is provided as a free accessory with Windows to establish a a direct connection to the COM port at 9600 baud, eight data bits, no parity, and no flow control.

Power the unit by plugging in the wall power unit. Observe the power on LED.

When the unit boots either by applying power or resetting the processor via the blue terminal on terminal block 2, a brief one-line screen message will be sent to the PC which is an advertisement, but also includes the date the firmware was last modified. A prompt (">") is provided.

To test the single output, connect a voltmeter between the TTL output (white lead) and GRD (black lead).

Use the PC to issue the "H" and "L" commands and observe voltage levels of near +5 VDC and near 0.0 VDC. Send the "S" command to determine the state of the output.

Connect a DS18S20 to the twisted pair as shown;

Screw Terminal Block		DS18S20 or DS18B20

Yellow DQ ------------- DQ (term 2) --------------- To other DS18S20 / DS18B20 devices
Black GRD ------------- GRD (terms 1 and 3) ------- To other DS18S20 / DS18B20 devices


1. This module is distributed with a programmed PIC which is code protected. The source code written in PIC C from CCS Info is available for $1500.00.

2. The firmware associated with this design is a rework of our "Serial Temperature Measurement System (8-pin DIP) Kit". However, the PICs are not interchangeable.

3. The processor which was used in this device does not have a hardware UART. Thus, while the processor is performing a task such as performing a temperature measurement sequence, the processor will not see any commands which are sent by the PC. The interfacing processor or similar should wait until prompt (">").

3. This design uses a calibrated RC clock inside the PIC microcontroller (as opposed to an external crystal or resonator). In reviewing the specifications, this appears more than sufficiently accurate to perform the timing involved in communicating with the PC. If it isn't, this will be apparent with all kinds of control characters appearing on your terminal. By all means, if this happens, return it to me. I honestly do not feel this will be a problem. 4. The single output is a TTL level capable of sourcing and sinking up to 12 mA.

5. A source of +5VDC is available at the terminal block (red lead). This should be used judiously and the current should not exceed 25 mA. This may be used to power a small amount of peripheral circuitry.

6. Several years ago, Dallas marketed a DS1820 in a PR35 package (an elongated TO-92 transistor). They then replaced this with the DS18S20 in a TO-92 package. However, for whatever reason, Dallas marks these parts as DS1820. This design is compatible with both as well as the DS18B20. All may be accommodated on twisted pair.

7. The limiting factor on the amount of cable and the number of DS18S20 devices which can be accommodated on a single twisted pair run is the capacitance associated with the cable and to a much lesser extent, that associated with the devices. In all probability, you can exceed my 200 foot recommendation. However, recognize that at some point, the measurements will fail and this will include both DS18X20 units which are close to and far from the module.

Note that my 200 foot recommendation is 200 feet total. Thus you might have a single 200 foot twisted pair or two 100 foot pairs or five 40 foot pairs in a star configuration.

Ordering Information. Please order as Temperature Module TM #127.