Portal for car enthusiasts

Description of ds1621. Temperature sensor DS1621

Schematic diagram of a homemade thermostat, which is designed to work with a heating system based on an electric boiler. The circuit is based on the DS1621 chip. The DS1621 is a digital I/O thermometer and thermostat with an accuracy of ±0.5°C.

When used as a thermometer, the data is read out via l2C/SMBus serial bus in 9-bit complementary code with a low order value of ±0.5°C.

For applications requiring higher resolution, the user can read additional registers and perform simple arithmetic to achieve more than 12-bit resolution (with a LSB cost of 0.0625°C). The DS1621 chip provides 3 addressable inputs to allow users to connect up to 8 DS1621s to a single bus.

When used as a thermostat, the temperature to be maintained is stored in the internal non-volatile memory (EEPROM) in the form of user-defined over-temperature (TH) and under-temperature (TL) setpoints. The difference between TH and TL forms a hysteresis.

When the temperature is insufficient (TL and below), pin 3 of the microcircuit is set to a low logic level. When the temperature is sufficient (TH and above), this output is a logical unit.

The DS1621 is available in 8-pin PDIP and 8-pin SOIC packages.

circuit diagram

Figure 1 shows the connection diagram of this microcircuit to a personal computer.

Rice. 1. Schematic diagram of a thermostat for an electric boiler.

The software with which the thermostat according to Fig. 1 will work together with a personal computer can be found in, download the program - Download (1.5 MB).

After setting the temperature using a personal computer, it can be disconnected from the circuit in Fig.1. The given data will be stored in the memory of the microcircuit, and this circuit will work independently, maintaining the set temperature with the help of the triac VS1, controlling the power supply of the heater of the heating boiler.

Rice. 2. Thermostat circuit on the ATTINY2313 microcontroller.

The computer can be successfully replaced with a microcontroller-based control and monitoring circuit, for example, the ATTINY2313 circuit shown in Figure 2. This is a complete stand-alone device that can maintain a room temperature within 10 to 40 degrees Celsius, and at the same time serve as a thermometer showing the specific temperature in the room.

The temperature is displayed on a two-digit LED digital display. Three button control. S1 is used to turn the thermometer on and off.

And with buttons S2 and S3 you can set the temperature that you want to maintain. The HL1 LED is used to indicate the on state of the electric boiler. When the heating element of the boiler is working, it flashes.

Firmware MK

The HEX file for programming the microcontroller is located at this link: Download (1.9 KB).

The microcontroller works with a built-in 4 MHz oscillator. When programming in Features, you need to select:

int. RC Osc. 4MHz; Start-up time: 14 CK + 0 ms;

Brown-out detection disabled; check the box Serial program downloading (SPI) enabled;

Fuses: (tick) SUT1, SPIEN, SUTO, CKSEL3, CKSEL2, CKSELO

Details

The assembly was carried out on breadboard printed circuit boards. Transformer T1 - ready-made transformer "TAIWAN 110-230V 6-0-6V 150tA", power, low-power, with a secondary winding of 6V. Rather, it has two secondary windings 6-0-6V and current up to 150tA, connected in series. Only one winding is used here. The primary winding is 230V, but contains a tap for 110V.

It is necessary with an ohmmeter to select the terminals of the primary winding with the greatest resistance between them, and connect them to the mains. ALSZZZA LED indicators are quite old. They can be replaced by any seven-segment common cathode digital LED.

Kozhukhin V. A. RK-08-16.

Literature: 1. Thermometer for PC on DS1621 - cxem.net/mc/mc136.php.

The device is simple, without calibration and microcontrollers.

This incredibly simple thermometer connects to any available serial port. The device does not use any programmable components and microcontrollers. Measurement accuracy is up to 0.5°C without calibration. It's so cheap that I've made one for every computer I use. It's so nice to have a temperature on the Windows taskbar that many friends asked me to make such a device!

