# DHT22 Returning Value of -7.00 on Photon w/ RelayShield

**URL:** <https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496>\
**Category:** Troubleshooting\
**Created:** [March 27, 2016, 1:35pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496 "2016-03-27T13:35:13Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 27, 2016, 1:35pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/1 "2016-03-27T13:35:13Z")

</div>

Hi folks,

After a bit of hassle I got the DHT to sort of work with the recommended "PietteTech\_DHT/PietteTech\_DHT.h" library. It was hanging and breathing green on the acquire and wait function, so I deleted it and the example switch case error reporting statements and I could get the program to loop and take readings.

However, now I'm only getting -7.0 as a return value for the other polling functions for temp/hum/dew point, etc.

That return value looks similar to what another user reported here:

> [@DHT22 sensor get stuck with Spark Core on pin 5 and pin 6 \[SOLVED\]](https://community.particle.io/t/dht22-sensor-get-stuck-with-spark-core-on-pin-5-and-pin-6-solved/12384/18):
>
> DHTLIB\_ERROR\_NOTSTARTED -7

What's it mean?

Things I've tried:  
Switching pins (D0,D2). Can't use D3 - 6.  
Switching the DHTTYPE from DHT22 to AM2302.  
Creating a new sketch from the library example with the library automatically included to rule out library inclusion issues.

Hardware:  
Photon  
RelayShield  
I have the SMAKN DHT22 that comes with a built in resistor (or two), and some presoldered pins. It was stated to be 3 - 5v capable.

Things I haven't tried:  
Powering with higher voltage.

Any other recommendations? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 28, 2016, 9:08am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/2 "2016-03-28T09:08:46Z")

</div>

Could you provide an image (good resolution to see the exact wiring)?  
Then I could copy that setup and try.

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 28, 2016, 8:34pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/4 "2016-03-28T20:34:50Z")

</div>

Welp, was tired of messing with it, so I gave the SMAKN thing 6v (my bench power supply only has 4.5 and 6 😕 and let the magic smoke out; something fried inside. It was stated to handle 3 - 5.5v, so I guess that’s fair. Amazon is shipping a new one, without the ‘convenient’ pre-soldered resistor(s) and pins.

Thanks for offering to help.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 29, 2016, 5:51am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/5 "2016-03-29T05:51:10Z")

</div>

Pitty that you deleted the image, but since I’m a mod, I could still see your problem.  
I’d say it was actually the pins not being solderd in. Just having the Photon sitting on the header pins will never give you enough reliable contact to do anything with it.

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 29, 2016, 10:17am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/6 "2016-03-29T10:17:58Z")

</div>

I didn’t want to waste your time since I’d already fried the DHT22 by that point. As far as the headers, for a better test I should have soldered them on, you’re right, though that Photon is meant for something else not requiring headers. Thing is, when it was attached to my project, the headers were soldered on and I was getting the same thing. Hoping for better results this afternoon. Thanks again!

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [March 29, 2016, 11:07am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/7 "2016-03-29T11:07:53Z")

</div>

> [@RobotChicken](#):
>
> As far as the headers, for a better test I should have soldered them on

Not just as a test. Without them soldered on, there's a very very slim chance you'll be able to take readings at all. Also, I noticed that the D7 LED was on, which it shouldn't be according to the code. Could it be that there was something else running?

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 29, 2016, 5:11pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/8 "2016-03-29T17:11:04Z")

</div>

The actual project was soldered, regardless, your advice is sound. I’ll solder my connections when testing in the future.

As far as the code, the image was taken with my project full code, but then I flashed the DHT\_SIMPLE and tested that too, but got the same readings.

Thanks for your comments!

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 30, 2016, 1:02am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/9 "2016-03-30T01:02:54Z")

</div>

![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/9/948596761bda55bdefb4535c10d123de41f2f321.jpg)

Running a code example from the Piette DHT library from October 2014.

This is a new unit from SMAKN without any pre-soldered stuff. I took @ScruffR and @Moors7 's advice and soldered the headers on, but I’m still getting -7.000000. Pretty sure I have a 10k resistor on there (its hard to tell, but its in #2, pulling signal up to 3.3v). Wired like these [here](https://community.particle.io/t/solved-dht22-issue-with-photon/13858).

Halp?

