DHT22 works with Photon, not Xenon & Argon


I have successfully gotten the DHT22 to work on my Photon, but for both the Xenon & Argon it always return zeros.

I’ve identified from forum postings the #include statement needs to be changed and there is a fix best retrieved by using piettetech_dht and ensuring it has the January 2019 update. Both are true.

I am sending the data via the .publish to ThinkSpeak (not using serial as in the examples if that makes a difference) and I’ve tried float, int & double declarations for the variables.

I assume there is something simple I am missing.

Argon/Xenon unresponsive/not showing offline

For debugging it’s always best to keep things as simple as possible - i.e. try serial printing first and when that is working move on.


Generally, I would agree with you. But in this case I have working code, I am just changing hardware.

This is an environmental \ context problem of some kind.


The DHT22 definitely works with Xenon - I have tried the sensor myself. Could you share how you are connecting it and the simple code just to get temperature and humidity from the sensor?


This is the code. (cannibalized from another post). Beyond confirming I have the January 2019 version of PietteTech_DHT.h, I’ve added delays between reads. The voltage displays with correct data, the other two are always zero. When I run it on the photon (battery commented out) observations start up after a cycle or two.

// This #include statement was automatically added by the Particle IDE.
#include <PietteTech_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
#define DHTTYPE DHT22	  

void setup() {


void loop() {
// Wait a few seconds between measurements.
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a 
// very slow sensor)

    double DHT_temp = dht.getTempFarenheit();
    double DHT_humid = dht.getHumidity();
    // Now we'll take some readings...

    int temperature_analog = DHT_temp; // read DHT sensor
    float temperature_percentage = (10 + ( (temperature_analog/50) ) );  
    int humidity_analog = DHT_humid; // read DHT sensor
    float humidity_percentage = (10 + ( (humidity_analog/50) ) );

     //Battery Life   
        float voltage = analogRead(BATT) * 0.0011224;
        Particle.publish("voltage", String(voltage),60,PUBLIC);
    // Send a publish devices...
    Particle.publish("DHT_temperature", String(temperature_analog),60,PUBLIC);
  //  Particle.publish("DHT_temp_percentage", String(temperature_percentage),60,PUBLIC);
    Particle.publish("DHT_humidity", String(humidity_analog),60,PUBLIC);
 //   Particle.publish("DHT_humid_percentage", String(humidity_percentage),60,PUBLIC);


Hi Will, what library did you use? thanks!


I just looked at this and it was the Seeed_DHT11 library as I was using the DHT11 supplied in the Grove Starter Kit for Particle Mesh and not the DHT22. Sorry to mislead. I had a look at the application I used for the Photon and that was PIETTETECH_DHT library. I just tried the @Moors7 BLE example with a Xenon - DHT11 reading which appears to have a 1 in 3 read failure - BLE works fine!