Introduction: Temperature With Power Saving

Since my study was not always at the best temperature, I decided it would be useful to display the ambient temperature on my desk. The cost of a sensor that provided humidity, in addition to temperature, was not prohibitive; therefore that was what was chosen.

Both the DHT11 and DHT22 sensors I considered provide temperature results in Centigrade. Fortunately it is an easy conversion to Fahrenheit (the format used in the USA, which is my location) . The sketch below displays temperature in both Fahrenheit and Centigrade, so it is applicable to whatever region of the world you are located in.

My initial project only involved temperature measurement, but since adding humidity was not too costly, I to include that at a future date.

There are many published examples on-line showing how to display humidity and temperature using an Arduino UNO, some include displaying the results on an LCD. In this Instructable, we will also display the results on an LCD, but with the addition of power conservation that allows the LCD backlight to be toggled on and off when the display is not needed. This ability was meaningful to me, as I prefer to be able to turn the display off when I am not in the study.

If you are using a “wall wart” extra power consumption may not be of overwhelming importance, but if you are powering the display from a battery it likely is, as reduced power consumption will extend a battery’s life.

I considered both the DHT22 and the DTH11/12 sensors, and settled on the DHT22, although slightly more expensive. The DHT11 can often be purchased for less than $2, while the DHT22 is often found for less than $5. If purchased directly from China, the cost can be even less. If I only wanted to display temperature, I could have used instead the TMP36 sensor and realized some savings, and indeed this is how I built an earlier DIY of mine. However, I decided to include a humidity display in this project.

The DHT22 is slightly more accurate than the DHT11. So, the slightly higher cost of the DHT22 seemed reasonable. Both DTH devices contain capacitive humidity sensors. These humidity sensors are widely used for industrial and commercial projects. While not extremely accurate, they are capable of functioning at relatively high temperatures and have a reasonable resistance to chemicals in their surroundings. They measure the changes in a dielectric that are produced by the relative humidity of their surroundings. Fortunately, the changes in capacitance are essentially linear in relation to humidity. The relative accuracy of these sensors can be easily seen by placing two of them side-by-side. If this is done it will be seen that they differ by, at most, 1 or 2 percentage points.

The DHT11/22 sensors can easily be substituted for each other. Depending on cost constraints, if any, either sensor can be chosen. They both come in similar 4-pin packages that are interchangeable, and as we will see shortly only 3 of the 4 pins on either package will be needed to build the desktop humidity and temperature display presented here. Although only three pins are needed for use, the four pins provide additional stability when these DHT sensors are placed/mounted on a breadboard.

As will be seen in this Instructable, the project requires very few components as the majority of the “heavy lifting” is performed by the sensor and the sketch.

Step 1: The Required Items.

The required items are:

- An experimental platform

- An LCD shield

- A DHT22 (AOSONG AM2302) digital temperature and humidity sensor.

- Female headers to be soldered on the LCD shield. I used 5, 6, and 7-pin female headers (although if you select the alternative shield, also shown here, no headers will be needed). Male header pins can be substituted for the sockets, and if used only the gender of one side of the three Dupont hook-up wires will need to be changed.

- Three Dupont hookup wires (That is correct, only 3 wires are needed)

- An Arduino UNO R3 (Other Arduinos can be used in place of the UNO)

- A USB cable to upload your sketch from a computer to the UNO

A device such as a “wall wart” or battery to power the UNO after it is programmed. All required items are readily found on Amazon, eBay, Banggood, etc.

You possibly already have many of the needed items, if not all, on your workbench, although some may need to be purchased. When you have all the required items for this project, let’s begin. Although if you have the first few, it is possible to start while waiting on the others.

Step 2: Preparing the Experimental Platform

The experimental platform comes in a vinyl bag containing a 120mm x 83mm Plexiglas sheet, and a small plastic bag containing 5 screws, 5 plastic standoffs (spacers), 5 nuts and a sheet with four bumpers, self-adhesive feet. All four bumpers will be needed, as will four each of the other items. There is an extra screw, standoff, and nut that are not required. However, the bag does not contain instructions.

Initially the vinyl bag is cut open to remove the Plexiglas sheet and the small bag. The Plexiglas sheet is covered on both sides with paper to protect it in handling and transit.

We need to peel the paper back on each side of the platform and remove the two sheets. Once the paper is removed from each side, the four holes for mounting the Arduino to the platform are easily seen. I found it easiest if after peeling the paper away, the acrylic sheet is placed with the four holes on the right, and the holes closest together and near one edge of the acrylic board, facing me (as can be seen in the attached picture).

