Updated 2.2.0 and now all my DHT Sensors no longer work Just read 0 and 6553 [SOLVED]

Updated all my Photon devices last night to 2.2.0 from 2.1.0 and now all my DHT22 Sensors read 0 Degs and 6553% Humidity.
Tried changing to the libraries, tried Both Adafruit_DHT and Adafruit_DHT_Particle and same error.
All of my single DHT Photons no longer work.
However one of my Photons that’s connected to Several DHT22 Sensors DOES read a single one of them correctly. It’s connected to pin D1 and working. However all the other sensors connected to D4, D5, D7 all get the error described above.

Another photon connected to a single DHT22 is on Pin D5
They are all on my custom printed circuit boards (made 4 years ago and working till the update now) so I can’t easily experiment moving pins around.
I tried downgrading the FW back to 2.1.0 but apparently you can’t go backwards like that so no clue how to roll back.
Any help would be greatly appreciated as my entire sensor system is down now :frowning:

Here is my code on the system with multiple sensors

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

SYSTEM_MODE(SEMI_AUTOMATIC);

double FWVer = 1.58;

int FansOnTemp = 81; int FansOffTemp = 78; int CRLightLevel = 1; int FanSpeed = 255; int FirstBoot = 1;
int VentTempF; int VentHumid; int VentError; int OutsideTempF; int OutsideHumid; int OutsideError; int PCRunning;
int AtticTempF; int AtticHumid; int AtticError; int CRTempF; int CRHumid; int CRError; int FansRunning;
const byte RGBMaxBright = 200; int RedSet = 255; int GrnSet = 255; int BluSet = 255; 

const byte VentConLed = A0; const byte AtticConLed = D3; const byte CRConLed = D0; const byte LedPin = D6; const byte PCBtn = A3; 
const byte VentTempProbePin = D7; const byte OutsideTempProbePin = D5; const byte AtticTempProbePin = D4; const byte PCMon = A2;
const byte CRTempProbePin = D1; const byte FanControlPin = A5; const byte LightControlPin = A4; const byte MagSensorPin = D2;

const byte RedAbove = 80; const byte YellowAbove = 76; const byte GreenAbove = 63; const byte AquaAbove = 57; const byte BlueAbove = 36; // Sets Temps for What Colors Display at What Temp. Any Temp Below BlueAbove is Full RED and Full BLUE!
const int CheckSensorTime = 3000; const int PublishTime = 300000; const int FanTime = 300000;
const byte CLR = 12; const byte Line2 = 148; const byte Line1 = 128; const byte Note = 220; byte DisplayLCDScreen; // Vars for Making LCD Commands Eaiser
const byte ColorSpeed = 1; const int RGBCheckTime = 1000; const int LCDCheckTime = 5000; String AppString;

Adafruit_NeoPixel LED = Adafruit_NeoPixel(7, LedPin, WS2812B);
DHT VentTempProbe(VentTempProbePin, DHT22);
DHT OutsideTempProbe(OutsideTempProbePin, DHT22);
DHT AtticTempProbe(AtticTempProbePin, DHT22);
DHT CRTempProbe(CRTempProbePin, DHT22);

elapsedMillis TimerCheckSensors;
elapsedMillis TimerCheckPublish;
elapsedMillis TimerCheckFans;
elapsedMillis TimerCheckRGB;
elapsedMillis TimerCheckLCD;

