Using the DHT11 Temperature Sensor with Espruino on a NodeMCU

DHT11 Temperature Sensor

  • There is a DHT11 module available for use
  • Require the module using the Web IDE to download and install it.
  • Set which data pin on the NodeMCU is connected to the data pin on the DHT11.
  • Temperature is in Celsius, RH is in %.
  • To convert from Celsius to Fahrenheit: F = (C * 1.8 + 32)
  • Connect the VCC pin to a 3.3v power pin
  • Connect the GND pin to a GND pin.
  • Connect the Data pin to pin D4.

var pin   = NodeMCU.D4;
var dht11 = require("DHT11").connect(pin); (a) {
  var c = a.temp;
  var f = (a.temp * 1.8 + 32);
  console.log("Temp is "+c.toString()+"C ("+f.toString()+"F) and RH is "+a.rh.toString());

// Temperature is in C, RH is in %.

Bare vs. Shielded DHT11

  • A DHT 11 with a shield has 3 pins.
  • A bare DHT11 has 4 pins.
  • In either case, 3vs4 pins, there are only 3 pins used: Signal, Vcc (+), Ground (-).
  • The shielded, or PCB mounted, version includes a 10K Ohm pull up resistor for the signal line.

categories: espruino | esp8266 | nodemcu |