I made this thermometer for fun, but also to get some experience with writing Arduino software and with the use of an LCD display. While working on it I decided to add some functionality. Measured maximum temperature, minimum temperature and an arrow up or down on the display showing the temperature trend. A push button is used to reset the displayed min and max temperature to the current temperature.
Building it is fairly simple. Connect the components as shown in the schedule. The 5V output of the Arduino Uno must be linked to all the +5V connections (arrows.) Also interconnect all ground pins. The thermometer is powered by an external power supply of 12 V DC connected to the Arduino. Download the sketch and upload it to your Arduino and you're done.
What you need:
- Arduino Uno
- LCD display 1602A
- 12 V DC power supply
- B+B Thermo Technik TS-NTC-103 (10kΩ)
- Metalfilm resistor 10kΩ, 0,1% tolerance
- potmeter 10kΩ linear
- Resistor 820 Ω (tolerance not important, 10%, 5% or better will do)
- Resistor 10 kΩ (tolerance not important)
- Capacitor 0,1 uF (=100nF) 16V (2 pieces)
- Elco 470 uF 16V
- pushbutton (normally off)
- Enclosure if you want to build it in
The NTC I use is a precision temperature sensor of B+B Thermo Technik of 10 kΩ. This sensor has a resistance tolerance at 25 °C of ±0,5% The NTC temperature sensors of series TS-NTC have a wide measuring range of -60 ... +150 °C, and hence, are suitable for applications where till now expensive platinum resistors were being used. Both the basic resistance as well as the B-value are within a toleranceof ±0.5%, so that the component can be used in many applications without temperature calibration and can also be replaced without readjustment. Hence, by means of simple resistance measurement,an accuracy of ±0.12 K at 25 °C can be achieved in this way. In the temperature range of -60 ...+85 °C, the maximum error is about ±0.5K. You can use any other high precision NTC, but then you'll have to change the Steinhart-Hart coefficients in de sketch to fit that NTC (see Steinhart-Hart approximation.)
Obviously for high precision temperature measurements the other resistor of the voltage divider, in series with the NTC, also needs to be a low tolerance type. I used a metalfilm resistor of 10kΩ, tolerance 0,1%, 0,6W, temperature coefficient 25 ppm. Any other resistor with a tolerance of 0,5% or less will do.
The NTC is placed outside the house. In my case with a couple of meters of cable. To avoid interference from other electrically 'noisy' equipment in the house I placed a decoupling capacitor of 0,1 uF from the analog temperature input of the Arduino Uno (pin 14) to earth. The oscilloscope still showed some noise on pin 14 after that. The noise was caused by the clock of 1602 LCD display. It dissappeared after a decoupling capacitor of 0,1 uF was placed between the VDD and the Vss pin of the LCD display. This capacitor should be soldered directly on the LCD PC board with wires as short as possible (1 cm at most.)
The oscilloscope showed the signal on pin 14 was clean after that. To avoid noise and ripple from the switching power supply I placed an elco of 470 uF between the 5V and gnd of the Arduino
To avoid faulty temperature measurements the NTC and its enclosure may never ever be in the sun. So it should be placed in the shade, preferably on the north side of the house (on the south side if you're in the southern hemisphere) or even away from the house. Not tight to the wall, but at least a couple of mm outside the wall, for the wall may be a couple of degrees warmer than the outside air. And preferably a wall with no heating behind it like the garage wall.
The LiquidCrystal library is included for the 1602 LCD commands. Several constants and variables are declared. Please read the comments in de sketch for more info. A, B and C are the Steinhart - Hart coefficients for the NTC I use. For other NTC's you have to change these coefficients. The integer interval on line 17 defines the time between two successive measurements, which is 3 seconds. In order to get a smooth progress of the temperature measurement a running average is calculated out of 30 successive measurements (numReadings on line 22). Hence the shown temperature is always the average of the temperature of the last 90 seconds. For the calculation of the running average an array is used: readings[numReadings] or in this case readings on line 21. Each reading is an integer between 0 and 1023.
An NTC (Negative Temperature Coefficient) is a resistor with a temperature dependant resistance. The resistance gets lower if the temperature increases. Unfortunately the relation between resistance and temperature is not lineair. But the R-T curve can be approximated by a formula. In practice two approximation formulas are used. The so called Beta formula and the Steinhart-Hart formula. Since the latter one gives the best approximation, that is the one I use. Often the manufacturer give us values for both approximations. However the TS-NTC-103 can be used in a wide temperature range of -60...+150 degrees Celcius. Since we are using it in a much smaller range of approx. -10...+30 degrees Celcius we get a better approximation if we calculate the coefficents ourself specially for this range. I used three resistance-temperature pairs from the specs of the manufacturer in our working range (-10, 0 and +20 degrees Celcius). It's simple to calculate the coefficients with the online calculator of Stanford Reasearch Systems. In the diagram below you see the data (red dots) the Beta model approximation and the Steinhart-Hart approximation. In the right lower corner you see that with a resistor value of 10k, the approximated temperature is 25,0035 degrees Celcius with Steinhart-Hart approximation, which is pretty good, and 25,7716 degrees Celcius with Beta approximation, which is substantially less good (the NTC is 10k at 25 degrees Celcius)