1
void Sensor_value()
{   server.handleClient();
    humidity = dht.readHumidity();
    temperature = dht.readTemperature();     
 }

I want to make condition if temperature = null and Humidity= null that means the sensor fails to take reading so I want to return and take value again

Coder9390
  • 512
  • 1
  • 7
  • 25

1 Answers1

1

The way to do this is:

float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);

if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; }

See https://www.hackster.io/MisterBotBreak/how-to-use-temperature-and-humidity-dht-sensors-9e5975 and https://stackoverflow.com/questions/40874880/getting-nan-readings-from-dht-11-sensor.

NULL should only be used with pointers.

Michel Keijzers
  • 13,014
  • 7
  • 41
  • 58