void setup() {
    
    Serial1.begin(9600); //Start Serial for LCD
    LED.begin(); LED.show(); //Start WS2812B LEDs
    Particle.function("PCPowerApp", PCPower);
    Particle.variable("ContRoom", &AppString, STRING);
   
    pinMode(VentConLed, OUTPUT); pinMode(AtticConLed, OUTPUT); pinMode(CRConLed, OUTPUT); //Set pin modes
    pinMode(FanControlPin, OUTPUT); pinMode(LightControlPin, OUTPUT); //Set pin modes
    pinMode(PCBtn,OUTPUT); pinMode(PCMon,INPUT_PULLDOWN);pinMode(MagSensorPin, INPUT_PULLUP); //Set pin modes
	VentTempProbe.begin(); OutsideTempProbe.begin(); AtticTempProbe.begin(); CRTempProbe.begin(); //Startup the Sensor Probes
    Serial1.write(22); Serial1.write(17); Serial1.write(CLR); delay(100); // Sets system to on with no cursor, Turn backlight on, Clear 
    Serial1.write("Welcome: Bovine"); Serial1.write(Line2); Serial1.write("  Control Room"); delay (3000);
    Serial1.write(CLR); delay(10); 
    Serial1.write(" Connecting to:"); Serial1.write(Line2); Serial1.write("Particle Cloud..");
    if (Particle.connected() == false) {Particle.connect();} delay(3000);
    Serial1.write(CLR); delay(10); // Sets system to on with no cursor, Turn backlight on, Clear 
    Serial1.write(Line1); Serial1.print("  Control Room"); Serial1.write(Line2); Serial1.print("  FW Ver:" + String (FWVer,2)); delay(5000);
    Serial1.write(CLR); delay(10); //Clear the screen
    analogWrite(LightControlPin, 255); analogWrite(FanControlPin, 255); // Sets Control Room Lights & Fans to Full Power for Testing
    for (int L=0; L<7; L++) {LED.setPixelColor(L,LED.Color(RGBMaxBright,RGBMaxBright,RGBMaxBright));}//Set LEDs to White for Testing
    LED.show();
    Serial1.write(Line2); Serial1.print("   Light Test");
    Serial1.write(Line1); Serial1.print("    Fan Test"); delay(3000);
    Serial1.write(Line1); Serial1.print("    Booting:      System Check  "); delay(1500);
    Serial1.write(CLR); delay (100); Serial1.print("Reading Sensors"); delay(1500);
    CheckSensors(); //Check each sensor for valid readings and report
    if (VentError == 1) {Serial1.write(Note); Serial1.write(Line2); Serial1.print("Vent Snsr Fail"); delay(5000);}
    if (AtticError == 1) {Serial1.write(Note); Serial1.write(Line2); Serial1.print("Attic Snsr Fail"); delay(5000);}
    if (OutsideError == 1) {Serial1.write(Note); Serial1.write(Line2); Serial1.print("Outsde Snsr Fail"); delay(5000);}
    if (CRError == 1) {Serial1.write(Note); Serial1.write(Line2); Serial1.print("CrtlRm Snsr Fail"); delay(5000);}
    if (CRError == 0 && OutsideError == 0 && AtticError == 0 && VentError == 0){Serial1.write(Line2); Serial1.print("All Sensors OK!"); delay(3000);}
    Serial1.write(CLR); delay(5); //Clear LCD Screen
    analogWrite(LightControlPin, 0); analogWrite(FanControlPin, 0); //Shutoff the Fan and Light Test
    Serial1.write("Booted and Ready");
    Particle.publish("ControlRoom", "FW Ver:" + String (FWVer) + "Now Online",60,PRIVATE);
    FirstBoot = 0; // First boot is now over, Set switch to reflect that
}

void loop() {
    CheckSensors();
    FanControl();
    CheckRoomLights();
    UpdateVentLED();
    UpdateLCD();
    UpdateAppString();
    PublishUpdates();
    if (Particle.connected() == false) {Particle.connect();}
}

void UpdateAppString(){
 AppString = String(OutsideTempF) + "," + String(OutsideHumid) + "," + String(AtticTempF) + "," + String(AtticHumid) +  "," + String(VentTempF) + "," + String(VentHumid) +  "," + String(CRTempF) + "," + String(CRHumid) + "," + String(PCRunning) + ",X";
}


