E SERIES EVAL KIT TUTORIALS - Temp Sensor Readings

Any ideas on why I keep getting strange readings from my Temperature sensor? Seems like it should be pretty straightforward, but alas have not had any luck. I have tried 2 different sensors so I think it must be my code or wiring configuration.

// This #include statement was automatically added by the Particle IDE.
#include <Adafruit_DHT.h>

// This example assumes the sensor to be plugged into CONN2
#define DHTPIN D1     // what pin we're connected to

// Here we define the type of sensor used
#define DHTTYPE DHT22        // DHT 22 

DHT dht(DHTPIN, DHTTYPE);

void setup() {

    // We open up a serial port to monitor the sensor values
    Serial.begin(9600); 
    Serial.println("DHT11 test!");

    dht.begin();
}

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

    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 
    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!");
    //     Particle.publish("error", "No data collected");
    //     return;
    // }

    // Print the data over serial
    Serial.print("Humid: "); 
    Serial.print(h);
    Serial.print("% - ");
    Serial.print("Temp: "); 
    Serial.print(f);
    Serial.print("*F ");
    Serial.println(Time.timeStr());

    // Publish data to the Particle cloud. 
    // Remember that you'll consume data every time you publish to the cloud.
    Particle.publish("temp", String (f));
    Particle.publish("humi", String (h));
}

it’s hard to say why is throwing this nonsense values but have you heard about PietteTech_DHT lib ? it’s also available from Web IDE
then try to flash this(it’s working just fine for me):
https://go.particle.io/shared_apps/609c40d711206f0009309e33

and you gonna be able to get some Debug info what is going on with your DHT.
also make sure that the pin on your e-series is correct one

e_series_pinout

1 Like

Hi Brad, how did you connect it all?
thanks

dreamER - Worked like a charm, thanks Buddy!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.