user3840: I just bought the sensor DHT11 and trying to test it with the library code provided by the IDE, but I always get the same error on .read() . Code -2
/*####################################################################
FILE: dht11_functions.pde - DHT11 Usage Demo.
VERSION: 2S0A

PURPOSE: Measure and return temperature & Humidity. Additionally provides conversions.

LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
GET UPDATES: https://www.virtuabotix.com/

  --##--##--##--##--##--##--##--##--##--##--
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ## DHT11 SENSOR ##  ##  ##  ##
  ##  ##  ##  ##  ##FRONT ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  --##--##--##--##--##--##--##--##--##--##--
      ||       ||          || (Not    ||
      ||       ||          || Used)   ||
    VDD(5V)   Readout(I/O)          Ground

HISTORY:
Joseph Dattilo (Virtuabotix LLC) - Version 2S0A (27 May 12)
-Rewritten to with more powerful Versalino functionality
Joseph Dattilo (Virtuabotix LLC) - Version 0.4.5 (11/11/11)
-Made Library Arduino 1.0 Compatible
Joseph Dattilo (Virtuabotix LLC) - Version 0.4.0 (06/11/11)
-Fixed bugs (squish)
Mod by Rob Tillaart - Version 0.3 (28/03/2011)
Mod by SimKard - Version 0.2 (24/11/2010)
George Hadjikyriacou - Original version (??)
#######################################################################*/


#include <dht11.h>

dht11 DHT11;

