# Arduino project: build a digital thermometer

> Learn how to build an Arduino digital thermometer by combining a DHT11 temperature and humidity sensor with a 1602 LCD display to show live readings.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-03-28 | Topics: [Arduino](https://flaviocopes.com/tags/electronics/) | Canonical: https://flaviocopes.com/arduino-project-digital-thermometer/

In this project I want to combine 2 components, the 1602 LCD Display

![Two 1602 LCD displays showing front and back sides with blue screen and green PCB with pin connections](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3666.jpg)

and the DHT11 temperature and humidity sensor

![DHT11 temperature and humidity sensor module with blue plastic casing and pin labels on black PCB](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3661.jpg)

to create a digital thermometer we could actually use in the real world.

Before we start, read the DHT11 tutorial where we write a program that reads the data from the sensor:

![Arduino circuit diagram showing DHT11 temperature sensor connected to Arduino Uno with wiring schematic](https://flaviocopes.com/images/arduino-project-digital-thermometer/Swanky_Curcan.png)

and also read the 1602 LCD tutorial where I explain how to write to the display:

![Arduino circuit diagram showing 1602 LCD display connected to Arduino Uno via breadboard with Hello World displayed](https://flaviocopes.com/images/arduino-project-digital-thermometer/Fantabulous_Jofo.png)

Once you do so, all you need to do from the circuits perspective is to add both circuits to the same Arduino based project:

![Complete circuit diagram showing Arduino connected to both DHT11 sensor and 1602 LCD display via breadboard](https://flaviocopes.com/images/arduino-project-digital-thermometer/Copy_of_LCD_display.png)

Here it is in practice:

![Physical breadboard setup with Arduino Uno, 1602 LCD display, and colorful jumper wires connecting components](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3698.jpg)

![Arduino project from different angle showing LCD display, breadboard, and DHT11 sensor with wire connections](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3699.jpg)

![Top-down view of completed digital thermometer project with LCD display, Arduino, and DHT11 sensor on breadboard](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3697.jpg)

On the code side, we do a similar thing. We include both the `DHT` and the `LiquidCrystal` libraries first, then we initialize the 2 components.

We initialize them in `setup()` and in `loop()` we check every 2 seconds the data coming from the sensor, and we print it to the LCD display:

```c
#include <LiquidCrystal.h>
#include <DHT.h>

DHT dht(2, DHT11);
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void setup() {
  dht.begin();
  lcd.begin(16, 2);
}

void loop() {
  delay(2000);
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    return;
  }

  lcd.setCursor(0, 0);
  lcd.print((String)"Temp: " + t + "C");
  lcd.setCursor(0, 1);
  lcd.print((String)"Humidity: " + h + "%");
}
```

Here is the project running:

![LCD display showing live temperature and humidity readings - Temp: 19.1C and Humidity: 69.60% on blue screen](https://flaviocopes.com/images/arduino-project-digital-thermometer/IMG_3700.jpg)
