#343 ESP8266 DHT11 Sensor
Reading temperature and humidity with a DHT11 sensor and ESP-01, coding with ESP8266 core for Arduino.

Notes
The DHT11 sensor is a very cheap and common sensor that provides readings of:
- relative humidity: 20-80% ±5%
- temperature: 0-50°C ±2°C
I’ve used this before with an Arduino - see LEAP#301. This time I’m testing with the most basic ESP8266 board - an ESP-01, which exposes one free GPIO.
DHT11 Module
I am using a DHT11 that is mounted on an adapter board that includes pull-up resistor for the data line, and a decoupling capacitor, similar to “New Temperature and Relative Humidity Sensor DHT11 Module with Cable for arduino Diy Kit” (aliexpress seller listing).

Programming Setup
I’m using a LEAP#194 DIYDevBoard to host the ESP-01 module, and a cheap CH340G-based USB to UART adapter. With the correct drivers installed, it shows up in the tty device list.
My host computer is running macOS.
Required Libraries
I’m using ESP8266 core with the Arduino IDE, and the Adafruit sensor library to interface with the DHT11:
These need to be installed in the Arduino IDE.
Test Sketch
The DHT11.ino sketch simply reads the sensor every 2 seconds and outputs the readings to the serial port.
Here is a test run:

Construction



Credits and References
- “DHT11 Humidity & Temperature Sensor” datasheet (mouser.com)
- ESP8266 core for Arduino
- Adafruit Unified Sensor Library
- DHT Sensor Library
- LEAP#194 DIYDevBoard - the dev board I’m using to host the ESP-01
- LEAP#301 DHT11/Basics - similar project for an Arduino
- ..as mentioned on my blog