Step 3: Mounting the Arduino UNO or Clone to the Experimental Platform.

The Arduino UNO R3 board has four mounting holes. The transparent spacers are placed between the underside of a UNO R3 and the upper side of the acrylic board. Working on my first experimental board I made the mistake of assuming that the spacers were washers that should be placed underneath the Plexiglas board to hold the nuts in place - they should not. The spacers are positioned underneath the Arduino UNO board, around the screws after the screws pass through the UNO's mounting holes. After passing through the board the screws pass through the spacers and then through the holes in the acrylic Plexiglas board. The screws are terminated by the nuts enclosed in the small package. The screws and nuts should be tightened to insure that the Arduino will not move when in use.

I found it easiest to start with the hole nearest the reset button (see photos) and work my way clockwise around the Arduino. The UNO is attached to the board, as might be expected, using one screw at a time.

You will need a small Phillips head screwdriver to turn the screws. I found a socket to hold the nuts was quite helpful, although not necessary. I used drivers made by Wiha and available on Amazon [a Wiha (261) PHO x 50 and a Wiha (265) 4.0 x 60]. However, any small Phillips head screwdriver should work without problem, and as noted previously a nut driver is not really required (although it makes mounting quicker, easier, and more secure).

Step 4: Mounting the Half-size, 400 Tie Points, to the Experimental Platform.

The underside of the half-sized breadboard is covered with paper pressed onto an adhesive backing. Remove this paper and press the breadboard, with its now exposed adhesive backing, onto the experimental platform. You should try to place one side of the breadboard parallel to the side of Arduino it is closest to. Simply press the self-adhesive side of the breadboard onto the acrylic board.

Next, turn the platform over and mount the four included plastic feet on the four corners of the platform’s underside.

Whatever experimental platform you use, when you finish you should have both the Arduino UNO R3 and a half-size breadboard mounted on it, and four feet on the underside to allow the platform and breadboard to be placed on any flat surface without marring that surface, while providing firm support to the assembly

Step 5: The LCD Shield

You can use a shield, such as the one shown earlier with pins already soldered on. However, such a shield has pins rather than sockets, so the Dupont breadboard cables must be chosen accordingly. If so, you only need to mount it onto the UNO. When mounting be sure that you mount the shield in the correct orientation, with the pins on each side of the shield lined up with the sockets on the UNO.

If you use a shield, such as the one I use here, without pins already soldered in place set aside female headers with 5, 6, and 7 sockets, respectively, to solder onto the shield. The sockets of these headers should be on the component side of the shield when you solder them on (see photographs). Once the headers are soldered in place, you can proceed in a similar manner to that for a shield purchased with the pins already soldered on. I chose to use M-M Dupont cables as opposed to M-F cables, as I generally prefer M-M cables.

Whichever shield you select to start with, when you finish you should have a shield mounted on top of the Arduino UNO. Either shield, the one with pre-soldered pins or the one you soldered yourself with female headers, uses quite a few digital pins. Fortunately, digital pins D0 through D3 and D11 through D13 are not used by the shield, and so are available for use. Analog socket A0 is used by the shield to hold the results of button presses. Thus, analog pins A1 through A5 are free to use.

I find it easiest to use a breadboard with male headers inserted to hold the female headers for soldering (see photographs).

Digital pin 10 is used for the LCD’s backlight display, and we will use it in our sketch to control power to the LCD when the display is not in use. Specifically, we will use the “LEFT” button on the shield to toggle the backlight on and off to save power when the display is not needed.

Step 6: Using the DHT22 Humidity and Temperature Sensor

Insert the four pins of the DHT22 into the half-size breadboard, thereby mounting the sensor on the breadboard.

The DHT22 has four pins. I numbered these pins 1 to 4 as shown in the included photograph. The power to the sensor is provided via pins 1 and 4. Specifically, pin 1 provides the +5v power, and pin 4 is used for ground. Pin 3 is not used, and pin 2 is used to provide the information needed for our display.

Connect the three pins that are used on the DHT22, using their associated holes on the breadboard, to the shield, and thus the Arduino UNO as follows:

1) Pin 1 of the sensor goes to the shield’s 5v power socket,

2) Pin 4 of the sensor goes to one of the shield’s GND connectors,

3) Pin 2 of the sensor, the data output pin, goes to digital socket 2 on the shield and thus to D2 on the UNO, no analog connectors are required.