void setup()
{
    DHT11.attach(2);
    Serial.begin(9600);
    Serial.println("DHT11 TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT11LIB_VERSION);
}

void loop()
{
    Serial.println("\n");

    int chk = DHT11.read();

    Serial.print("Read sensor: ");
    switch (chk)
    {
        case 0: Serial.println("OK"); break;
        case -1: Serial.println("Checksum error"); break;
        case -2: Serial.println("Time out error"); break;
        default: Serial.println("Unknown error"); break;
    }

    Serial.print("Humidity (%): ");
    Serial.println((float)DHT11.humidity, DEC);

    Serial.print("Temperature (°C): ");
    Serial.println((float)DHT11.temperature, DEC);

    Serial.print("Temperature (°F): ");
    Serial.println(DHT11.fahrenheit(), DEC);

    Serial.print("Temperature (°K): ");
    Serial.println(DHT11.kelvin(), DEC);

    Serial.print("Dew Point (°C): ");
    Serial.println(DHT11.dewPoint(), DEC);

    Serial.print("Dew PointFast (°C): ");
    Serial.println(DHT11.dewPointFast(), DEC);

    delay(2000);
}

And this is my ouput:
DHT11 TEST PROGRAM 
LIBRARY VERSION: 2S0A


Read sensor: Time out error
Humidity (%): 0.0000000000
Temperature (Â°C): 0.0000000000
Temperature (Â°F): 32.0000000000
Temperature (Â°K): 273.1499938964
Dew Point (Â°C): nan
Dew PointFast (Â°C): nan


Read sensor: Time out error
Humidity (%): 0.0000000000
Temperature (Â°C): 0.0000000000
Temperature (Â°F): 32.0000000000
Temperature (Â°K): 273.1499938964
Dew Point (Â°C): nan
Dew PointFast (Â°C): nan

The wiring:
-left pin: 5v
-right pin: gnd
-middle pin: 5v - digital2 - through 10kO resistor


UPDATED:
I found a library that works. I also changed the wiring because I found out the sainsmart dht11 switches the pins:
-left: signal with 10kO and to 5v
-middle: 5v
-right: GND
Now just a question.
What is the difference between these two dht11 sensors.
Dht11 basic
dht11 with board
The one from sainsmart has a piece of circuit I don't know what it is.(I have a lack on electronics I try to fix step by step...) 
It is a resitor, capacitor? it says 103.
How does this affect to the wiring?

user13174: The DHT11 sensor is available as-is and integrated on a break-out board. The break-out board shows following differences:

the order of PINs is changed, e.g. in one version: 1 -> signal, 2 -> +, 3 -> GND (left-to-right, pins down, looking at the front)
the unused pin is not connected
the board already has a 10 KOhm pull-up resistor connected

Thus, when you have a DHT11 on a break-out board you have to adjust schematics that use it as-is - e.g. in this example you have to remove the external pull-up resistor and connect the pins in the correct order.
Be aware that there may be different versions of DHT11 breakout boards available - i.e. ones where the order of pins is different. You can look out for PIN markings like S (-> signal) and - (-> GND). Also, you can look at both sides of the breakout board to trace the connections.
The resistor usually comes as SMD on such a board - and if it has a marking it uses a special code. For example, 103 means 10 * 10^3 Ohm, i.e. 10 KOhm.
The adafruit DHT library comes with an example sketch that prints the sensor values over serial.

3840: <p>I just bought the sensor <a href="http://www.sainsmart.com/sainsmart-dht11-temperature-and-relative-humidity-sensor-module-for-arduino.html" rel="nofollow noreferrer">DHT11</a> and trying to test it with the library code provided by the IDE, but I always get the same error on <code>.read()</code> . Code -2</p>

<pre><code>/*####################################################################
FILE: dht11_functions.pde - DHT11 Usage Demo.
VERSION: 2S0A

PURPOSE: Measure and return temperature &amp; Humidity. Additionally provides conversions.

LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
GET UPDATES: https://www.virtuabotix.com/

  --##--##--##--##--##--##--##--##--##--##--
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ## DHT11 SENSOR ##  ##  ##  ##
  ##  ##  ##  ##  ##FRONT ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  | ##  ##  ##  ##  ##  ##  ##  ##  ##  ## |
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##  ##
  --##--##--##--##--##--##--##--##--##--##--
      ||       ||          || (Not    ||
      ||       ||          || Used)   ||
    VDD(5V)   Readout(I/O)          Ground

HISTORY:
Joseph Dattilo (Virtuabotix LLC) - Version 2S0A (27 May 12)
-Rewritten to with more powerful Versalino functionality
Joseph Dattilo (Virtuabotix LLC) - Version 0.4.5 (11/11/11)
-Made Library Arduino 1.0 Compatible
Joseph Dattilo (Virtuabotix LLC) - Version 0.4.0 (06/11/11)
-Fixed bugs (squish)
Mod by Rob Tillaart - Version 0.3 (28/03/2011)
Mod by SimKard - Version 0.2 (24/11/2010)
George Hadjikyriacou - Original version (??)
#######################################################################*/


#include &lt;dht11.h&gt;

dht11 DHT11;

void setup()
{
    DHT11.attach(2);
    Serial.begin(9600);
    Serial.println("DHT11 TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT11LIB_VERSION);
}

void loop()
{
    Serial.println("\n");

    int chk = DHT11.read();

    Serial.print("Read sensor: ");
    switch (chk)
    {
        case 0: Serial.println("OK"); break;
        case -1: Serial.println("Checksum error"); break;
        case -2: Serial.println("Time out error"); break;
        default: Serial.println("Unknown error"); break;
    }

    Serial.print("Humidity (%): ");
    Serial.println((float)DHT11.humidity, DEC);

    Serial.print("Temperature (°C): ");
    Serial.println((float)DHT11.temperature, DEC);

    Serial.print("Temperature (°F): ");
    Serial.println(DHT11.fahrenheit(), DEC);

    Serial.print("Temperature (°K): ");
    Serial.println(DHT11.kelvin(), DEC);

    Serial.print("Dew Point (°C): ");
    Serial.println(DHT11.dewPoint(), DEC);

    Serial.print("Dew PointFast (°C): ");
    Serial.println(DHT11.dewPointFast(), DEC);

    delay(2000);
}
</code></pre>

<p>And this is my ouput:</p>

<pre><code>DHT11 TEST PROGRAM 
LIBRARY VERSION: 2S0A


Read sensor: Time out error
Humidity (%): 0.0000000000
Temperature (Â°C): 0.0000000000
Temperature (Â°F): 32.0000000000
Temperature (Â°K): 273.1499938964
Dew Point (Â°C): nan
Dew PointFast (Â°C): nan


Read sensor: Time out error
Humidity (%): 0.0000000000
Temperature (Â°C): 0.0000000000
Temperature (Â°F): 32.0000000000
Temperature (Â°K): 273.1499938964
Dew Point (Â°C): nan
Dew PointFast (Â°C): nan
</code></pre>

<p>The wiring:</p>

<p>-left pin: 5v</p>

<p>-right pin: gnd</p>

<p>-middle pin: 5v - digital2 - through 10kO resistor</p>

<p><img src="https://i.stack.imgur.com/hQQf0.jpg" alt="enter image description here">
<img src="https://i.stack.imgur.com/HqhAN.jpg" alt="enter image description here"></p>

<p><strong>UPDATED:</strong>
I found a <a href="http://playground.arduino.cc/Main/DHT11Lib" rel="nofollow noreferrer">library</a> that works. I also changed the wiring because I found out the sainsmart dht11 switches the pins:</p>

<p>-left: signal with 10kO and to 5v</p>

<p>-middle: 5v</p>

<p>-right: GND</p>

<p>Now just a question.
What is the difference between these two dht11 sensors.
<a href="http://www.exp-tech.de/Sensoren/DHT11-Feuchte-Temperatur-Sensor.html" rel="nofollow noreferrer">Dht11 basic</a>
<a href="http://www.sainsmart.com/sainsmart-dht11-temperature-and-relative-humidity-sensor-module-for-arduino.html" rel="nofollow noreferrer">dht11 with board</a></p>

<p>The one from sainsmart has a piece of circuit I don't know what it is.(I have a lack on electronics I try to fix step by step...) </p>

<p><strong>It is a resitor, capacitor?</strong> it says 103.</p>

<p>How does this affect to the wiring?</p>
 13174: <p>The DHT11 sensor is available as-is and integrated on a break-out board. The break-out board shows following differences:</p>

<ul>
<li>the order of PINs is changed, e.g. in one version: 1 -> signal, 2 -> <code>+</code>, 3 -> GND (left-to-right, pins down, looking at the front)</li>
<li>the unused pin is not connected</li>
<li>the board already has a 10 KOhm pull-up resistor connected</li>
</ul>

<p>Thus, when you have a DHT11 on a break-out board you have to adjust schematics that use it as-is - e.g. in this <a href="https://learn.adafruit.com/dht/connecting-to-a-dhtxx-sensor" rel="nofollow">example</a> you have to remove the external pull-up resistor and connect the pins in the correct order.</p>

<p>Be aware that there may be different versions of DHT11 breakout boards available - i.e. ones where the order of pins is different. You can look out for PIN markings like <code>S</code> (-> signal) and <code>-</code> (-> GND). Also, you can look at both sides of the breakout board to trace the connections.</p>

<p>The resistor usually comes as SMD on such a board - and if it has a marking it uses a special code. For example, <code>103</code> means <code>10 * 10^3</code> Ohm, i.e. 10 KOhm.</p>

<p>The <a href="https://github.com/adafruit/DHT-sensor-library" rel="nofollow">adafruit DHT library</a> comes with an example sketch that prints the sensor values over serial.</p>