Make yourself an accurate thermometer

D This project is easy enough for beginners, only there may be difficulties associated with hardware incompatibility of the serial port on different computers. The single sensor version only needs a sensor chip, a voltage regulator, and a few diodes and resistors. Do it and learn the secrets of the IIC bus, how to implement an IIC bus using only two resistors and a couple of zener diodes, how to control it on a serial port using Visual Basic. The components used are readily available in .

Characteristics:
The temperature is displayed both on the Windows taskbar and outside it (see figure).
Installed in any free PC COM port.
Measuring range -20 ... +125°C (-4 ... 257°F).
Basic accuracy and resolution 0.5°C.
Celsius (°C) and Farenheit (°F) scale.
The data is written to an easily readable text file (good for Excel).
Sample rate 1, 5, 30 or 60 seconds.
One or two temperature sensors (expandable to 8)
Powered by COM port, no external power required.
Easy to do, no exotic software and hardware parts.
Does not require calibration.

Making a PC thermometer is easy. I will describe in detail the version with surface mount elements. Those unfamiliar with soldering small SMT elements will be happy to know that a lead board is also available.

First you need to collect all the elements except for the boards. Here is the list of elements:

Number

Description

DS1621 or DS1631

Digital temperature sensor
Plastic case SO8 (SMD) or DIP (Output)

Ultra low loss voltage regulator, TO92 package (in both versions)

Small switching diode (like 1N4148)

Zener diode 5.1V 0.5W.

electrolytic capacitor

Low Voltage Ceramic Capacitor (SMD 1206)

Resistor 0.25W (SMD 1206)

9-pin female connector, straight (SMD) or angled (Pull-out)

This is an enlarged view of the assembled SMT board (The small board is a remote temperature sensor).

Once I collected all the elements, I printed out the board in its actual size to check the dimensions of all the elements relative to it. If the element is too big or small, I can fix the board or look for a suitable element before starting work.

After all the elements are checked, I make a payment. Since it is single sided, you can easily etch it yourself. It takes less than an hour and does not require any special materials according to the method described here.

The board must be spotlessly clean (free of oxidation and fingerprints) for good etching and soldering. Wipe it with a soft abrasive to a shine (kitchen washcloth, steel wool and even an office eraser). Don't forget to mirror the board before printing! I love SMT boards because there aren't many tedious holes to drill before soldering.

Soldering requires a soldering iron with a thin tip, sharp tweezers and a steady hand. I fix the board to the table while soldering. I'm actually attaching it to the printout to make it easier to check while soldering.
In order not to accidentally mix up the elements, keep them in their original packaging until needed. I suggest you start with small items (resistors, diodes...) and end with large ones (electrolytic capacitor), tall items can make small items difficult to access.

Don't apply too much solder, and be careful not to overheat the components (especially diodes and ICs). If necessary, let the element cool down. Most of the elements are polar, so be careful not to mix them up. The cathode of the diode (K) is marked with a black ring, the negative terminal of the electrolytic capacitors is marked with a black stripe. If you prefer to use tantalum capacitors, remember that their markings are reversed, and the black stripe indicates the positive terminal!

Keep an eye on the photo and always double check until you are sure there is no difference.

Those with no experience in SMT soldering may be concerned about soldering the sensor IC.
I clean the tip of the soldering iron before each soldering point, and use very fine solder to apply as little solder as possible. I apply a small amount of solder only to the pad designated for pin 1.

I put the chip on the board, and when its leads line up with the pads, I clean the tip and heat pin 1 until it is soldered. I check that the chip is still properly positioned (all pins are centered on their respective pads). If it has moved, I heat up pin 1 and move it, or I still solder the rest of the pins, cleaning the tip and using little solder. The last step is to solder pin 1, initially soldered with very little solder.

The LM2936Z5 voltage regulator needs special preparation for soldering. I had through holes but wanted to solder it on the SMT side of the board. The figure shows how to bend and shorten the contacts.

