Proj: ESP8266 Remote temperature and humidity sensor

From West London Hackspace Wiki
Jump to: navigation, search

You will need:

  • NodeMCU or similar but the pin references will be different
  • DHT11 or DHT22 temperature and humidity sensor
  • jumper wires - in the simplest form three female-female wires, ideally red, black and some different colour

An internet connection is also required, or at least a wireless LAN that you can access from a PC.

Connect DHT sensor:

black wire to Gnd
red wire to Vcc
coloured wire to Data

Connect NodeMCU

black wire to Gnd (the one near D4 is a good position)
red wire to 3V3 (the one next to D4 is a good position)
coloured wire to D4 (which is actually GPIO2)

Now install the library Adafruit / DHT-sensor-library [1] by pressing the 'Download ZIP' button in GitHub, opening the resulting ZIP and copying the resulting folder to the arduino/libraries folder.

Open the Arduino IDE and under File / Examples you should now see "DHT sensor library" and a sketch DHTtester which you should open.

Near the top check that the line "#define DHTTYPE DHTxx" references the right type of sensor and change the pin in "#define DHTPIN x" to 2 (GPIO2 which is D4 on the NodeMCU).

<--Just below that change the value of 'ssid' to -->

Open the serial monitor window, upload the sketch and watch.

(Coming soon - the 'wireless' side of this example)