int PCPower(String CommandPC){
    int PCReturns;
    if (CommandPC == "PC On"){
        if (digitalRead (PCMon) == LOW){
            Serial1.write(Note); PCReturns = 2020;
            Particle.publish("ControlRoom","Sending PC On",60,PRIVATE);
            digitalWrite(PCBtn, HIGH); delay(500); digitalWrite(PCBtn, LOW);
            }
        else {Particle.publish("ControlRoom","PC Already On",60,PRIVATE);}
        }
        
    else if (CommandPC == "PC Off"){
        if (digitalRead (PCMon) == HIGH){
            Serial1.write(Note); delay(500); Serial1.write(Note); PCReturns = 2020;
            Particle.publish("ControlRoom","Sending PC Off",60,PRIVATE);
            digitalWrite(PCBtn, HIGH); delay(500); digitalWrite(PCBtn, LOW);
            }
        else {Particle.publish("ControlRoom","PC Already Off",60,PRIVATE);}
    }
        
    else if (CommandPC == "PC Off FORCE"){
        if (digitalRead (PCMon) == HIGH){
            Serial1.write(Note); delay(100); Serial1.write(Note); delay(100); Serial1.write(Note); PCReturns = 2020;
            Particle.publish("ControlRoom","Sending PC FORCE Off",60,PRIVATE);
            digitalWrite(PCBtn, HIGH); delay(6000); digitalWrite(PCBtn, LOW);
            }
        else {Particle.publish("ControlRoom","PC Already Off",60,PRIVATE);}
    }
    return PCReturns;
}

void UpdateLCD(){
    if (TimerCheckLCD >= LCDCheckTime){TimerCheckLCD = 0; //If it's time to Update then reset timer and run update
        Serial1.write(17); Serial1.write(22);// Turns Backlight on & cursor after disconnection/Reconnection
        Serial1.write(CLR); delay(5); Serial1.write(Line1);
        if (VentError == 0){Serial1.print("I"); Serial1.print(int(VentTempF)); Serial1.print(":"); Serial1.print(VentHumid); Serial1.print("% ");} 
            else {Serial1.print("I Error ");}
        if (OutsideError == 0){Serial1.print("O"); Serial1.print(int(OutsideTempF)); Serial1.print(":"); Serial1.print(OutsideHumid); Serial1.print("%");}
            else {Serial1.print("O Error");}
        
        Serial1.write(Line2); 
        if (CRError == 0){Serial1.print("C"); Serial1.print(int(CRTempF)); Serial1.print(":"); Serial1.print(CRHumid); Serial1.print("% ");} 
            else {Serial1.print("C Error ");}
        if (AtticError == 0){Serial1.print("A"); Serial1.print(int(AtticTempF)); Serial1.print(":"); Serial1.print(AtticHumid); Serial1.print("%");}
            else {Serial1.print("A Error");}
    }
}

void UpdateVentLED(){
    if (TimerCheckRGB >= RGBCheckTime) {TimerCheckRGB = 0; //If it's time to Update then reset timer and run update
        if (OutsideTempF >= RedAbove) {RedSet = RedSet + ColorSpeed; GrnSet = GrnSet - ColorSpeed; BluSet = BluSet - ColorSpeed;} // If Above RedAbove then start to change color to Red only
          else if (OutsideTempF >= YellowAbove) {RedSet = RedSet + ColorSpeed; GrnSet = GrnSet + ColorSpeed; BluSet = BluSet - ColorSpeed;} // If Above YellowAbove then Add Green and Red
          else if (OutsideTempF >= GreenAbove) {RedSet = RedSet - ColorSpeed; GrnSet = GrnSet + ColorSpeed; BluSet = BluSet - ColorSpeed;} // If Above GreenAbove then Change to only Green
          else if (OutsideTempF >= AquaAbove) {RedSet = RedSet - ColorSpeed; GrnSet = GrnSet + ColorSpeed; BluSet = BluSet + ColorSpeed;} // If Above AquaAbove then change to Aqua (Blue and Green) Only
          else if (OutsideTempF >= BlueAbove) {RedSet = RedSet - ColorSpeed; GrnSet = GrnSet - ColorSpeed; BluSet = BluSet + ColorSpeed;} // If Above BlueAbove then start to change to Blue Only
          else if (OutsideTempF == 0) {RedSet = RedSet + ColorSpeed; GrnSet = GrnSet + ColorSpeed; BluSet = BluSet + ColorSpeed;} // If Sensor Error then go white
          else {RedSet = RedSet +  ColorSpeed; GrnSet = GrnSet - ColorSpeed; BluSet = BluSet + ColorSpeed;} // If Below BlueAbove then start to add full Red to full blue (Pink)
      
        // If any color ends up being below 0 or above RGBMaxBright then correct it so no errors via outside allowable parameters (0-255)
        if (RedSet < 0) {RedSet = 0;} if (RedSet > RGBMaxBright) {RedSet = RGBMaxBright;} 
        if (GrnSet < 0) {GrnSet = 0;} if (GrnSet > RGBMaxBright) {GrnSet = RGBMaxBright;} 
        if (BluSet < 0) {BluSet = 0;} if (BluSet > RGBMaxBright) {BluSet = RGBMaxBright;} 
    
    for (int L=0; L<7; L++) {LED.setPixelColor(L, LED.Color(RedSet,GrnSet,BluSet));} // Set LEDs to Correct Color
    LED.show();
    }
}

