top of page

Make a Digital Thermometer circuit!

Updated: Aug 18, 2023

For centuries, thermometers had been working on a fairly simple concept. Mercury is a metal which is liquid under room conditions and this leads to its thermal sensitive properties. What’s interesting about this feature of mercury is that it can detect slight changes in temperature. When temperature rises, mercury expands. When temperature decreases, it contracts. Mercury also has one of the densest structures which makes this contraction or expansion very easy to identify.


Earlier, analogue thermometers were primarily used which contained temp-sensitive mercury.
An Analogue Thermometer

For centuries, these thermometers provided reliable and fairly accurate readings but then technology flooded in. We have digital thermometers now with unmatched accuracy and precision. Using tiny temperature sensors and a basic circuit we can create mercury thermometer’s successor.


Know your components - Digital Thermometer


For this project, we’ll be using a LM35 Thermal sensor. A thermal sensor changes its resistance in response to the change in temperature. This, in turn, allows for a potential divider which changes the voltage. It’s output voltage is linearly proportional to Celsius temperature. Using this simple component, we can detect minute changes in temperatures.


We're using 8051 Microprocess like this intel processor here. It's perfect for IOT applications like this.
8051 Microprocessor

Thereafter, we use an ADC (analogue-digital converter) to take the analogue values (voltage) from the thermal sensor and return a digital value ranging from 0 to 256. This digital data is fed to an 8051 Microcontroller which reads these digital values and returns a value in degree Celsius. The microcontroller returns data in ASCII form which is really useful to us because it can be readily displayed on an LCD.


The last step in the circuit is simply to feed the ASCII values to the 16X2 LCD using the data ports from D0 to D7. This represents an 8-bit register. The LCD screen will display our current temperature and update it frequently as with the thermometer.


Code Explanation


Microcontrollers like the 8051 microcontroller that we’re using could be programmed in C++ to perform certain tasks. Our task here is to take in the ADC digital inputs and provide an ASCII output to the LCD. This does require processing but we can easily do it in a few steps and with the help of a few in-built library commands.


Code




Getting into the code, the first libraries that we import are the reg51 library- which is essential for circuits and electronics projects like these- and the string library- which will help us convert data into ASCII for the LCD. We’ll go through the code from the top to the bottom. The code is divided into small functions to perform specified tasks which is how you should try to code your electronics circuits too.


As always in these projects, we define the constants and the ports that we’ll be using in the first few lines. This is how we initialise our entire circuit. The delay function does exactly what you’d expect it to. It provides a “delay” to a circuit which is basically just so that you can time the circuit right. If the LCD is changing temperatures way too quickly, the user won’t understand anything. The cmd and the ldata function are just initialisation functions for the LCD, they start the LCD and set everything to zero on the LCD.


Then we have the functions that are the core of our program. The first among these is the adc function which takes in values from the ADC and returns it after applying a delay (as seen visibly in the code). The ldata function loops through the characters of a string and changes them into the ASCII form that we talked about.


In the main function, we start our LCD. After a small delay, we’ll print “temp: “ on the LCD and note that this has to remain there. The temperature itself will change but the “temp: “ part stays there. Thankfully, we can do this easily by moving the LCD cursor to be after the “temp: “. To do that we just use the command cmd(0x85). After this is done, the printing part is just taking the data from ldata and putting it on the screen one by one.



Want us to help you with the projects, write your inquiry here - Order Projects


Check out our Free Arduino Projects Playlist - Arduino Projects

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects

Check out our Free IoT Projects Playlist - IoT Projects

Check out our Free Home Automation Projects Playlist - Home Automation Projects

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects



13 views2 comments

Related Posts

See All
bottom of page