Thermometer with thermocouple on microcontroller pic. Thermometer on ATmega8 and temperature sensor DS18B20. Algorithm of the thermometer program on ATmega and DS18B20

Thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller - an article with a detailed description of the memory thermometer circuit and, in addition, a logical continuation of the article I previously published on the Yandex site pichobbi.narod.ru. This thermometer has proven itself quite well, and it was decided to modernize it a little. In this article I will tell you what changes have been made to the scheme and the working program, I will describe the new functions. The article will be useful for beginners. Later I converted the current version of the thermometer into .

The thermometer on the PIC16F628A and DS18B20 (DS18S20) microcontroller can:

  • measure and display temperature in the range:
    -55...-10 and +100...+125 with an accuracy of 1 degree (ds18b20 and ds18s20)
    -in the range -9.9...+99.9 with an accuracy of 0.1 degrees (ds18b20)
    -in the range -9.5...+99.5 with an accuracy of 0.5 degrees (ds18s20);
  • Automatically detect DS18B20 or DS18S20 sensor;
  • Automatically check the sensor for failure;
  • Remember the maximum and minimum measured temperatures.

The thermometer also provides for easy replacement of the 7-segment indicator from OK to an indicator with OA. A gentle procedure for writing to the EEPROM memory of the microcontroller has been organized. A voltmeter that has proven itself well is described in this article -.

The circuit diagram of a digital thermometer on a microcontroller was developed for reliable and long-term use. All the parts used in the circuit are not in short supply. The pattern is easy to follow and perfect for beginners.

The schematic diagram of the thermometer is shown in Figure 1

Figure 1 - Schematic diagram of a thermometer on PIC16F628A + ds18b20/ds18s20

I will not describe the entire circuit diagram of the thermometer, since it is quite simple, I will only dwell on the features.

Used as a microcontroller PIC16F628A from Microchip. This is an inexpensive controller and also not in short supply.

Digital sensors are used to measure temperature DS18B20 or DS18S20 from Maxim. These sensors are inexpensive, small in size, and information about the measured temperature is transmitted digitally. This solution allows you not to worry about the cross-section of the wires, their length, etc. Sensors DS18B20,DS18S20 capable of operating in the temperature range from -55… +125 °C.

The temperature is displayed on a 7-segment 3-digit LED indicator with a common cathode (OK) or with (OA).

To display the maximum and minimum measured temperatures on the indicator, you need the SB1 button. To reset the memory you also need the SB1 button

Using the SA1 button you can quickly switch sensors (street, house).

A jumper is needed to switch the common wire for the LED indicator. IMPORTANT! If the indicator is OK, then we put the jamper in the lower position according to the diagram, and solder the transistors VT1-VT3 with p-n-p conductivity. If the LED indicator is OA, then we move the jamper to the upper position according to the diagram, and solder the transistors VT1-VT3 with n-p-n conductivity.

In Table 1 you can see the entire list of parts and their possible replacement with an analogue.

Table 1 – List of parts for assembling the thermometer
Position designation Name Analog/replacement
C1, C2 Ceramic capacitor - 0.1 μFx50V -
C3 Electrolytic capacitor - 220μFx10V
DD1 Microcontroller PIC16F628A PIC16F648A
DD2,DD3 Temperature sensor DS18B20 or DS18S20
GB1 Three 1.5V AA batteries
HG1 7-segment LED indicator KEM-5631-ASR (OK) Any other low-power for dynamic indication and suitable for connection.
R1,R3,R14,R15 Resistor 0.125W 5.1 Ohm SMD size 0805
R2,R16 Resistor 0.125W 5.1 kOhm SMD size 0805
R4,R13 Resistor 0.125W 4.7 kOhm SMD size 0805
R17-R19 Resistor 0.125W 4.3 kOhm SMD size 0805
R5-R12 Resistor 0.125W 330 Ohm SMD size 0805
SA1 Any suitable switch
SB1 Tact button
VT1-VT3 Transistor BC556B for indicator with OK/transistor BC546B for indicator with OA KT3107/KT3102
XT1 Terminal block for 3 contacts.