The printed circuit board is designed to fit between the pins of the serial port connector. This is the last part of soldering. Don't forget to solder pins 7 and 8 on the opposite side of the PCB.
I usually clean the board of flux residue with a solvent like acetone and let the board dry completely before turning it on. Once the board is tested and working, I apply a coat of clear spray varnish to protect the copper from oxidation.

The last step is to download and install the software. If you are confused by the Microsoft Installer prompts (... in Italian) these screenshots (first and second) will help you get it right.

When you first start, you must select the serial port number to which the circuit is connected, and you will be ready to receive the temperature. Good luck!

How it works?

The circuit is derived from the programmer Claudio Lanconelli PonyProg. The key component is Dallas Semiconductor's DS1621 temperature sensor. This is a digital temperature sensor, which means that it measures the temperature and converts it into digital values ​​(binary numbers, that is, a sequence of zeros and ones, like bytes in a computer).

Simply apply a regulated 5V power supply and the DS1621 is capable of transmitting ambient temperatures via the IIC (Inter-Integrated Circuit Bus, also spelled I2C) serial bus. This is a standard transfer scheme developed by Philips Semiconductors for connecting many chips together using just two lines: clock (SCL) and data (SDA).

See the documentation for more information on how the bus works, but for now it's enough to know that any I2C chip has its own address (a number in the range from 0 to 127) and a set of commands. This way you can connect many chips in parallel and still be able to communicate with each individually by starting each message with the appropriate address.

Right from the factory, all DS1621s come with a base address ($40), but you can configure it by connecting the address pins (A0, A1, A2) to 5V or GND respectively (see table). Thus, you can connect up to 8 sensor ICs in parallel per bus, although the supplied software only supports and tabulates two (you can add more sensors by changing the software).

So we can power the DS1621 with 5V DC and connect it to SCK and SDA via PC I2C interface wires, right? Unfortunately, computers don't have 5V DC jacks and I2C ports, so we have to hack them!

Hack #1: Phantom power to the COM port

A temperature sensor doesn't require much power to operate, so why not eliminate the need for power by "stealing" power from the signals already available on the RS232 port?
+12V from the RS232 lines are transmitted to the regulator through diodes D1, D2, filtered by C1 and regulated to +5V on the LM2936-Z5. This is a special regulator capable of operating with a minimum input voltage and saving every mA. The LM2936 is capable of regulating with input voltages as low as 5.2V (most serial ports are only powered by 6V). By comparison, conventional 78L05 regulators require at least 6.7V input and draw 100 times the current required by the LM2936-Z5.

Hack #2: Making the COM port pretend to be an I2C bus.

The thermometer PC software emulates the wires of the I2C bus with two pins of the COM port available on all motherboards.

The SCL line uses RTS (Request To Send, pin 7), while the SDA uses a line originally designed for serial DTR (Data Terminal Ready, pin 4). These signals are available from Visual Basic by setting the DTR and RTS properties of the MSComm object.
You cannot send a signal from the COM port to the DS1621 directly, as the voltage levels must be adapted. According to the EIA-RS232 standard, in most computers, the output voltage reaches +15VDC and drops to -15VDC at the COM port, so we must limit them to more convenient voltages from 0 to +5VDC before connecting to the DS1621 SDA and SCL wires. A 5.1V zener diode and a 4700 limiting resistor are sufficient for this purpose.

If you look closely at the schematic, you will notice that the SDA pin is also connected to the CTS pin (Clear To Send, pin 8). So the thermometer's PC software can control the logic level of the SDA to read the chip's responses, making this line bi-directional. Although the serial port theoretically requires a negative signal from the input, signals in the 0...5Vdc range work well on almost any computer on earth.

Software

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

