user17055: When run this code on an Arduino Uno (clone), everything works. 
When I run it on my LoLin NodeMcu, I get the following verbose upload output: 
esptool v0.4.9 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM4
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

The only difference I really see is that on the Arduino Uno, the voltage pin is connected to 5V, while on the LoLin, it's connected to one of the 3V pins. Does the DHT11 require 5V?
Edit
So I stumbled upon this list of port mappings. When I change my pin number to 5 (meaning D1), it actually works. Kinda. The numbers outputted are strange. Even when I put the board outside, in about -6 Celcius, it still displays 
Temp 247.208 °C
RH 216.208 %

Well, I guess this oddity should be posted as another question. I'll answer my own question here with reference to the weird pin-to-number mapping on the LoLin board.

user17055: The problem was that the port mappings on the LoLin board didn't make much sense. 
Port D0 is for instance mapped to number 16, not 0. 
Go to this Github comment to get a complete list:
/*
 * Weird pin mappings on LoLin:
 * 
 * static const uint8_t D0   = 16;
 * static const uint8_t D1   = 5;
 * static const uint8_t D2   = 4;
 * static const uint8_t D3   = 0;
 * static const uint8_t D4   = 2;
 * static const uint8_t D5   = 14;
 * static const uint8_t D6   = 12;
 * static const uint8_t D7   = 13;
 * static const uint8_t D8   = 15;
 * static const uint8_t D9   = 3;
 * static const uint8_t D10  = 1;
*/

Missing decimal digits and not able to measure sub zero values
If this comment on github is correct, the DHT11 sensor does not offer decimals and does not measure values below zero.

user32037: I was scratching my head since last two days over similar issue. I am using ESP8266 NodeMCU which is V2 of LoLin NodeMCU and wanted to read DHT11 sensor data over WiFi into blynk app. However my serial output was 'Failed to read from DHT sensor!'. The program and interfacing was working perfectly with Arduin Uno and Raspberry Pi but not with NodeMCU.
Being a hardware guy, I tried all sorts of hardware modification possible. I had DHT11 sensor module which is already having 5k pull up resistors on board. Since NodeMCU board doesn't have 5V supply, I desoldered the sensor and did direct interfacing with 10k resistor as recommended by adafruit DHTxx guide. Doing internet search , someone recommended IDE version issue, tried that too. Nothing worked.
Finally referring per @nitech answer, I checked the pin details of NodeMCU board and got the idea of D2 pin actual mapped on GPIO4. Just changed the pin 2 with 4 in example code and it worked. Voila! I think recent race in achieving most of the boards as Arduino shield and IDE standard compatible, we need to be used for such issues for any deviation.

17055: <p>When run <a href="https://tkkrlab.nl/wiki/Arduino_KY-015_Temperature_and_humidity_sensor_module#Schematic" rel="nofollow noreferrer">this code</a> on an Arduino Uno (clone), everything works. 
When I run it on my LoLin NodeMcu, I get the following verbose upload output: </p>

<pre><code>esptool v0.4.9 - (c) 2014 Ch. Klippel &lt;ck@atelier-klippel.de&gt;
    setting board to nodemcu
    setting baudrate from 115200 to 115200
    setting port from COM1 to COM4
    setting address from 0x00000000 to 0x00000000
    espcomm_upload_file
    espcomm_upload_mem
    setting serial port timeouts to 1000 ms
opening bootloader
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
resetting board
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
trying to connect
    flush start
    setting serial port timeouts to 1 ms
    setting serial port timeouts to 1000 ms
    flush complete
    espcomm_send_command: sending command header
    espcomm_send_command: sending command payload
    read 0, requested 1
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
</code></pre>

<p>The only difference I really see is that on the Arduino Uno, the voltage pin is connected to 5V, while on the LoLin, it's connected to one of the 3V pins. Does the DHT11 require 5V?</p>

<p><strong>Edit</strong></p>

<p>So I stumbled upon <a href="https://github.com/esp8266/Arduino/issues/584#issuecomment-123715951" rel="nofollow noreferrer">this list of port mappings</a>. When I change my pin number to 5 (meaning D1), it actually works. Kinda. The numbers outputted are strange. Even when I put the board outside, in about -6 Celcius, it still displays </p>

<pre><code>Temp 247.208 °C
RH 216.208 %
</code></pre>

<p>Well, I guess this oddity should be posted as another question. I'll answer my own question here with reference to the weird pin-to-number mapping on the LoLin board.</p>
 17055: <p>The problem was that the port mappings on the LoLin board didn't make much sense. </p>

<p>Port D0 is for instance mapped to number 16, not 0. </p>

<p>Go <a href="https://github.com/esp8266/Arduino/issues/584#issuecomment-123715951" rel="nofollow noreferrer">to this Github comment</a> to get a complete list:</p>

<pre><code>/*
 * Weird pin mappings on LoLin:
 * 
 * static const uint8_t D0   = 16;
 * static const uint8_t D1   = 5;
 * static const uint8_t D2   = 4;
 * static const uint8_t D3   = 0;
 * static const uint8_t D4   = 2;
 * static const uint8_t D5   = 14;
 * static const uint8_t D6   = 12;
 * static const uint8_t D7   = 13;
 * static const uint8_t D8   = 15;
 * static const uint8_t D9   = 3;
 * static const uint8_t D10  = 1;
*/
</code></pre>

<p><strong>Missing decimal digits and not able to measure sub zero values</strong></p>

<p>If <a href="https://github.com/RobTillaart/Arduino/issues/5#issuecomment-34655292" rel="nofollow noreferrer">this comment on github</a> is correct, the DHT11 sensor <em>does not offer decimals</em> and <em>does not measure values below zero</em>.</p>
 32037: <p>I was scratching my head since last two days over similar issue. I am using ESP8266 NodeMCU which is V2 of LoLin NodeMCU and wanted to read DHT11 sensor data over WiFi into blynk app. However my serial output was 'Failed to read from DHT sensor!'. The program and interfacing was working perfectly with Arduin Uno and Raspberry Pi but not with NodeMCU.</p>

<p>Being a hardware guy, I tried all sorts of hardware modification possible. I had <a href="http://rads.stackoverflow.com/amzn/click/B00TM87YRS" rel="nofollow noreferrer">DHT11 sensor module</a> which is already having 5k pull up resistors on board. Since NodeMCU board doesn't have 5V supply, I desoldered the sensor and did direct interfacing with 10k resistor as recommended by <a href="https://cdn-learn.adafruit.com/downloads/pdf/dht.pdf" rel="nofollow noreferrer">adafruit DHTxx guide</a>. Doing internet search , someone recommended IDE version issue, tried that too. Nothing worked.</p>

<p>Finally referring per @nitech answer, I checked the pin details of NodeMCU board and got the idea of D2 pin actual mapped on GPIO4. Just changed the pin 2 with 4 in example code and it worked. Voila! I think recent race in achieving most of the boards as Arduino shield and IDE standard compatible, we need to be used for such issues for any deviation.</p>