For initial debugging of the digital thermometer, a virtual model built in Proteus was used. In Figure 2 you can see a simplified model in Proteus

Figure 2 – Model of a thermometer on the PIC16F628A microcontroller in Proteus

Figure 3-4 shows the circuit board of the digital thermometer

Figure 3 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (bottom) not to scale.

Figure 4 – Printed circuit board of a thermometer on a PIC16F628A microcontroller (top) not to scale.

The thermometer, assembled working parts, starts working immediately and does not need debugging.

The result of the work is Figures 5-7.

Figure 5 - Appearance of the thermometer

Figure 6 - Appearance of the thermometer

Figure 7 - Appearance of the thermometer

IMPORTANT! In the thermometer firmware not sewn in advertising can be used for your pleasure.

Amendments made to the work program:

1 automatic detection of DS18B20 or DS18S20 sensor;

2. The rewriting time in EEPROM has been reduced (if the condition for rewriting is met) from 5 minutes to 1 minute.

3. The blinking frequency of the dot has been increased;

A more detailed description of the operation of the thermometer can be found in the document, which can be downloaded at the end of this article. If you don’t want to download, then on the website www.pichobbi.narod.ru The operation of the device is also perfectly described.

The finished board fit perfectly into a Chinese alarm clock (Figures 8, 9).

Figure 8 – All the stuffing in a Chinese alarm clock

Figure 9 - All the filling in the Chinese alarm clock

Video - Thermometer operation on PIC16F628A

PIC16F676 Application: soldering station, control of high-temperature processes, etc. with PID control function of the heating element

I decided to insert a thermometer into my laminator, a K-type thermocouple thermometer. To make it more informative for me, I believe that a hobby radio amateur cannot be content when only two LEDs “POWER” and “READY” are lit on such a device. I arrange the scarf for my details. Just in case, with the ability to cut it in half (this is some versatility). Right away with a place for the power part on the thyristor, but for now I’m not using this part, this will be my circuit for a soldering iron (when I figure out how to attach a thermocouple to the tip)


There is not enough space in the laminator (the mechanisms are located very tightly, you know in China), I use a small seven-segment indicator, but that’s not all, the whole board doesn’t fit either, this is where the versatility of the board comes in handy, I cut it in half (if you use a connector, the upper part fits many developments on little tidbits from ur5kby.)


I set it up, first I do as stated in the forum, I don’t solder in the thermocouple, I set 400 (although if this parameter is in memory, this item will disappear), I set the variables to approximately room temperature and exactly to boiling point,

Such a controller theoretically operates up to 999°C, but at home such a temperature is unlikely to be found, at most it is an open fire, but this heat source has strong nonlinearity and sensitivity to external conditions.

here is a sample table.
and also for clarity

So there is little choice in choosing a source for adjusting the controller readings.

There is no more playing with buttons, everything can be collected,
I used a thermocouple from a Chinese tester. And a post in the forum advised me that this thermocouple can be multiplied, its length is almost half a meter, I cut off 2 cm.

I make a transformer by twisting it with charcoal, a ball is obtained, and to the two ends it is exactly the same, along a copper wire, for good soldering to my wires.

A series of articles about temperature measurement with Arduino controllers would be incomplete without a story about thermocouples. Moreover, there is nothing else to measure high temperatures with.

Thermocouples (thermoelectric converters).

All temperature sensors from previous lessons made it possible to measure temperature in a range no wider than – 55 ... + 150 °C. For measuring higher temperatures, the most common sensors are thermocouples. They:

  • have an extremely wide temperature measurement range -250 … +2500 °C;
  • can be calibrated for high measurement accuracy, up to an error of no more than 0.01 °C;
  • usually have a low price;
  • are considered reliable temperature sensors.

The main disadvantage of thermocouples is the need for a fairly complex precision meter, which must provide:

  • measurement of low values ​​of thermo-EMF with an upper value in the range of tens and sometimes even units of mV;
  • compensation of thermo-EMF of the cold junction;
  • linearization of thermocouple characteristics.

Operating principle of thermocouples.