I wrote a program in Visual Basic. I did it in a direct way, deliberately avoiding optimizations that would make the code less readable.
The I2C bus functions are grouped into a file that can be reused for other applications. It provides functions for all basic I2C bus operations, such as starting and stopping the bus, or sending and receiving a single byte.

The main program provides a function, temperature(chipaddress), which instructs the I2C bus to get the temperature from the chip.
To read the chip temperature in Visual Basic all you need is to query the temperature ($&48), where $ and 48 is the address for the first chip, $H49 is the address of the second chip, and so on according to the table above. My program uses two sensors, but it's not that hard to change it to support up to 8 chips.

The very first time you run the program, you will get a warning that the configuration file does not exist (it will be automatically created at the end of the session) and the settings will be default. Select the serial (COM) port you are using if your device includes U2 for reading outdoor temperature, interval between measurements, units of measurement and if you want temperature logging to the file "pc_thermometer.txt" (an ASCII text file that you can be imported into Excel for processing or plotting).

Check the "start minimized" field, if it is enabled, then on subsequent launches the program will not open a window on the desktop, but will be minimized on the taskbar, providing a "temperature icon". This is my preferred way to use the program.
Clicking on the icon opens a window.

List of radio elements

Designation Type Denomination Quantity NoteShopMy notepad
U1, U2 temperature sensor

DS1621

2 To notepad
U3 Linear Regulator

LM2936

1

The microcircuit is a thermometer and a thermostat “in one bottle” with digital input and output, which guarantees the accuracy of measurement and control with an error of plus or minus 0.5 g. Celsius. If the DS1621 sensor is used as a thermometer, then the data must be processed via the I2C/SMBus serial bus in an additional nine-bit code with the least significant bit accuracy plus or minus 0.5 gr. Celsius.

For applications that need higher resolution of the temperature controlled value, it is necessary to read additional registers and perform simple arithmetic operations in order to obtain more than 12-bit resolution (with the cost of the smallest bit being 0.0625 degrees Celsius). The DS1621 chip has three addressable inputs, so it is possible to connect up to eight DS1621 sensors to one bus.

Using the DS1621 as a thermostat, the DS1621 has TH (high temperature) and TL (low temperature) registers. If the current temperature exceeds the TH level, the sensor output will switch to the active state and will remain in it until the current temperature drops below the TL mark. Thus, control with a given hysteresis is implemented.

Description of DS1621 sensor pins

  • SDA- I2C bus data output.
  • SCL- I2C bus clock output.
  • tout- thermostat output.
  • vdd- power output plus.
  • GND- power output, minus.
  • A0..A2 — low bit line.

The principle of operation of the DS1621 sensor

The principle of measurement is based on the instability of the oscillation frequency when the temperature changes. To implement this measurement principle, two generators are included in the microcircuit structure.

The first of them has high temperature stability. Its operating frequency corresponds to the temperature - 55 gr. Celsius and does not actually change. The operating frequency of the second generator, on the contrary, changes in proportion to the change in temperature. Special counters count pulses for an equal period of time and based on the difference, the current temperature is calculated, which is presented in the form of a 9-bit binary code.

Data is divided into high and low bytes. If an integer temperature value is needed for any purpose, then only the high byte should be used. The least significant byte has only one information bit - LSB, which implements a discreteness of 0.5 gr. Celsius. The remaining bits of the low byte are permanently zero.

Status register

The DS1621 chip has several modes of operation. Setting and control of these modes is carried out using the status register. The following bits exist:

  • DONE- conversion completion flag. Set at the end of the conversion.
  • THF- high temperature flag. Set when the temperature rises above the TH threshold. The flag is reset by software or by turning off the power.
  • TLF- low temperature flag. Set when the temperature drops below the TL threshold. The flag is reset by software or by turning off the power.
  • NVB- flag for writing data to the non-volatile memory of the sensor. A set flag indicates that the write has not completed. The approximate time to write data to cells is 10 ms.
  • POL- select the polarity of the Tout output. A high value indicates direct polarity, a low value indicates reverse polarity. This bit is non-volatile.
  • ISHOT- measurement cycle control bit. A single measurement occurs when the logic level of this bit is high. It is usually used in the creation of energy-saving systems. The low logical level of this bit allows the conversion to be performed in a constant mode. This bit is non-volatile.

