logo elektroda
logo elektroda
X
logo elektroda

Thermometer with DS18B20 sensor and two-digit LED display

Sam Sung  19 1776 Cool? (+18)
📢 Listen (AI):

I made myself a two-digit thermometer with a red ELD-515SURWA seven-segment display (soldered out of a Euroster 1100E thermostat) and a DS18B20 sensor.
The electronics fit on a 2x8 cm cutout of a 6x17 mesh universal board.




The housing is a white 2xRJ11 6P4C surface-mounted telephone socket.
White plastic casing marked for drilling with holes and electric drill nearby White surface-mount box with hand-drilled holes for a seven-segment display White plastic case with a rectangular cutout, file and screwdriver nearby White enclosure with rectangular cutout for seven-segment display Thermometer with red LED display showing 21°C Thermometer with red LED display showing 21°C DIY thermometer with LED display showing 28°C in a white plastic casing. Thermometer with red LED display showing a temperature of 14 degrees Two-digit red LED display showing value 29 on a white casing White enclosure with dark translucent panel for an LED display. Homemade thermometer with red LED display showing 28°C
Power supply from a 5 V / 120 mA switching power supply.

Schedule <br/span>
Thermometer schematic with AT89C2051 microcontroller and ELD-5155URWA display

Firmware
The brain of the chip is the AT89C2051. The program in assembler takes 410 bytes. I attach the source and hex.
The thermometer can show a temperature from -9 to +99 °C.
I use the smallest resolution of the measurement i.e. 9 bits and show only the integer part of the result.
By using three wires (i.e. supplying power via a separate wire rather than parasitically), you can ask the sensor if it has finished measuring. When this happens, the program reads scratchpad , checks the CRC and updates the value on the display.
Multiplexing takes place in a timer interrupt at 1302 Hz. During the time-critical operations of receiving and sending a bit on the 1-wire bus, the interrupts are blocked (up to half a millisecond during 1-wire resets); I did not notice with the naked eye the effect of such multiplexing hang-up on the brightness of the display.


-- No sensor
E1 The sensor reported completion of temperature measurement immediately after measurement order
E2 The sensor failed to report completion of temperature measurement in a timely manner
E3 CRC error data received from scratchpad a sensor
__ Temperature ≤ -10 °C
90c64cdcfda ^^ Temperature ≥ +100 °C






The sensor here measures the temperature of the hot water at the outlet of the cooker. I cleaned a piece of tubing with sandpaper and on a drop of thermally conductive paste applied the sensor with the inscription side to the tubing, stuck it on with silver repair tape and then wrapped it with a couple of layers of sponge.
It seems that despite these treatments the thermometer nevertheless underestimates the water temperature by about 2-3 degrees....

About Author
Sam Sung
Sam Sung wrote 1982 posts with rating 552 , helped 226 times. Been with us since 2005 year.

Comments

Andrzej_Tomaszewski 31 Jan 2026 22:21

AT89C2051- I started my uC adventure with it 20 years ago. Did you write the procedure for handling 1Wire and communicating with DS18B20 yourself? How do you limit the current of the diodes in the display... [Read more]

Sam Sung 01 Feb 2026 09:13

Yes, these are my battle-tested procedures, here used in the trivial case of a single sensor on a ~20cm wire. I converted their delays to a 12 MHz clock. So far the smallest pull-up I've had was 1.5k,... [Read more]

Andrzej_Tomaszewski 01 Feb 2026 11:38

Well yes, if the WK display is ok but the control method is a bit unusual, not very energy efficient. Regards Added after 2 [minutes]: And haven't you thought about a resistor ladder with... [Read more]

Sam Sung 01 Feb 2026 11:58

I didn't know there were such. This kind of circuit would not fit on such a small board. [Read more]

Andrzej_Tomaszewski 01 Feb 2026 18:47

Just out of curiosity - what was dictated by this board size? It seems that the enclosure allowed the use of a slightly larger board. [Read more]

saly 02 Feb 2026 00:13

Years ago I used assembler, then fell in love with C++, I remember from assembler that it was like ploughing acres of field with a hand plough. Respect and admiration, especially for your original solution... [Read more]

Andrzej_Tomaszewski 02 Feb 2026 08:18

The following shows that the output in the low state can accept 20mA while in the high state the current flowing out is negligible. I wonder what was dictated by the choice of this and not another uC. ... [Read more]

ex-or 02 Feb 2026 10:57

Way from PCF8574 note [Read more]

Sam Sung 02 Feb 2026 17:39

The choice of board and prock was mainly dictated by the fact that I had one, but I also wanted to see if I could do such a small chip with such an old proc. The port load is high, the ports have a strong... [Read more]

acctr 03 Feb 2026 15:23

The microprocessor used is very cool, for many one of the first in an electronic career, due to BASCOM. The relatively small amount of ROM is enough for small projects and to practice assembler, because... [Read more]

efi222 03 Feb 2026 19:36

Bascom was not as bad as it was painted. Here an example of a thermometer on an ATTiny2313 with a DS18B20. http://mirley.net/minitermometr_uniwersalny.html This project is also on the electrode as far... [Read more]

Andrzej_Tomaszewski 03 Feb 2026 20:34

And it still isn't :) [Read more]

Sam Sung 03 Feb 2026 22:43

Many times. Well it didn't want to work the first time :) Hmm, I've done error handling though, and I don't keep flying by no matter what happens on the bus :) Well, and I put the microcontroller... [Read more]

Andrzej_Tomaszewski 04 Feb 2026 07:58

In Bascom, one short command and the uC sleeps, error detection on the 1Wire bus - it's just testing the state of a dedicated variable, processing data from DS18B20 and converting it to degC with simultaneous... [Read more]

Strumien swiadomosci swia 06 Feb 2026 09:45

Tum no less sometimes it's nice to insert an insert in asm ..... [Read more]

astony 08 Feb 2026 12:17

Bravo for the assembler. Pity not at2313 :) . [Read more]

Sam Sung 09 Feb 2026 17:22

When you write identical functionality in assembler on ATtiny2313, we'll compare the conciseness of 8051 vs AVR machine code :) It seems that the AVR must lose by a landslide because: - it's RISC -... [Read more]

acctr 09 Feb 2026 18:35

But in which category? Because certainly not in performance. [Read more]

rb401 10 Feb 2026 06:30

Your board would fit another twenty resistors without any problem. Using SMD resistors instead of chip resistors. SMD resistors of size 0805 and 0603 fit best on such universal boards. The use of SMD... [Read more]

%}