Why do I end up with the display

Failed to read from DHT sensor!

in the serial monitor in most cases when I run the code given below? When I reduce the delay to 1000ms the reading shows 0.00 for both temperature and humidity which, as well, is pretty much false. Any help would be highly appreciated.

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"

#define DHTPIN 2     // what pin we're connected to

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Initialize DHT sensor for normal 16mhz Arduino
// NOTE: For working with a faster chip, like an Arduino Due or Teensy, you
// might need to increase the threshold for cycle counts considered a 1 or 0.
// You can do this by passing a 3rd parameter for this threshold.  It's a bit
// of fiddling to find the right value, but in general the faster the CPU the
// higher the value.  The default for a 16mhz AVR is a value of 6.  For an
// Arduino Due that runs at 84mhz a value of 30 works.
// Example to initialize DHT sensor for Arduino Due:

void setup() {
  Serial.println("DHTxx test!");


void loop() {
  // Wait a few seconds between measurements.

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  Serial.print("Humidity: "); 
  Serial.print(" %\t");
  Serial.print("Temperature: "); 
  Serial.print(" *C ");
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.println(" *F");
  • 1
    Is that library designed for the Galileo? I see that it runs at 400 MHz, whereas the library (when I last used it) was for a 16 MHz Arduino. The DHT11 uses a highly timing-specific protocol. A search for intel galileo dht11 revealed DHT workaround for Galileo and Galileo Gen2 using 2 pins instead of one
    – Nick Gammon
    Commented Mar 16, 2016 at 9:05
  • This is only because i am using the same material as from where ctrl+c and ctrl+v was done! :) Further adding to it, please can you specify in detail the pin connections? means in simple words like which pin is to connect diode with, which pin to connect resistor with from the link you have shared above! (also the specification of diode and resistor). Thanks mate for the help!!! Cheers..
    – Jay M
    Commented Mar 17, 2016 at 2:29
  • And in addition I am using 3 pin DHT22 (Vcc, Out, Gnd).
    – Jay M
    Commented Mar 17, 2016 at 2:38

1 Answer 1


The article link by Nick is the same that I found, so it must be a well search problem.

What is described on the Intel forum is that the Galileo is not capable of direct communication with the sensor as it is a computer and not a microcontroller, so therefore lacks the ability for accurate timing required by the sensor and also the DHT* is considered a peripheral and would thus require a way to interface with the "PC".

What is described in the post is to use two pins to create the proper digital signal for the DHT.

The circuit makes use of a diode to protect the output pin.

The OP on the forum describes the connections like this:

Pin 2 of Galileo is connected to the data pin of the DHT11.

Cathode of the diode is connected to pin 3 of the Galileo.

Anode of the diode is connected to the DHT11 data pin.

The diode would be a standard diode, possibly a fast switching signal diode as the 1N4143. The resistor would be the standard pull up resistor of 10K Ohms.

Here is the OPs schematic:

enter image description here
(source: intel.com)

You will also need to make use of the code linked to by the OP in the linked post as it was modified to work with the workaround.

  • Here it is written, "pin 2 is connected to the DHT11", But whose Pin 2 to connect to DHT and on which pin of DHT i should connect.
    – Jay M
    Commented Mar 28, 2016 at 5:56
  • @JayM hi, the PIN2 is the Galileo and PIN3 is also the Galileo. Pin 2 is connected to the data pin of the dht, while pin 3 is connected to the cathode of the diode and the anode of the diode to the data pin of the dht check this schematic from the op communities.intel.com/servlet/JiveServlet/downloadImage/…
    – RSM
    Commented Mar 28, 2016 at 17:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.