Exchange commands

Data exchange with the DS1621 sensor takes place according to the typical I2C protocol. The sensor takes part in it as a SLAVE device. Its SLAVE - address looks like this:

where xxx is the state of the A0-A2 lines of the microcircuit. The following commands are used to interact with the DS1621:

  • 22h -"Stop conversion" - the command terminates the operation of the temperature conversion circuit. No extra data is required to work.
  • Ah-“Reading temperature” - The result of the command is two bytes of data that contain the value of the measured temperature.
  • A1h-"Setting TH" - a command for selecting the upper threshold of the thermostat. After this command, the transfer of two bytes of the threshold value is required.
  • A2h-"Setting TL" - a command to select the lower threshold of the thermostat. After this command, the transfer of two bytes of the threshold value is required.
  • A8h-"reading the temperature counter". The command has a read-only effect and allows reading the counter data, the frequency of which depends on the temperature.
  • A9h-"read stable counter". The command is valid only for reading and allows reading data from the counter, the frequency of which does not depend on temperature.
  • ACh - Configuration register. If the bit is equal to R, the configuration register is written; if W, it is read.
  • EEh-"Start counter" - command to start temperature measurement. No extra data required.

Improving Measurement Accuracy

In the DS1621 sensor, it is possible to increase the accuracy of the measured temperature. For this, the counter values ​​of the stable N and the temperature-dependent generator N are available. Knowing the measured temperature value T and the values ​​of the counters, you can get an accurate reading by applying the formula:

T=T – 0.25 + (N-N)/N

Thermostat mode DS1621

The DS1621 sensor also has an operating mode as a thermostat. To control actuators, there is a digital output Tout, which is set depending on the temperature value. The output on and off levels are set in the TH and TL registers, and the output polarity is selected by the POL bit in the configuration register.

Chip DS 1621, manufactured by Dallas Semiconductors, is designed to perform the functions of a thermometer and thermostat. The capabilities of the microcircuit allow measurements in the temperature range from -55 to +125 degrees Celsius. The temperature reading step is 0.5 degrees. DS 1621 is equipped with an interface I 2C. In thermostat mode, autonomous operation is possible.

Pin assignment

  • SDA- I2C bus data line
  • SCL- I2C bus clock line
  • Tout- thermostat output
  • vdd- positive power output
  • Vss- negative power output
  • A0..A2- lines for forming the least significant bits of the address

Principle of operation

temperature sensor D.S. 1621 for measurement uses the principle of oscillation frequency instability with temperature changes. For this, it includes two generators. The first has high temperature stability. Its frequency corresponds to a temperature of -55 degrees and is practically not subject to change. The frequency of the second generator, on the contrary, varies in proportion to the temperature. Special pulse counters count for the same time interval and, based on the difference, calculate the temperature value. This 9-bit binary value is available to the user. The data is split into high and low bytes. If an integer temperature value is sufficient, then only the high byte can be used. The least significant byte has only one information bit LSB , providing a resolution of 0.5 degrees. The remaining bits of the low byte are always 0.

The DS 1621 chip has several modes of operation. These modes are configured and monitored using the status register. The following bits are available:

  • DONE– conversion end flag. Set after the conversion is completed.
  • THF– high temperature flag. Set when the TH threshold is exceeded. Reset by software or power off.
  • TLF- low temperature flag. It is set at a temperature lower than the threshold value TL . Reset by software or power off.
  • NVB– flag for writing data to non-volatile memory. The set flag indicates that the record is not completed. Cell recording time is approximately 10 ms.
  • POL– output polarity Tout . A high value corresponds to direct polarity, a low value corresponds to reverse polarity. The bit is non-volatile.
  • ISHOT– control of the measurement cycle. When logic high, the measurement is performed once. This mode is used in energy-saving systems. Bit logic low, enables continuous conversion. The bit is non-volatile.

