DHT11 sensor data to Thingspeak using a Wemos D1

In this example we will connect a DHT11 sensor to our Wemos D1, we will then send the temperature and humidity values to thingspeak.

DHT11 digital temperature and humidity sensor is a composite Sensor contains a calibrated digital signal output of the temperature and humidity. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability. The sensor includes a resistive sense of wet components and an NTC temperature measurement devices, and connected with a high-performance 8-bit microcontroller.

Typically a DHT11 can be bought in a basic breakout board format but can be bought as a standalone part as well, here is a picture of a typical breakout board, this board holds the sensor and a resistor, the resistor is connected between Vdd (3v3) and the signal pin on the board.

If you do not use a module like the one aboveyou can build a similar circuit on a breadboard. Here is a typical schematic, which is basically what the breakout above actually is

You will connect the Gnd of the module (DHt11) to a Gnd on your Wemos board, connect 5v or Vdd of the module (DHt11) to a 3v3 connection on your Wemos and the Sig pin (data pin on the DH11) goes to whatever input you decide to use on your Wemos, in the code below you can see this as

#define DHTPIN 2

You will now need to create a new account at thingspeak – https://thingspeak.com. Once done create a new channel and add two new fields, one will hold the temperature reading and the other will hold the humidity reading from our DHT11. This should look something like this

45 comments to DHT11 sensor data to Thingspeak using a Wemos D1

I’m new in Arduino programming and I try to make wemos sensor data, but i have KY-015 whit dht11 sensor, but vhen I connect it and upload your code it cant read from sensor. Can you help me whit changes in sketch that I need to make?

In the ARduino IDE, when you open the Serial monitor at 115200 do you see any output. The Serial.print lies are effectively only useful for debug. The key one is Serial.println(“Failed to read from DHT sensor!”);. All I could recommend is that you double check your wiring in particular the data connection which in this case is the pin with the S beside it

Are you using the correct com port in the Arduino IDE for the board
If you disconnect any external devices connect to the device does the upload work then?
Try another USB cable – I have had issues with cheaper and nasty ones (its not common though)
If you had another board you could try that with nothing attached.

Basically you are just ruling things out – incorrect settings, power issues, faulty hardware

What DHT-library did you use? The one I have installed has got a file named dht.h instead of DHT.h. After I have changed the sketch at 2 lines (“#include ” and “dht dht(DHTPIN, DHTTYPE);”), I got these errors:

Now I got the libs working (2 folders “Adafruit_Sensor-master” and “DHT-sensor-library-master”). I have gotten “Failed to read from DHT sensor!” and “fatal exeption”. Do you have a sketch without wifi/thingspeak that I can try? Thanks.

Sorry I didn’t add a reply (see below for my first reaction). In the meantime I noticed that “D2” doesn’t work for my, neither does “2”. I have to use “5” (and put the wire in connection “D15/SCL/D3”). With this change I shall try your sketch again tomorrow.
The values for temperature en humidity are both too low, resp. 2 degrees celcius and 20%. Is there a simple solution for that?

I am using a D1R1 board, same as pictured above, but am unable to make this work on D2, although I can make it work on D5. I tried an even simpler program, doing a digitalRead on pin 2 (with D2 tied to a pushbutton to ground and a pullup resistor) and it seems to read the value at boot, but doesn’t show changes. Same for D3.
I’m compiling with board set to WeMos D1(retired).
Any thoughts on what’s going on?

Thanks for this mate it works perfectly, the only thing i had to change was the ssid name/password and the D2 pin to D8 (one im using for the dht11). Massively appreciate it, hope you’re still creating!

after the compile, the error message as follows. What is wrong?. Please help…

In file included from d:\Arduino\libraries\DHT_sensor_library\DHT_U.cpp:22:0:
d:\Arduino\libraries\DHT_sensor_library\DHT_U.h:25:29: fatal error: Adafruit_Sensor.h: No such file or directory
#include
^
compilation terminated.
Multiple libraries were found for “DHT.h”
Used: d:\Arduino\libraries\DHT_sensor_library
Not used: d:\Arduino\libraries\Grove_Temperature_And_Humidity_Sensor
Using library DHT_sensor_library at version 1.3.0 in folder: d:\Arduino\libraries\DHT_sensor_library
Using library ESP8266WiFi at version 1.0 in folder: C:\Users\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\libraries\ESP8266WiFi
exit status 1
Error compiling for board WeMos D1 R2 & mini.

Great example! It took me 5 minutes to register at thingspeak.com and 5 minutes to upload the code into my Wemos D1; little change – DHT22 insteasd of DHT11 as the latter is not so accurate. Thanks a lot + wishes for new creations!

For a school project we need to get data from a temperature/humidity sensor (DHT11) and a dust sensor written to a SD card. Our group like to go further so we bought the Wemos and make it upload the data from the DHT11 to thingspeak to our own website.
We got it to work, but we can’t get the dust sensor to work correctly, it’s a Shinyei PPD42. We can’t get the script working correctly.
Can anybody help us?