problem in program I need your help

good morning
I have a problem with the program which I have made for controlling home appliances I have LDR, PIR, SOUND and TEMP DHT11 (3 pin) and 4 relay with Arduino Leonardo
first problem I cant see the temp value in the serial monitor
second it is working in the opposite way when it should be high it is low and the opposite correct so I made it opposite to work good and the temp relay it stay on only, please could you help me to correct the code.

final_LDR___PIR_ok__sound_and_temp.ino (1.74 KB)

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks..Tom... :)

it is so difficult but I will do

it takes some time

thanks

#include <dht11.h>
dht11 DHT11;

#define LDR A0
#define PIR 2
#define SOUND A1
#define DHT11PIN 7

/**

  • AnalogReadSerial
  • Reads an analog input pin 1 and prints the result to the serial monitor
  • Click on the serial monitor button to open it.
    */

#define RELAY_1 3
#define RELAY_2 4
#define RELAY_3 5
#define RELAY_4 6

int pirState;
int sensorValue;
int ldrValue;

void setup() {
DHT11.attach(4);
Serial.begin(9600);
Serial.println(“Virtuabotix DHT11 FAN & Heater CONTROL”);
pinMode(RELAY_1, OUTPUT);
pinMode(RELAY_2, OUTPUT);
pinMode(RELAY_3, OUTPUT);
pinMode(RELAY_4, OUTPUT);
digitalWrite(RELAY_4, LOW);//turn off the relay
pinMode(PIR, INPUT);
digitalWrite(RELAY_1, HIGH);
pinMode(SOUND, INPUT);

}

void loop(){
ldrValue = analogRead(LDR);
//Serial.print("Analog reading = ");
//Serial.println(ldrValue);

if (ldrValue <= 512) { // dark
digitalWrite(RELAY_2, LOW);
}
else { // light
digitalWrite(RELAY_2, HIGH);
}
pirState = digitalRead(PIR);
if (pirState == LOW) {
digitalWrite(RELAY_1, HIGH);
}
else {
digitalWrite(RELAY_1, LOW);
delay(10000);
}
{
sensorValue = analogRead(SOUND);
Serial.println(sensorValue, DEC);
delay(10);
if (sensorValue <= 5) {
digitalWrite(RELAY_3, HIGH);
}
else {
digitalWrite(RELAY_3, LOW);
delay(10000);
}
}

{

Serial.println("\n");
int chk = DHT11.read();
Serial.print("Read sensor: ");
switch (chk)
}

Serial.print("Temperature (C): ");
Serial.println(DHT11.temperature, DEC);
if(DHT11.temperature < 30)//change to match your threshold in C.

{
digitalWrite(heatrelaypin, HIGH);//turn on the heater

}
else

{
digitalWrite(heatrelaypin, LOW);
}
delay(2000);

}

}

    switch (chk)Why switch and no cases ?

:) should I delete it ?

ok

Almawali: ok

Full marks for brevity :)

...R