Working with DS1621

Exchange commands

Data exchange with DS 1621 is carried out according to the standard I 2C protocol. The microcircuit participates in it as a slave device. The slave address of the DS 1621 is 1001xxx, where xxx is the state of the A0-A2 lines of the microcircuit. The following commands are used to work with the DS 1621:

  • 22h– "Stop conversion" - the command terminates the operation of the temperature conversion circuit. Additional data is not required for work.
  • AAh– "Read temperature" - The result of the command is two bytes of data containing the value of the measured temperature.
  • A 1h– “Setting TH” - a command for setting the upper threshold for thermostat operation. This command requires the transmission of two bytes of the threshold value.
  • A 2h- "Setting TL" - a command for setting the lower threshold of the thermostat. This command requires the transmission of two bytes of the threshold value.
  • A8h– “reading the temperature counter”. The command is read-only and allows you to read the counter data, the frequency of which depends on the temperature.
  • A9h- "reading a stable counter". The command is read-only and allows you to read counter data, the frequency of which does not depend on temperature.
  • A CH– “Configuration register”. Depending on the state of the R /W bit, the configuration register is written or read. The data format used is bytes.
  • EEh– "Start counter" - command to start temperature measurement. Additional data is not required.

Improving Measurement Accuracy

The DS1621 temperature sensor allows for improved measurement accuracy. To do this, the values ​​of the counters of the stable N and the temperature-dependent N of the generator are available to the user. Knowing the measured temperature value T and the values ​​of the counters, you can use the formula:

T=T – 0.25 + (N-N)/N

It is also desirable to calibrate the sensor to determine the necessary corrections. These corrections must be taken into account in the controller.

Thermostat mode

The DS 1621 chip can operate in thermostat mode. To do this, there is an output Tout , which is set depending on the temperature value. The output on and off thresholds are set by the values ​​in the TH and TL registers. The output polarity is set by the POL bit in the configuration register.





The device is simple, without calibration and microcontrollers.

This incredibly simple thermometer connects to any available serial port. No programmable components or microcontrollers are used. Measurement accuracy is up to 0.5°C without calibration. It's so cheap that I've made one for every computer I use. It's so nice to have a temperature on the Windows taskbar that many friends asked me to make such a device!

Make yourself an accurate thermometer

D This project is easy enough for beginners, only there may be difficulties associated with hardware incompatibility of the serial port on different computers. The single sensor version only needs a sensor chip, a voltage regulator, and a few diodes and resistors. Do it and learn the secrets of the IIC bus, how to implement an IIC bus using only two resistors and a couple of zener diodes, how to control it on a serial port using Visual Basic. The components used are readily available from radio online stores.

Characteristics:

The temperature is displayed both on the Windows taskbar and outside it (see figure).

Installed in any free PC COM port.

Measuring range -20 … +125°C (-4 … 257°F).

Basic accuracy and resolution 0.5°C.

Celsius (°C) and Farenheit (°F) scale.

The data is written to an easily readable text file (good for Excel).

Sample rate 1, 5, 30 or 60 seconds.

One or two temperature sensors (expandable to 8)

Powered by COM port, no external power required.

Easy to do, no exotic software and hardware parts.

Does not require calibration.

Making a PC thermometer is easy. I will describe in detail the version with surface mount elements. Those unfamiliar with soldering small SMT elements will be happy to know that a lead board is also available.

First you need to collect all the elements except for the boards. Here is the list of elements:

Number Type Description
U1, U2 DS1621 or DS1631 Digital temperature sensor

Plastic case SO8 (SMD) or DIP (Output)