The operating principle of this type of sensor is based on the thermoelectric effect (Seebeck effect). Therefore, another name for a thermocouple is a thermoelectric converter.

In a circuit, a potential difference is formed between connected dissimilar metals. Its value depends on temperature. Therefore it is called thermo-EMF. Different materials have different thermal emf values.

If in a circuit the joints (junctions) of dissimilar conductors are connected in a ring and have the same temperature, then the sum of the thermo-EMF is equal to zero. If the wire junctions are at different temperatures, then the total potential difference between them depends on the temperature difference. As a result, we come to the design of a thermocouple.

Two dissimilar metals 1 and 2 form a working junction at one point. The working junction is placed at the point whose temperature needs to be measured.

Cold junctions are the points where the metals of a thermocouple connect to another metal, usually copper. These may be the terminal blocks of the measuring instrument or the copper communication wires to the thermocouple. In any case, it is necessary to measure the temperature of the cold junction and take it into account in the calculation of the measured temperature.

Main types of thermocouples.

The most widely used thermocouples are XK (chromel - copel) and XA (chromel - alumel).

Name Designation NSKh Materials Measuring range, °C Sensitivity, µV/°C, (at temperature, °C) Thermo-EMF, mV, at 100 °C
THC (chromel-copel) L Chromel, copel - 200 … + 800 64 (0) 6,86
TCA (chromel-alumel) K Chromel, alumel - 270 … +1372 35 (0) 4,10
TPR (platinum-rhodium) B Platinorhodium, platinum 100 … 1820 8 (1000) 0, 03
TVR (tungsten-rhenium) A Tungsten-rhenium, tungsten-rhenium 0 … 2500 14 (1300) 1,34

How to practically measure temperature using a thermocouple. Measurement technique.

The nominal static characteristic (NSC) of the thermocouple is given in the form of a table with two columns: the temperature of the working junction and the thermo-emf. GOST R 8.585-2001 contains the NSCH of thermocouples of different types, specified for each degree. Can be downloaded in PDF format from this link.

To measure temperature using a thermocouple, follow these steps:

  • measure the thermo-EMF of the thermocouple (Etotal);
  • measure the temperature of the cold junction (T cold junction);
  • Using the thermocouple NSH table, determine the thermo-EMF of the cold junction using the temperature of the cold junction (E cold junction);
  • determine the thermo-EMF of the working junction, i.e. add the EMF of the cold junction to the total thermo-EMF (E working junction = E total + E cold junction);
  • Using the NSH table, determine the temperature of the working junction using the thermo-EMF of the working junction.

Here is an example of how I measured the temperature of a soldering iron tip using a TXA thermocouple.

  • I touched the working junction to the soldering iron tip and measured the voltage at the thermocouple terminals. The result was 10.6 mV.
  • Ambient temperature, i.e. cold junction temperature is approximately 25 °C. The cold junction EMF from the GOST R 8.585-2001 table for a K-type thermocouple at 25 °C is 1 mV.
  • The thermal EMF of the working junction is 10.6 + 1 = 11.6 mV.
  • The temperature from the same table for 11.6 mV is 285 °C. This is the measured value.

We need to implement this sequence of actions in the Arduino thermometer program.

Arduino thermometer for measuring high temperatures using a TXA-type thermocouple.

I found a TP-01A thermocouple. A typical, widely used TCA thermocouple from a tester. This is what I will use in the thermometer.

The parameters indicated on the packaging are:

  • type K;
  • measurement range – 60 … + 400 °C;
  • Accuracy ±2.5% up to 400°C.

The measuring range is based on fiberglass cable. There is a similar thermocouple TP-02, but with a 10 cm long probe.

TP-02 has an upper measurement limit of 700 °C. So, we will develop a thermometer:

  • for thermocouple type TXA;
  • with measuring range – 60 … + 700 °C.

Once you understand the program and circuit diagram of the device, you can create a meter for thermocouples of any type with any measurement range.

The remaining functionality of the thermometer is the same as the devices from the previous three lessons, including the function of recording temperature changes.

Category: . You can bookmark it.