In this guide, I will walk you through the full process of building your own WiFi-enabled thermostat using cheap, easy-to-find parts. With some basic electronics knowledge and less than $20 in materials, you can construct a connected thermostat that allows you to control your home's temperature right from your smartphone.

Overview of the Build

Here is a high-level overview of the main steps we will walk through:

Selecting the Microcontroller

The ESP8266 is a low-cost yet powerful microcontroller with integrated WiFi. It can connect directly to your home WiFi network and be controlled remotely. There are a variety of ESP8266 development boards available for just a few dollars. The NodeMCU or Wemos D1 Mini boards are two popular, inexpensive options.

For this project, I chose the Wemos D1 Mini because of its small form factor and ease of use. It has a built-in USB port so it can be easily programmed and powered from any computer or charger. And the integrated WiFi antenna provides good range.

The Wemos D1 Mini packs a lot of punch for the price. Key specs:

With WiFi, plenty of GPIO pins, and Arduino-compatible firmware, this $4 board has everything needed for an IoT thermostat.

My Reasons for Choosing the Wemos D1 Mini

I selected the Wemos D1 Mini for several reasons:

For this low-cost DIY build, the Wemos checks all the boxes!

Adding Temperature and Humidity Sensing

To create a useful thermostat, we need to be able to monitor the ambient temperature and humidity. For this, I chose the DHT11 sensor. This is an inexpensive, widely used digital temperature and humidity sensor.

The DHT11 provides fairly accurate readings with standard 5V power and a single data pin connection.

Key specifications:

This sensor contains all the logic and circuitry inside needed to read humidity and temperature levels and output a digital signal. So it's very easy to connect to a microcontroller like the ESP8266.

I opted for the DHT11 over the very similar DHT22 because:

By keeping costs down and fitting into a smaller case, the DHT11 is a smart choice here.

Adding a Display

To be able to see the current temperature and humidity at a glance, our thermostat needs some sort of display.

The simplest option is an LCD character display. These low-cost modules provide an easy way to output textual data like numbers and text.

For this build, I chose a 16x2 LCD display. This provides:

Connecting the LCD only requires 6 wires - 5V power, ground, and then one pin each for digital data, clock signal, and reset. Most microcontrollers have plenty of GPIO pins to handle this.

The 16x2 size shows the key info like temperature and humidity while keeping the display portion compact. And costs under $5.

Why I Picked a 16x2 Character LCD

After considering different display options like OLED and e-ink, I settled on the 16x2 LCD for the following reasons:

For showing a few lines of text, the tried and true LCD is a practical choice here.

Developing the Thermostat Software

The software side of this project involves two main components:

  1. Arduino sketch running on the ESP8266 to control the hardware
  2. Web server code to handle the WiFi interface

Luckily, we can make use of existing Arduino libraries and examples to simplify development.

For the microcontroller side, we need to:

And on the web server:

By piecing together some existing Arduino example sketches, we can get the key functionality working without too much code.

The sketch will be written in the Arduino IDE then uploaded to the Wemos D1 Mini board.

Assembling the Circuit

Here are the steps I followed to assemble this on a breadboard:

  1. Insert the Wemos D1 Mini board
  2. Connect the DHT11 sensor to 3.3V power and a data pin like D1
  3. Connect the 16x2 LCD module to 5V and the following control pins:
  4. D2 for Register Select (RS)
  5. D3 for Enable (EN)
  6. D4 for Data (D4)
  7. D5 for backlight power
  8. Connect buttons to pins D6 and D7 for adjusting setpoint up/down
  9. Power the Wemos by USB or 7-12V input

Once wired up on the breadboard, the circuit can be tested and debugged as needed.

Creating the Enclosure

For the enclosure, I opted for a compact 3D printed case. This holds the Wemos board, breadboard, LCD display, and DHT11 sensor together in a tidy package.

I designed it in Tinkercad using precise measurements of the components. The case design includes:

Printed in PLA plastic, the case measures 4" x 3" x 1.5" and can be placed anywhere just like a traditional thermostat.

For a sleek look, I chose a black semi-gloss PLA filament and went with a 20% infill setting for durability.

Total Cost Breakdown

Here is the final cost breakdown for the main components used in this project:

Grand Total: $18

Coming in under the $20 budget, this proves you can create an impressive IoT device very affordably.

Having the ability to view and control the temperature of your home from anywhere provides real value. And given the low component cost, this DIY WiFi thermostat can pay for itself in energy savings over time.


In closing, with some basic electronics components costing less than $20 total, I was able to construct a fully functional web-connected thermostat with temperature and humidity display.

Following the steps outlined here, you can create your own low-cost WiFi thermostat that gives you smart heating control using the existing Arduino environment.

The same approach could also be adapted to control other devices like lights, motors, or appliances based on sensor input. The possibilities are endless when it comes to inexpensive home automation with ESP8266 boards and a bit of coding. Let me know if you end up building your own thermostat after reading this!