U3 LM2936Z-5.0 Ultra low loss voltage regulator, TO92 package (in both versions)
D1, D2 LL4148 Small switching diode (like 1N4148)
DZ1, DZ2 MMSZ5V1 Zener diode 5.1V 0.5W.
C1, C2 47uF/16V electrolytic capacitor
C3, C4 100nF Low Voltage Ceramic Capacitor (SMD 1206)
R1, R2 4700 ohm 5% Resistor 0.25W (SMD 1206)
COM DB9F 9-pin female connector, straight (SMD) or angled (Pull-out)

This is an enlarged view of the assembled SMT board (The small board is a remote temperature sensor).

Once I collected all the elements, I printed out the board in its actual size to check the dimensions of all the elements relative to it. If the element is too big or small, I can fix the board or look for a suitable element before starting work.

After all the elements are checked, I make a payment. Since it is single sided, you can easily etch it yourself. It takes less than an hour and does not require any special materials according to the method described here.

The board must be spotlessly clean (free of oxidation and fingerprints) for good etching and soldering. Wipe it with a soft abrasive to a shine (kitchen washcloth, steel wool and even an office eraser). Don't forget to mirror the board before printing! I love SMT boards because there aren't many tedious holes to drill before soldering.

Soldering requires a soldering iron with a thin tip, sharp tweezers and a steady hand. I fix the board to the table while soldering. I'm actually attaching it to the printout to make it easier to check while soldering.

In order not to accidentally mix up the elements, keep them in their original packaging until needed. I suggest you start with small items (resistors, diodes...) and end with large ones (electrolytic capacitor), tall items can make it difficult to access small ones.

Don't apply too much solder, and be careful not to overheat the components (especially diodes and ICs). If necessary, let the element cool down. Most of the elements are polar, so be careful not to mix them up. The cathode of the diode (K) is marked with a black ring, the negative terminal of the electrolytic capacitors is marked with a black stripe. If you prefer to use tantalum capacitors, remember that their markings are reversed, and the black stripe indicates the positive terminal!

Keep an eye on the photo and always double check until you are sure there is no difference.

Those with no experience in SMT soldering may be concerned about soldering the sensor IC.

I clean the tip of the soldering iron before each soldering point, and use very fine solder to apply as little solder as possible. I apply a small amount of solder only to the pad designated for pin 1.

I put the chip on the board, and when its leads line up with the pads, I clean the tip and heat pin 1 until it is soldered. I check that the chip is still properly positioned (all pins are centered on their respective pads). If it has moved, I heat up pin 1 and move it, or I still solder the rest of the pins, cleaning the tip and using little solder. The last step is to solder pin 1, initially soldered with very little solder.

The LM2936Z5 voltage regulator needs special preparation for soldering. I had through holes but wanted to solder it on the SMT side of the board. The figure shows how to bend and shorten the contacts.

The printed circuit board is designed to fit between the pins of the serial port connector. This is the last part of soldering. Don't forget to solder pins 7 and 8 on the opposite side of the PCB.

I usually clean the board of flux residue with a solvent like acetone and let the board dry completely before turning it on. Once the board is tested and working, I apply a coat of clear spray varnish to protect the copper from oxidation.

The last step is to download and install the software. If you are confused by the Microsoft Installer prompts (... in Italian) these screenshots (first and second) will help you get it right.

When you first start, you must select the serial port number to which the circuit is connected, and you will be ready to receive the temperature. Good luck!

How it works?

The circuit is derived from the programmer Claudio Lanconelli PonyProg. The key component is Dallas Semiconductor's DS1621 temperature sensor. This is a digital temperature sensor, which means that it measures the temperature and converts it into digital values ​​(binary numbers, that is, a sequence of zeros and ones, like bytes in a computer).

Simply apply a regulated 5V power supply and the DS1621 is capable of transmitting ambient temperatures via the IIC (Inter-Integrated Circuit Bus, also spelled I2C) serial bus. This is a standard transfer scheme developed by Philips Semiconductors for connecting many chips together using just two lines: clock (SCL) and data (SDA).