void CheckRoomLights(){ // If door sensor detects low then turn on CRLights OR High to turn lights off 
    if (digitalRead(MagSensorPin)==LOW){analogWrite(LightControlPin, CRLightLevel);}
    else {analogWrite(LightControlPin, 0);}
}

void FanControl(){ //Fan Control Code via Temp
/*  if (FansRunning == 0 && CRTempF >= FansOnTemp){
        analogWrite(FanControlPin, FanSpeed); 
        FansRunning = 1;
        TimerCheckFans = 0;
        Particle.publish("ControlRoom","Fans ON:" + String (CRTempF) + "F",60,PRIVATE);
    }
    if (TimerCheckFans >= FanTime){
        TimerCheckFans = 0;    
        if (CRError == 0 && FansRunning == 1 && CRTempF < FansOffTemp){
            analogWrite(FanControlPin, 0);
            FansRunning = 0;
            Particle.publish("ControlRoom","Fans OFF:" + String (CRTempF) + "F",60,PRIVATE);
        }
    }
    if (CRError == 1){analogWrite(FanControlPin, 255); FansRunning = 1;} // If Control Room Sensor is in Error then Enable Fans as Precaution
*/
}

void CheckSensors(){
    if (TimerCheckSensors >= CheckSensorTime || FirstBoot == 1){TimerCheckSensors=0;  //If it's time to Update then reset timer and run update OR skip timer if it's first boot
        VentTempF = (VentTempProbe.getTempFarenheit() - 3);
	    VentHumid = VentTempProbe.getHumidity();
	    if (VentHumid==0){VentError = 1;}
	    else {VentError=0;}
	    digitalWrite(VentConLed, HIGH); delay(5); digitalWrite(VentConLed, LOW); delay(25);
	    if (VentError==0){digitalWrite(VentConLed, HIGH);}
    
        OutsideTempF = (OutsideTempProbe.getTempFarenheit() - 1);
	    OutsideHumid = OutsideTempProbe.getHumidity();
	    if (OutsideHumid == 0){OutsideError = 1;}
	    else {OutsideError = 0;}

	    AtticTempF = AtticTempProbe.getTempFarenheit();
	    AtticHumid = AtticTempProbe.getHumidity();
        if (AtticHumid == 0){AtticError = 1;}
	    else {AtticError = 0;}
	    
	    digitalWrite(AtticConLed, HIGH);delay(5); digitalWrite(AtticConLed, LOW); delay(25);
        if (OutsideError == 0 && AtticError == 0){digitalWrite(AtticConLed, HIGH);}
    
        CRTempF = CRTempProbe.getTempFarenheit();
	    CRHumid = CRTempProbe.getHumidity();
        if (CRHumid == 0){CRError = 1;}
	    else {CRError = 0;}
        digitalWrite(CRConLed, HIGH);delay(5); digitalWrite(CRConLed, LOW); delay(25);
        if (CRError == 0){digitalWrite(CRConLed, HIGH);}
    }
    
    if (digitalRead (PCMon) == HIGH){PCRunning = 1;} //Tracks PC Status and Updates Cloud Var
        else {PCRunning = 0;}

}

