User Manual

160
/
223
The breadboard layout is based on the layout from Lesson 22, so it will simplify
things if you still have this on the breadboard.
There are a few jumper wires near the pot that have been moved slightly on this
layout.
The 10 kΩ resistor and thermistor are all new additions to the board.
Code
After wiring, please open the program in the code folder- Lesson 23 Thermometer
and click UPLOAD to upload the program. See Lesson 2 for details about program
uploading if there are any errors.
Before you can run this, make sure that you have installed the < LiquidCrystal >
library or re-install it, if necessary. Otherwise, your code won't work.
For details about loading the library file, see Lesson 1.
The sketch for this is based on that of lesson 22. Load it up onto your Arduino and
you should find that warming the temperature sensor by putting your finger on it
will increase the temperature reading.
I find it useful to put a comment line above the 'lcd' command.
// BS E D4 D5 D6 D7
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
This makes things easier if you decide to change which pins you use.
In the 'loop' function there are now two interesting things going on. Firstly we have
to convert the analog from the temperature sensor into an actual temperature, and
secondly we have to work out how to display them.
First of all, let's look at calculating the temperature.
int tempReading = analogRead(tempPin);
double tempK = log(10000.0 * ((1024.0 / tempReading - 1)));
tempK = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * tempK * tempK ))
* tempK );
float tempC = tempK - 273.15;
float tempF = (tempC * 9.0)/ 5.0 + 32.0;
Displaying changing readings on an LCD display can be tricky. The main problem is
that the reading may not always be the same number of digits. So, if the
temperature changed from 101.50 to 99.00 then the extra digit from the old reading
is in danger of being left on the display.
To avoid this, write the whole line of the LCD each time around the loop.