Home > Espressif, Hardware, Linux, Testing, Ubuntu > Getting Started with Wemos D1 mini ESP8266 Board, DHT & Relay Shields

Getting Started with Wemos D1 mini ESP8266 Board, DHT & Relay Shields

Wemos D1 mini is an ESP8266 board that’s interesting thanks to its size, its low price ($4), micro USB power, its shields, and a documentation that looks fairly good. The board can be programmed with Arduino or Lua, and supports both serial and OTA programming. I’ve decided to give it a try and bought the board together with two temperature shields, a relay shield, and micro SD shield.

Click to Enlarge

Click to Enlarge

I got all for $ 14.00 from Wemos Aliexpress shop, and it took about one month for delivery. I can also see they’ve recently released a new OLED shield selling for about $5. All shields were shipped inside their own anti-static bags.

The pins are clearly marked on both side of the board and the shields. One side of the board features ESP8266 module.


and the other side has CH340 serial to USB chip, and the reset button.


The provided headers make it easy to stack the board with several shields if you wish too. For example I connect Wemos D1 mini to both the relay shield, and DHT Pro shield after soldering some of the headers. The only potential pitfall would be to solder the header on the wrong side, so you just need to make sure the pins (5V, RST,…) are properly aligned.


I’ve mostly followed the Getting Started in Arduino guide in Wemos.cc in this tutorial, and people who prefer Lua/NodeMCU will want to check NodeMCU guide instead. There are various ways to configure the Arduino IDE for WeMos D1 mini in the guide, but I’ve only used the recommended way: git.

The first step was to install and run Arduino 1.6.8. Since I’m using a computer running Ubuntu 14.04 64-bit, I downloaded and installed Arduino 1.6.8 64-bit for Linux:

Now get the sketchbook folder by going to File->Preferences


Note this folder as this is where we’ll install the board support, tools and examples, and exit Arduino before starting the installation:

download the binary tools:

and finally install the examples:

Later on, you can update the board support files and the samples by running git pull in the two directories where you ran git clone.

Now connect Wemos D1 mini to a USB port of your computer with a micro USB to USB cable. In Linux, you should see a new device in the kernel log:

Let’s start Arduino 1.6.8 and select WeMos D1 R2 & mini in Tools->Board.

Arduino_1.6.8_Wemos_D1_miniWe can use the default for the other settings include 80 MHz CPU frequency, 4M flash size, 912600 upload speed, and /dev/ttyUSB0 port.

We can now use the code samples, and to make sure everything works I’ll run the blink project in File->Sketchbooks->D1_mini_Examples->01. Basics->Blink:

Pressing the Upload button will build and upload to code to the board and once this is complete, the build-in Blue LED (D4 / GPIO2) will blink every second. So my board is working.


As you can see I’ve already connected DHT Pro shield to the board, so let’s try the sample for the shield to get the temperature and humidity in File->Sketchbooks->D1_mini_Examples->04. Shield->DHT_Pro_Shield->Simple:

But this time I had an error during compilation, as DHT library is missing:

To fix that error, go to Sketch->Include Library->Manage Libraries, input dht to filter the library, and install DHT sensor library by Adafruit.

Install_DHT_LibraryNow click on the Upload button again, the code will be compiled and uploaded to the board. Now open the serial monitor with Ctrl+Shift M or Tools->Serial Monitor, and you should see the printed values for the humidity in percent as well as the  temperature & heat index in Celcius and Fahrenheit.

Wemos_D1_mini_Temperature_HumidityThe reported temperature matched the temperature reported by my IR thermometer (32.5 C). Pretty good. If you’d like to get results displayed on a web page instead, you may want to modify DHT Shield->SimpleServer sample.

Now I’ll had the relay shield on top, and run another sample (File->Sketchbooks->D1_mini_Examples->04. Shield->Relay_Shield->Blink):

The relay blink sample will turn on and off the relay every two seconds. Since the DHT Pro shield uses D4 pin and the Relay shield uses D1 pin both can be used at the same time. I had no problem uploading the sample to the board, and hearing the relay switch on and off every 2 second.

So overall, I’m very pleased with WeMos D1 mini and the shields I tried, as everything pretty much worked out of the box, and I’ve got an ultra-compact WiFi connected system with a 5A/250V relay, and a fairly accurate (+/- 0.5C) temperature and humidity sensor for around $10.

  1. March 22nd, 2016 at 21:59 | #1

    Some commands messed up in 2nd and 4th code block !

  2. March 23rd, 2016 at 17:30 | #2

    I am successfully running esp-link firmware on those.

    I have also discovered platformio yesterday which supports UNOs and also the ESP8266 based boards.

  3. March 23rd, 2016 at 22:13 | #3

    I also found this new firmware:


    Thanks to that discussion:


    I tried to reflash but I end up with this error:


  4. Dave
    March 24th, 2016 at 10:51 | #4

    I have a couple with the DHT pro shields. It’s a nifty package, but the esp8266 (or possibly the voltage regulator) seems to be heating the whole thing by enough to have them reading higher than ambient by about 2 degrees C. (Admittedly, my local ambient is quite a bit lower than yours, so the heating effect may be more noticeable here…)

    And I’m just sending my temps to ThingSpeak. Eventually, I’ll probably do something MQTT-ish, but for basic debugging, ThingSpeak works pretty darn well for the price. 🙂

  5. March 24th, 2016 at 11:31 | #5

    That would be really convenient to use if that can be made to work on Wemos D1.

    I’m also thinking about sending data to the cloud, but I’m not quite sure which solution to use yet, so maybe I’ll try ThingSpeak, or host something myself.

  6. Paul
    March 27th, 2016 at 20:19 | #6

    FYI, recently Kickstarted MicroPython port (https://github.com/micropython/micropython/tree/master/esp8266) also shapes up nicely. There’s pretty complete support for sockets and hardware protocols (I2C, SPI) now. More work is under way of course!

  7. ludvik
    June 18th, 2016 at 03:39 | #7

    I got “Failed to read from DHT sensor!” every time

  8. June 18th, 2016 at 09:20 | #8

    Likely one of two reasons: issue with the hardware itself, or module plugged in the wrong side.

  9. Joe Q
    June 25th, 2016 at 19:18 | #9


    Exact same observation here. I am logging data every 20 seconds and can “see” the sensor heat up over its first 15-20 minutes of operation, after which it reaches a steady state.

  10. stockdam
    October 16th, 2016 at 03:23 | #10

    Worked perfectly for me after a few problems uploading the sketch (I got a fake Wemos so that’s probably a reason). Uploading sketches appears to be better when the shields are removed; upload the sketch, power off the Wemos, add the shield and power back on again.

  1. No trackbacks yet.