← Back

Temperature sensor

Built on XDAWant to build your own cheap smart home sensors? Here's how I got started with the ESP32By Adam Conway
ESP32 DevKit V1

DHT11 temperature and humidity module

DATAD2GNDGNDVCC3V3

Compatibility checks

1 warning

  • DHT11 temperature and humidity module uses D2, which must be low to upload code; a pull-up can stop uploads.

Wiring steps

  1. 1

    DHT11 temperature and humidity module

    • GNDtoGND
    • VCCto3V3
    • DATAtoD2
  2. 2

    Plug in the USB cable last.

ESPHome config

Paste into ESPHome Device Builder.

esphome:
  name: temperature-sensor

esp32:
  board: esp32dev

logger:
api:
  encryption:
    key: !secret api_encryption_key  # make one at esphome.io/components/api
ota:
  - platform: esphome
    password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

sensor:
  - platform: dht
    pin: GPIO2
    model: DHT11
    temperature:
      name: "DHT11 Temperature"
      id: reading_1
    humidity:
      name: "DHT11 Humidity"
      id: reading_2
    update_interval: 60s

Some board drawings are from Wokwi and Seeed Studio.