Scheme of a two-channel thermometer on a microcontroller. Electronic thermometer with wireless sensor

The figure shows a diagram of a thermometer based on the PIC16F628A microcontroller; a DS18B20 digital temperature sensor is used as a sensor. The thermometer indicator consists of a 4-digit seven-segment indicator. Measured temperature range from-55 to + 125 degrees Celsius. The temperature is read every 15 seconds, the reading time can be changed in the code.

The thermometer supply voltage is 5V, current consumption is 90 mA. The circuit uses BC337 or similar transistors. The current consumption of each indicator segment is 15 mA (dynamic indication), which is limited by 220 Ohm resistors (indicator with a common cathode).

Firmware file -

DS18B20 digital thermometer with programmable resolution, from 9 to 12-bit, which can be stored in the device’s EEPROM memory. DS18B20 exchanges data via a 1-Wire bus and can be either the only device on the line or work in a group. All processes on the bus are controlled by a central microprocessor.

Measuring range from –55°C to +125°C and accuracy of 0.5°C in the range from –10°C to +85°C. In addition, the DS18B20 can be powered by data line voltage (“parasite power”) in the absence of an external voltage source.
Each DS18B20 has a unique 64-bit serial code that allows it to communicate with multiple DS18B20 sensors installed on the same bus. This principle allows one microprocessor to be used to control many DS18B20 sensors distributed over a large area. Applications that can benefit from this feature include temperature control systems in buildings, equipment or machinery, as well as monitoring and control of temperature processes.

  • Similar articles

Login using:

Random articles

  • 10.10.2014

    The figure shows the diagram preamp with tone block, tone block included in the circuit feedback pre-amplifier. The supply voltage of the device can vary from 12 to 24V, the current consumption is no more than 10 mA. The input signal arrives through the coupling capacitor C1, resistors R1 and R2 determine the bias voltage of transistor VT1, after pre-amplification ...

I decided to make a two-channel thermometer, but not an ordinary one, but with a wireless sensor for the street. The idea is certainly not new; similar industrial thermometers are already on the market. Since I had experience connecting radio modules to a microcontroller, I began to develop my own version of a wireless thermometer.

To measure temperature, I used the common DS18B20 sensors, and to display the readings I used the no less popular one. I discussed radio modules and data transmission algorithm earlier in an article about

Below is a diagram of a wireless sensor on a PIC12F675 microcontroller.

After power is applied, the microcontroller reads the temperature value from sensor BK1 and sends this data to radio transmitter A1, after which it enters sleep mode. The microcontroller wakes up by an interrupt, which is generated by a change in the level on the GP0 line. An RC circuit on elements R2 and C4 is connected to this line, which performs the function of a timer. When exiting sleep mode, the GP0 line is set to a low logic level, thereby discharging capacitor C4. Before going into “sleep”, the line is adjusted to the input, the capacitor begins to charge through resistor R4, and when the threshold voltage (about 1.2V) is reached, the microcontroller is interrupted and awakened. With the values ​​of R2 and C4 indicated in the diagram, the awakening period is approximately 5 minutes. By installing jumper JP1, you can reduce the period to 5.5 seconds. By selecting a capacitor and resistor, you can adjust the desired period time, but you must take into account the charging current of the capacitor in terms of energy consumption.

The temperature value is transmitted over the radio channel in the form of a packet of 3 bytes, the last byte is the checksum of the first 2 bytes. The data transmission algorithm that I use, in principle, allows us to do without a checksum; the probability of receiving incorrect data is low. The transmission speed is 3.3 Kbps. Each time after measuring the temperature, 3 packets of bytes are sent, the pause between packets is 10 ms, I used this transmission option to increase the reliability of receiving data by the receiver. This is due to the fact that the receiving side interrupts signal reception for 4-5 ms while measuring the temperature from the internal (home) sensor.

A 6F22 9V battery (“Krona”) is used as power; the A1 radio transmitter module is powered directly from the battery. To power the microcontroller, a 5V micro-power voltage stabilizer DA1 (MCP1702) is used; the stabilizer’s own current consumption is only 1-2 µA, the maximum load current is up to 250 mA. The MCP1702 stabilizer can be replaced with the LP2950, ​​whose current consumption is higher and is 75 μA. Conventional voltage stabilizers of the L78xx type have a high current consumption of several milliamps, and therefore are not suitable for battery-powered equipment. The current consumption of the device in sleep mode changes over time as capacitor C4 charges; for the first 2.5 minutes the consumption is 10 μA, for the next 2.5 minutes the current gradually increases until the sleep mode is exited. This phenomenon occurs due to the presence of switching currents in the microcontroller input buffer.

I would like to note that at low temperatures the battery capacity decreases faster; not all types of batteries can be used in such conditions. Lithium batteries have the best performance at negative temperatures, followed by Ni-Mh batteries, alkaline batteries occupy third position, salt cells are not suitable for such conditions.

Below is a diagram of a thermometer on a PIC16F628A microcontroller.


