OBJECTIVE

In this project we will build a device for measuring temperature.

THE HARDWARE

You can use an UNO or MEGA

UNO
MEGA

There are a number of sensors that I could have used to make this thermometer but I chose the LM35. I chose the LM35 because of its precision. The LM35 has an output voltage that is linearly proportional to the temperature in Centigrade. For every degree celsius increase, the voltage output of the LM35 increases by 10mV. The LM35 can be used to measure voltages from -55°C to +150°C. The LM35 can operate from a 5V supply voltage and has a standby current of less than 60µA. All of these characteristics make it an ideal choice for this project.

THE CODE

First, we include the library that is needed to use the DHT series of temperature and humidity sensors.

#include <DHT.h>;

Next, we define two constants that will be used before the program is compiled. We define which digital pin the sensor will be connected to.

#define DHTPIN 7
#define DHTTYPE DHT22

Now we need to initialise the sensor.

DHT dht(DHTPIN, DHTTYPE);

Now we define a variable to store the temperature value.

float temp;

In our void setup() we set up the serial monitor with a baud rate of 9,600.

void setup()
{
  Serial.begin(9600);
  dht.begin();
}

In our void loop() we create a 2-second delay between each measurement.

delay(2000);

Now we need to store our temperature reading in our temperature variable.

temp = dht.readTemperature();

Next, we print text to our serial monitor, along with the values stored in our temp variable.

Serial.print(" Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
delay(10000);

IMPROVEMENTS

Since some countries read temperature values in °F we could display this value as well as °C. To convert between °C and °F we can use this formula, °F = temperature in °C x (9/5) + 32.

A further improvement would be to use an LCD instead of the serial monitor. This would also mean that the thermometer could be portable.