DHT11 sensor help

Hello,

I'm trying to read data from sensor.
Power is V-usb, gnd and output is d2.

1.) I have successfully compiled and uploaded example:

#include "Adafruit_DHT.h"

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

#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)

// Connect pin 1 (on the left) of the sensor to +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

DHT dht(DHTPIN, DHTTYPE);

void setup() {
	Serial.begin(9600); 
	Serial.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.getHumidity();
// Read temperature as Celsius
	float t = dht.getTempCelcius();
// Read temperature as Farenheit
	float f = dht.getTempFarenheit();
  
// 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!");
		return;
	}

// Compute heat index
// Must send in temp in Fahrenheit!
	float hi = dht.getHeatIndex();
	float dp = dht.getDewPoint();
	float k = dht.getTempKelvin();

	Serial.print("Humid: "); 
	Serial.print(h);
	Serial.print("% - ");
	Serial.print("Temp: "); 
	Serial.print(t);
	Serial.print("*C ");
	Serial.print(f);
	Serial.print("*F ");
	Serial.print(k);
	Serial.print("*K - ");
	Serial.print("DewP: ");
	Serial.print(dp);
	Serial.print("*C - ");
	Serial.print("HeatI: ");
	Serial.print(hi);
	Serial.println("*C");
	Serial.println(Time.timeStr());
}
  1. Result is in screenshot.

3.)


Does your DHT11 breakout board have the pull-up resistor on it? There needs to be a 10K pull up from the data line to the + power line. The plain sensors don't have it, but yours looks like it's mounted on a board so it may or may not have it built-in.

Some DHT11 sensors don't work properly at 3.3V. With the Photon 1 and P1 (including the Sparkfun Redboard), you can power the DHT11 by VUSB, but you cannot do this with Gen 3 and Gen 4 devices which are not 5V tolerant.

The Adafruit DHT guide has a lot of good tips for getting the sensor to work properly.

1 Like

Is there any reason the DHT11 sensors from the recently discontinued Argon Starter Kits shouldn't work with the Grove Temperature and Humidity library 1.0.7?
I just received my starter kits and have tried 3 DHT11 sensors from 3 different kits with the dht11-demo.ino from that library to no avail (fails to read from the sensor).
I've checked other posts, and Googled, and can't find a solution.
I was finally able to get the sensor to work with the code in the post
" Photon 2 - DHT11 Sensor and Reading Values".
Just wondering why the Grove library doesn't seem to work.
My Argon has OS 6.1.1

The DHT11 works sporadically on the Argon (nRF52840 MCU). The problem is variable interrupt latency which causes incorrect bit values to be read. Some libraries work better than others but you will always get some number of CRC errors. On the nRF52, the only library that will work reliably is DHT22Gen3_RK but there are many limitations to using it because it uses the SPI peripheral to avoid interrupt timing issues.

The DHT11 and DHT22 do not work at all on the Photon 2/P2/M-SoM because of slow GPIO, There is no library that will make that work.

The best solution in all cases is to avoid sensors with proprietary protocols like the DHT11 and DHT22 and use a sensor with an I2C interface.

Thank you Rick! For the detailed explanation as well as the link to the library (it took a few minutes to realize that the input had to be changed to A2 for the Grove connection). Should the tutorial Particle Variables: measure temperature & humidity be changed to reflect your library?

I'm also using your Google Firebase Tutorial

Thanks again!