Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KC868-A4 dht22 problem
#1
i'm using a dht22 and input 1 and output1.
i made a simple code where i'm showing the dht22 value in the serial monitoring and  when the intput1 is colsed i made the output1 in the ON state, and if the input1 is open the ouptput1 is OFF.
in the simulation everting work fine and the value of the dht22 sonsor is correct.

but when i add an lamp in the output1 and turn it on and off the value of the dht22 becomes null.
i tried to modify the code like add a delay... but no result. dht22 becomes null.

 here is my simple source code:
Code:
#define output1 4
#define input1   36


#include "DHT.h"
#define DHTPIN 13     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 
DHT dht(DHTPIN, DHTTYPE);



int temperatureSonde=0;

void setup() {
 
  Serial.begin(9600);
dht.begin();

pinMode(output1,OUTPUT);
pinMode(input1,INPUT);
}

int loading=0;

void loop() {

if (digitalRead(input1)==0 && digitalRead(output1)==0){digitalWrite(output1,1);
//delay(100);
}
else if(digitalRead(input1)==1 && digitalRead(output1)==1){digitalWrite(output1,0);
//delay(100);
}


/*********************humidity***************************/
// Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very s0 sensor)
  float h = dht.readHumidity();


  // Check if any reads failed and exit early (to try again).
  if (isnan(h) ) {
      Serial.println("Failed to read from DHT sensor!");
    }


  Serial.print(F("Humidity: "));
  Serial.println(int(dht.readHumidity()));

/********************************************************/





delay(100);

}// end loop()
Reply


Messages In This Thread
KC868-A4 dht22 problem - by Joseph.o - 03-13-2023, 11:19 PM
RE: KC868-A4 dht22 problem - by admin - 03-14-2023, 12:08 AM
RE: KC868-A4 dht22 problem - by Joseph.o - 03-14-2023, 07:37 PM
RE: KC868-A4 dht22 problem - by admin - 03-14-2023, 11:12 PM
RE: KC868-A4 dht22 problem - by Joseph.o - 03-15-2023, 01:53 AM
RE: KC868-A4 dht22 problem - by admin - 03-15-2023, 01:55 AM
RE: KC868-A4 dht22 problem - by Joseph.o - 03-15-2023, 02:05 AM
RE: KC868-A4 dht22 problem - by Joseph.o - 03-15-2023, 03:14 AM
RE: KC868-A4 dht22 problem - by kovalank - 03-15-2023, 03:25 AM
RE: KC868-A4 dht22 problem - by admin - 03-15-2023, 04:45 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)