void PublishUpdates(){ //Publish Sensors to Particle Feed (Mostly for WholeHouse Fan Speed Kickdown)
    if (TimerCheckPublish >= PublishTime){TimerCheckPublish = 0;
       
       if (VentError == 0){Particle.publish("CRHouseTemp", String (VentTempF), 60, PRIVATE);}
       
       /* if (VentError == 0){
            Particle.publish("ControlRoom","Vent Temp:" + String (VentTempF) + "F  " + "Humid:" + String (VentHumid) + "%",60,PRIVATE);}
        else {Particle.publish("ControlRoom","Vent Sensor Error",60,PRIVATE);}
    
        if (OutsideError == 0){
            Particle.publish("ControlRoom","Outside Temp:" + String (OutsideTempF) + "F  " + "Humid:" + String (OutsideHumid) + "%",60,PRIVATE);}
        else {Particle.publish("ControlRoom","Outside Sensor Error",60,PRIVATE);}
        
        if (AtticError == 0){
            Particle.publish("ControlRoom","Attic Temp:" + String (AtticTempF) + "F  " + "Humid:" + String (AtticHumid) + "%",60,PRIVATE);}
        else {Particle.publish("ControlRoom","Attic Sensor Error",60,PRIVATE);}
    
        if (CRError == 0){
            Particle.publish("ControlRoom","CRoom Temp:" + String (CRTempF) + "F  " + "Humid:" + String (CRHumid) + "%",60,PRIVATE);}
        else {Particle.publish("ControlRoom","Control Room Sensor Error",60,PRIVATE);}
    */
    }
}

Progress so far:
Updated FW one version at time all the way to 3.1.0 and still a no go.
Going to attempt a factory reset on a unit and only update it to 2.1.0

OK so I swore I was running 2.1.0 but apparently not.
Jumping to any 2.x results in total failure described above except on pin D1
I was able to reflash them to 1.5.1 and then upgrade them to 1.5.2 and everything is back online and working again on all my photon devices.

So here’s how I have it resolved for now, for anyone else in the same situation.

Pull your photon from service and connect to USB
Install Particle CLI, (If you don’t have it already)
download 1.5.1 FW here, https://github.com/particle-iot/device-os/releases/download/v1.5.1/particle_device-os@1.5.1.zip
Extract 2 files located in the particle_device-os@1.5.1.zip\1.5.1\photon\release\
Called “photon-system-part1@1.5.1.bin” and “photon-system-part2@1.5.1.bin”
Place them in a known location IE: \Desktop
Open Powershell and navigate to the directory you have them downloaded at IE: C:\users\Steve\Desktop
Then plug in your Photon to your computer USB and hold down Reset and Setup at the same time, then release ONLY the reset button and hold until it goes yellow LED
Then run these 3 commands in Powershell pressing enter after each one
particle flash --usb photon-system-part1@1.5.1.bin
particle flash --usb photon-system-part2@1.5.1.bin
particle flash --usb tinker

Your device should now be online and accessible as normal. BEFORE you send your code of choice to the device make sure to select FW no higher than 1.5.2
Then flash with your code. Return the device to service.

Not sure if the issue is in the FW 2.X OR if the libraries need to be updated to support 2.x That’s above my pay grade to understand all that BUT this is what got my entire sensor network back up and running again.

But I’m up and running again.

You could have a try with a different DHT library - others seem to have no problem with this one on 2.2.0 or even 3.x.x

Before incorporating this into your project you can give one of the samples a try
https://build.particle.io/libs/PietteTech_DHT/0.0.14/tab/example/DHT_simple.ino

1 Like

I tried the other libraries too but they all use different calls, and I didn’t want to go through the code for all my devices and rewrite them for the new calls on a new library. That was set as my total last ditch effort, if all else failed I would have gone down that road.
But reverting FW did the trick and no code rewrites needed.
So Hopefully someone smarter than me will fix the FW or the Library for future people :slight_smile:
I’m guessing the library needs an update for something that changed in 2.x or 3.x but that’s WAY out of my skill level. :slight_smile:

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