The DHT22 sensor can only provide updated information every 2 seconds. That is, if you pole the sensor more than once every two seconds you may get results that are dated.

Step 7: The Sketch

I have included the sketch I used below.However, this site removes less than and greater than symbols and the text in between these symbols. Thus, if you want to see the sketch as written just download the attached text file.


Sketch to display humidity and temperature on the desktop

Written by R. Jordan Kreindler, July 2016

Uses an LCD Shield to display Humidity, as well as Fahrenheit and Centigrade

room Temperatures.

With the press of the ‘Left’ button the LCD backlight turns off and

with another press of this button the backlight turns back on.

The DHT22 sensor provides Centigrade temperature values which can be easily

converted to Fahrenheit.


#include DHT.h

#include LiquidCrystal.h

// Be sure and encase the DHT.h and LiquidCrystal.h inside less than and greater than signs.

// The LCD shield uses digital pins 4 through 9

// and analog pin A0(for the buttons)

LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // Define a LiquidCrystal object, lcd

int DHTData = 3; // The data pin from the DHT22 is digital pin 3

DHT dht(DHTData, DHT22);// Define a DHT object, dht

int humidity = 0; // Holds humidity results as an integer

float cTemp = 0.0; // Holds Centigrade temerature results as a float

int centigradeTemp = 0; // The Centigrade temperature after conversion to int

int fahrenheitTemp = 0; // Will hold the converted to Fahenheit temperature

int i = 0; // A for loop index

int delay1 = 700; // The time between text displays

boolean backlightOn = true; // Holds state of backlight

int adcValueRead = 0; // Start with a value in adcValueRead

void centered(int line, char str1[]) {

// Written by R. Jordan Kreindler June 2016

int length1 = strlen(str1);

int spaces = (15 - length1) / 2.0;

lcd.setCursor(0, line);

lcd.print(" "); // Should show 16+ spaces between quotes, but removes spaces

lcd.setCursor(0, line);

for (i = 0; i <= spaces; i++) {

lcd.print(" ");




void setup() {

lcd.begin(16, 2);


pinMode(10, OUTPUT); // Set pin 10 for output to turn backlight on/off

digitalWrite(10, HIGH); // Set LCD backlight on

dht.begin(); //Starts the DHT22 sensor

lcd.setCursor(0, 0);

lcd.print("'Left' is On/Off");


void loop() {

humidity = round(dht.readHumidity()); // Not really required here

lcd.setCursor(0, 1);



lcd.print(" ");

cTemp = dht.readTemperature();

centigradeTemp = round(cTemp);

fahrenheitTemp = round(cTemp * 9.0 / 5.0 + 32.0);



lcd.print(" ");



lcd.print(" ");

adcValueRead = analogRead(14); // Check if any buttons pressed

if ( (adcValueRead >= 400 && adcValueRead <= 500) && backlightOn == true) {


lcd.print("Powering off ");

for (int i = 1; i < 4; i++) {




digitalWrite(10, LOW); // Set LCD backlight off

backlightOn = false;

adcValueRead = 5000;


if ( (adcValueRead >= 400 && adcValueRead <= 500) && backlightOn == false ) {


digitalWrite(10, HIGH); // Set LCD backlight on


lcd.print("Powering on ");

for (int i = 1; i < 4; i++) {




backlightOn = true;


lcd.setCursor(0, 0);

lcd.print("'Left' is On/Off");



Step 8: The Assembled Project in Use

I mounted my assembled project on a business card holder (see photograph). The business card holder shown in the attached photograph was available in my ‘odds and ends’ collection, so I used it. However, the assembled project could just as easily be placed and displayed on a mobile phone holder. Any holder that takes the assembled project from a flat position to an angle of 30-60 degrees should work well.

Step 9: Afterwards

Congratulations, if you followed the steps above you now have your own display, including a power saving mode.

If you decide you would like to extend the information displayed, this Instructable can serve as a starting point. In another project I added a real time clock (RTC) module, in addition to the sensor used here, so I could include the day of the week, month, day of the month, and current time in the display. I also presented less information (I did not include the temperature in Centigrade) on line two of the display so I could include the %, percent, and ⁰, degree, symbols (see attached photograph).

Perhaps, this Instructable may suggest possible follow-on projects for you, in addition to the date and time display discussed in this step.

If you would like to contact me with any questions or for additional information, or to expand my knowledge in the area presented, I can be reached at (please replace the second 'i' with an 'e' to contact me.