```
/*
 * FILE: DHT_simple.ino
 * VERSION: 0.3
 * PURPOSE: Example that uses DHT library with two sensors
 * LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
 *
 * Samples one sensor and monitors the results for long term
 * analysis. It calls DHT.acquireAndWait
 *
 * Scott Piette (Piette Technologies) scott.piette@gmail.com
 * January 2014 Original Spark Port
 * October 2014 Added support for DHT21/22 sensors
 * Improved timing, moved FP math out of ISR
 */

#include "PietteTech_DHT/PietteTech_DHT.h"

#define DHTTYPE DHT22 // Sensor type DHT11/21/22/AM2301/AM2302
#define DHTPIN 2 // Digital pin for communications

//declaration
void dht_wrapper(); // must be declared before the lib initialization

// Lib instantiate
PietteTech_DHT DHT(DHTPIN, DHTTYPE, dht_wrapper);
int n; // counter

void setup()
{
    Serial.begin(9600);
    while (!Serial.available()) {
        Serial.println("Press any key to start.");
        delay (1000);
    }
    Serial.println("DHT Example program using DHT.acquireAndWait");
    Serial.print("LIB version: ");
    Serial.println(DHTLIB_VERSION);
    Serial.println("---------------");
}

// This wrapper is in charge of calling
// must be defined like this for the lib work
void dht_wrapper() {
    DHT.isrCallback();
}

void loop()
{
    Serial.print("\n");
    Serial.print(n);
    Serial.print(": Retrieving information from sensor: ");
    Serial.print("Read sensor: ");
    //delay(100);
  
    
    Serial.print("Humidity (%): ");
    Serial.println(DHT.getHumidity(), 2);

    Serial.print("Temperature (oC): ");
    Serial.println(DHT.getCelsius(), 2);

    Serial.print("Temperature (oF): ");
    Serial.println(DHT.getFahrenheit(), 2);

    Serial.print("Temperature (K): ");
    Serial.println(DHT.getKelvin(), 2);

    Serial.print("Dew Point (oC): ");
    Serial.println(DHT.getDewPoint());

    Serial.print("Dew Point Slow (oC): ");
    Serial.println(DHT.getDewPointSlow());

    n++;
    delay(2500);
}
```

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [March 30, 2016, 8:55pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/10 "2016-03-30T20:55:39Z")

</div>

Solved. It was the library. I loaded the AdafruitDHT library an code example and it worked like intended.

```
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_DHT/Adafruit_DHT.h"

//#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());
}
```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [March 30, 2016, 9:04pm UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/11 "2016-03-30T21:04:10Z")

</div>

That’s odd.  
The Piettetech library is the most stable one for my DHT sensors, I had lockups with the others.

However, good to know, you got yours running 👍

---

<div class="post-metadata">

**Author:** ![RobotChicken](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/robotchicken/32/8976_2.png) [@RobotChicken](https://community.particle.io/u/RobotChicken)\
**Post date:** [April 4, 2016, 1:07am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/12 "2016-04-04T01:07:51Z")

</div>

That’s why I started with it. But I had lockups with it and the example code, and then couldn’t get good data returned from the sensor(s). So I don’t know, the Adafruit one just worked.

Its running like a champ and I was able to finally do install after messing around for a few days figuring this stuff out. Thanks again.

---

<div class="post-metadata">

**Author:** ![BulldogLowell](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bulldoglowell/32/4305_2.png) [@BulldogLowell](https://community.particle.io/u/BulldogLowell)\
**Post date:** [April 4, 2016, 1:26am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/13 "2016-04-04T01:26:39Z")

</div>

> [@ScruffR](#):
>
> That's odd.The Piettetech library is the most stable one for my DHT sensors, I had lockups with the others.

I am using both, they are both pretty stable, IMHO.

---

<div class="post-metadata">

**Author:** ![cyclin\_al](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cyclin\_al](https://community.particle.io/u/cyclin_al)\
**Post date:** [September 4, 2016, 6:11am UTC](https://community.particle.io/t/dht22-returning-value-of-7-00-on-photon-w-relayshield/21496/14 "2016-09-04T06:11:29Z")

</div>

I had the same problem occur using an AOSONG AM2302 … I found this thread searching for a solution.  
In the end, I re-did my breadboard and re-flashed the same code; afterwards it worked perfectly.  
My assumption is that one of the hardware connections was not quite right and that was the cause of my problem.

Hope this helps!
