Cannot get any readings from DHT22 Sensor connected to Arduino M0 Pro I have directly connected a DHT22 to my Arduino M0 Pro. I have put a 10k Resistor across the Data &amp; V+ of the sensor pinout. The data is connected to pin 5 and I have it connected to 3.3V output of Arduino.

I am just trying to see some readings from the sensor via the SerialUSB console. I have downloaded and unpacked the DHT libraries that I got on the Adafruit website/GitHub. As far as I know I have these libraries in the right directory - C:\Program Files (x86)\Arduino\libraries\DHT...
I also have installed the Adafruit Unified Sensor library on the IDE.

I am trying to use the Tester program that is provided, this compiles ok but the SerialUSB printout prints:

Failed to read from DHT sensor!
Failed to read from DHT sensor!
Failed to read from DHT sensor!


And so on...

I have tried another DHT22 sensor to no avail.

The only part of the code I have changed is the pin number and changed from Serial to SerialUSB.

Not sure if I have to change anything else? Or am I doing something really silly!



Here is the code:

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

#include "DHT.h"

#define DHTPIN 5     // what digital pin we're connected to

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

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1
// to 3.3V instead of 5V!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  SerialUSB.begin(9600);
  SerialUSB.println("DHTxx test!");

  dht.begin();
}

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

  // 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 (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

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

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);

  SerialUSB.print("Humidity: ");
  SerialUSB.print(h);
  SerialUSB.print(" %\t");
  SerialUSB.print("Temperature: ");
  SerialUSB.print(t);
  SerialUSB.print(" *C ");
  SerialUSB.print(f);
  SerialUSB.print(" *F\t");
  SerialUSB.print("Heat index: ");
  SerialUSB.print(hic);
  SerialUSB.print(" *C ");
  SerialUSB.print(hif);
  SerialUSB.println(" *F");
}
Found what the fault was, it was a solder short between pins on a custom PCB that was sitting on top of the Arduino board. My bad! At least I have it working now!