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.
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);
}