The HG1 display, BK1 sensor and microcontroller are powered by a voltage of 3.3V from the DA2 stabilizer. This value was chosen due to the characteristics of the display, the maximum supply voltage of which is 3.3V; in addition, there is no need to match the voltage levels between the input/output lines of the display and the microcontroller. Receiver module A1 is powered by stabilizer DA1, with an output voltage of 5V. Resistors R6, R7 are installed to match voltage levels.

Microcontroller DD1 reads the temperature value from sensor BK1 every 2 seconds, in parallel receives a signal from the receiver, and when a packet of bytes is received from the transmitter, the HL1 LED flashes. At the top of the display the inscription “Home” is displayed, under which the temperature value from the internal (home) sensor is displayed, below the inscription “Street” and the temperature received from the wireless sensor are displayed. After receiving data over the radio channel, the microcontroller starts a timer that counts down the time to control the receipt of data. If data has not been received during the countdown period of the timer, instead of temperature readings, the dash symbols “- – – – -” are displayed on the display. The countdown time can be set from 1 to 15 minutes in one-minute increments. To do this, before programming the microcontroller, you need to write a number from 1 to 15 into the EEPROM cell with address 0x00. The default period is 7 minutes. If the BK1 sensors malfunction, for both devices, instead of the corresponding temperature value, the message “ERROR” is displayed. Button SB1 controls the display backlight; by default, the backlight is on. Button SB2 is designed to adjust the display contrast, since it may differ from one model to another.

An unstabilized power source with an output voltage of 8-12V is suitable to power the device. Both devices are housed in plastic cases. The antenna for radio modules is made in the form of a piece of single-core wire 17 cm long (a quarter of the wavelength of the carrier frequency).





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 work 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 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 sensor DS18B20 or DS18S20;

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;

More detailed description The operation of the thermometer can be viewed 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

On MK. Its heart is the PIC16F628A microcontroller. The thermometer circuit uses a 4-digit or 2+2 LED indicator with a common anode. The temperature sensor used is DS18B20 type, and in my case the sensor readings are displayed with an accuracy of 0.5*C. The thermometer has temperature measurement limits from -55 to +125*C, which is enough for all occasions. To power the thermometer, a regular charger from a mobile phone was used on an IP with a transistor 13001.

Schematic diagram of a thermometer on a PIC16F628A microcontroller:

To flash the PIC16F628A firmware, I used the ProgCode program, installing it on the computer and assembling the ProgCode programmer according to the well-known scheme:

Designation of the pins of the microcontroller used and the pinout of some other similar MKs:

The ProgCode program and instructions with photos of step-by-step firmware are in the archive on the forum. There are also all the files necessary for this scheme. In the program, open and click on the “record everything” button. In my manufactured device, as can be seen from the photographs, 2 thermometers are assembled in one case at once, the upper indicator shows the temperature at home, the lower indicator shows the temperature outside. It is placed anywhere in the room and connects to sensor with a flexible wire in the screen. Material provided by ansel73. Firmware edited by: [)eNiS

Description of the thermometer operation

The purpose of this thermometer is simply to show the temperature. Small differences from other similar schemes are only in the format of temperature output on the LED indicator, which is a 4-digit super-bright CA04-41SRWA. DS18B20 is used as a temperature sensor in a normal connection with a separate power wire.

The circuit is designed to be powered by batteries, so when the power is turned on, the indicator does not show anything. The thermometer program undergoes initialization and immediately goes into sleep mode. Sleep mode of the microcontroller allows you to save energy from the power supply. When you press the button connected to PORTB0, the indication turns on.
The indicator displays a hint:



Then the temperature readings themselves are displayed on the indicator.



The type of reading output is as follows:






The output shape differs only for low positive temperatures. When indicating such a temperature, the sign “C” is added to the “degree” symbol. That is, degrees Celsius. The “degree” symbol is present on the indicator at any measured temperature.

The DS18B20 temperature sensor measures temperature with a resolution of 0.0625 degrees Celsius. The thermometer reads the readings from the sensor and rounds them to the nearest tenth of a degree. Tenths of a degree are displayed in all display modes, except for temperatures lower than -10 degrees Celsius. This is done so that readings of negative temperatures always have a minus sign.

The readings are present on the indicator for 30 seconds. Then the device goes into sleep mode again and the indicator turns off.


Modeling a thermometer in Proteus


The Proteus model made it possible to work out the software part of the thermometer without assembling the device itself in hardware. All modes have been tested. There are no simulation failures in the program.



The model itself can be downloaded from the link: termo_i_v2.DSN

Schematic diagram of a thermometer


The circuit is drawn based on the design of the printed circuit board. First, the wiring of the printed circuit board was done so that the length of the conductors and the location of the parts were optimal, and only after the PIC16F628A microcontroller ports on the printed circuit board corresponded to the pins of the CA04-41SRWA indicator, an exact circuit diagram was drawn up.


Thermometer circuit board


mob_info