Wireless temperature and humidity sensor (MQTT enabled)

Posted by David Husselmann on

Handy for home automation projects, this wireless temperature sensor reports the current temperature and humidity to an MQTT broker of your liking every 5 seconds.

Parts required


Make the following connections:

  1. GND on power supply to:
    1. GND on ESP8266
    2. GND (pin 4) on DHT11
  2. +3.3V on power supply to:
    1. CHPD on ESP8266
    2. VCC on ESP8266
    3. Pin 1 on DHT11 (leftmost)
  3. Connect a 4.7k resistor between pin 1 and 2 of the DHT11.
  4. Connect pin 2 on the DHT11 to GP2 on the ESP8266.

The following pins should remain unconnected: DHT11 pin 3, ESP8266 GP0, RXD, TXD and RST.


Programming the ESP8266

While we're not going to go into a detailed guide on how to program the ESP8266, here is a sample sketch that should get you up and running.  Please note the following:

 When everything is up and running, you should see the following topics being published approximately every 5 seconds:

tempsensor/temperature 24
tempsensor/humidity 54

Where 24 is the temperature, in degrees Celsius, and 54 is the relative humidity (percentage).

The final product

Share this post

← Older Post Newer Post →