# Cheap DIY Thermometer With Arduino and Thermistor

774

3

## Introduction: Cheap DIY Thermometer With Arduino and Thermistor

Good Day, guys i am back again with another simple project. To make this simple thermometer you will need just four items.

1. Arduino Uno or any arduino micro controller you have

2. NTC thermistor

3. 10k ohm resistor

4. Arduino IDE for PC o ArduinoDriod for Andriod phones

I will be using the Arduino UNO microcontroller for this project.

## Step 1: NTC: Negative Temperature Coefficient THERMISTOR

Thermistor is an electronic component used to calculate temperature. It is a variable resistor that changes it resistance based on temperature. For NTC thermistor as temperature increases its resistance drops while for PTC thermistors as temperature increases the resistance also increases . P.T.C stands for Positive Temperature Coefficient.

## Step 2: Voltage Divider

A voltage divider does what it names says, it divides voltage. it makes use of resistors to divide voltage. The voltage divider we will be making will consists of just 2 resistors although voltage dividers can be made up of more than two resistors. The two resistor we will be using will be our thermistor and 10k resistor. connect them according to how they are connected it the image to the arduino. One of any of the legs of the Thermistor and 10k ohms resistor should go to the A0 pin of the arduino and the other leg of the thermistor should go to 5V on the arduino while the other leg of the 10k Resistor should go to the GND pin of the arduino.

## Step 3: CODE 1

For the code i used a little bit of Math. I used a concept know as Linear Interpolation the formular is given like this y=y1+(y2-y1)/(x2-x1) * (x-1)Let the values for y, y1 and y2 be for our temperature and let the values for x, x1, x2 be for our analogRead values. Linear interpolation can be used when you predict a certain value from the a group of similar data. it is not very accurate but the good news is that we can use it for our project.

LINEAR INTERPOLATION:

To be able to use linear interpolation we need to know three value of y that corresponds to two values of x when we are looking for x, but when we are looking for y we need to know three values of x that corresponds to two values of y, the third value of y will be what you are looking for the same goes when looking for x . To know more on Linear Interpolation click here

But first we need to get some data. Connect your resistor and thermistor as shown above and copy and paste this code to your arduino.

void setup() {
// put your setup code here, to run once:

Serial.begin(9600);

}

void loop() {

// put your main code here, to run repeatedly:

delay(500);

}

This first code is very simple, in the void setup(), the Serial.begin(9600) set the baud rate of our micro controller to 9600 bps (bits per second). This must be the same as the Serial monitor in you Arduino IDE.

After that open your serial monitor and make sure its baud rate is the same as the one in your code. it should be printing values these values are our analogRead value, so we need to compare it to temperature we know already.

I guess we already know that the human body temperature for a healthy human being should be 36.6 degree Celsius, now touch your thermistor and write down the value(s) you get while touching it, you might get multiple values like values varying from 501 to 506 , if you find yourself in such situation, just find the mean (average) of such values, Now remove your hand from the thermistor and let it cool for a while, check your phone for the weather and check the value of that is shown on your computer ( i advised taking your project with your pc outside to get a better reading) . Then find the mean of the different values you got and write them down, if you kept getting the same value just write that one value down. So for me

A better method will be using an Air Conditioner to adjust the temperature of the Air conditioner to any value you want and wait for a while for it to reach such level and check your thermistor readings on your Serial monitor and write down the temperature of your Air Conditioner and and the mean of the values you got, repeat this for a second time and write down your values .

I used an Air Conditioner and the values i got at specific temperatures where

at 19 degree Celsius the mean of the values i got was 501.0

at 30 degree Celsius the mean of the values i got was 566.6

The variable i used to hold those values in my Code where

sens1val= 19; sens1tmp=501.0;

sens2val=30; sens2tmp=566.6;

## Step 4: Code 2

This is the main code for this project, looking at the code above, i highlighted some values, you will have to change the values , the ones i circled to be exact. sens1val is the value you got at the temperature you tested the thermistor the first time and sens1tmp is the temperature you at which you tested the thermistor . if the first time you touched the thermistor and you got a value of 500 and the normal body temperature for a human beign is 36.6 then for sen1val you would type 500 and for sen1tmp you would type 36.6. Now repeat this same procedure again for sen2val and sen2tmp with another know temperature. Remember you can also use your A.C to get a better result.

FORMULAE:

Remember the formulae i showed you guys earlier on Linear interpolation y=y1+(y2-y1)/(x2-x1) * (x-1) . But in the code i did not use x and y instead

y=temp=temperature we are looking for x=analogRead(A0)

y1=sens1tmp. ; x1= our analogRead value at sens1tmp = sens1val

y2=sen2tmp. ; x2= our analogRead value at sen2tmp = sens2val

so our formular in the code will be:

we will get our answer in Celsius,

To convert to Kelvin add 273 to the value you got in Celsius.= temp+273

To convert to Fahrenheit multiply your value in Celsius by 1.8 and then add 32 to your answer= temp*1.8+32. and we are done , upload your code to your arduino board, open the serial monitor and you will see the temperature values in Celsius, Fahrenheit and Kelvin.

## Step 5: Debbuging

if you are getting values a bit greater or lesser than the actual value you should be getting you can add or subract such value until you get a good result. In my code i added 1.65 to compliment my error, so i can get an accurate result.

## Step 6: Appreciation

Thank you guys for reading. If you have any questions, you can kindly dropped them in the comment section, I will try to answer them. Also I will be including this project in an instructables contest, Please kindly vote for me. Thank You. Participated in the
Anything Goes Contest