See the documentation for more information on how the bus works, but for now it's enough to know that any I2C chip has its own address (a number in the range from 0 to 127) and a set of commands. This way you can connect many chips in parallel and still be able to communicate with each individually by starting each message with the appropriate address.

Right from the factory, all DS1621s come with a base address ($40), but you can configure it by connecting the address pins (A0, A1, A2) to 5V or GND respectively (see table). Thus, you can connect up to 8 sensor ICs in parallel per bus, although the supplied software only supports and tabulates two (you can add more sensors by changing the software).

So we can power the DS1621 with 5V DC and connect it to SCK and SDA via PC I2C interface wires, right? Unfortunately, computers don't have 5V DC jacks and I2C ports, so we have to hack them!

Hack #1: Phantom power to the COM port

A temperature sensor doesn't require much power to operate, so why not eliminate the need for power by "stealing" power from the signals already available on the RS232 port?

12V from the RS232 lines are transmitted to the regulator through diodes D1, D2, filtered by C1 and regulated to + 5V on the LM2936-Z5. This is a special regulator capable of operating with a minimum input voltage and saving every mA. The LM2936 is capable of regulating with input voltages as low as 5.2V (most serial ports are only powered by 6V). By comparison, conventional 78L05 regulators require at least 6.7V input and draw 100 times the current required by the LM2936-Z5.

Hack #2: Making the COM port pretend to be an I2C bus.

The thermometer PC software emulates the wires of the I2C bus with two pins of the COM port available on all motherboards.

The SCL line uses RTS (Request To Send, pin 7), while the SDA uses a line originally designed for serial DTR (Data Terminal Ready, pin 4). These signals are available from Visual Basic by setting the DTR and RTS properties of the MSComm object.

You cannot send a signal from the COM port to the DS1621 directly, as the voltage levels must be adapted. According to the EIA-RS232 standard, in most computers, the output voltage reaches +15VDC and drops to -15VDC at the COM port, so we must limit them to more convenient voltages from 0 to +5VDC before connecting to the DS1621 SDA and SCL wires. A 5.1V zener diode and a 4700 limiting resistor are sufficient for this purpose.

If you look closely at the schematic, you will notice that the SDA pin is also connected to the CTS pin (Clear To Send, pin 8). So the thermometer's PC software can control the logic level of the SDA to read the chip's responses, making this line bi-directional. Although the serial port theoretically requires a negative input signal, signals in the 0...5VDC range work well on almost any computer on earth.

Software

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

I wrote a program in Visual Basic. I did it in a direct way, deliberately avoiding optimizations that would make the code less readable.

The I2C bus functions are grouped into a file that can be reused for other applications. It provides functions for all basic I2C bus operations, such as starting and stopping the bus, or sending and receiving a single byte.

The main program provides a function, temperature(chipaddress), which instructs the I2C bus to get the temperature from the chip.

To read the chip temperature in Visual Basic all you need is to query the temperature ($&48), where $ and 48 is the address for the first chip, $H49 is the address of the second chip, and so on according to the table above. My program uses two sensors, but it's not that hard to change it to support up to 8 chips.

The very first time you run the program, you will get a warning that the configuration file does not exist (it will be automatically created at the end of the session) and the settings will be default. Select the serial (COM) port you are using if your device includes U2 for reading outdoor temperature, interval between measurements, units of measurement and if you want temperature logging to the file "pc_thermometer.txt" (an ASCII text file that you can be imported into Excel for processing or plotting).

Check the "start minimized" field, if it is enabled, then on subsequent launches the program will not open a window on the desktop, but will be minimized on the taskbar, providing a "temperature icon". This is my preferred way to use the program.

Clicking on the icon opens a window.

Download files for the project

Original article in English (translation: Alexander Kasyanov for cxem.net site)