DHT22 Sensor not Reading Temp using DHTNEW Library.

Hello! This is my first post on the forum, I hope someone can help me.
I am making a system which is a solar powered wildfire detection system for a university project. The code should read three sensors then send an SMS if a fire is detected. The system senses temperature, light and smoke. The light and smoke sensors are working but the temperature is not. I am using a DHT22 sensor for the temperature. I know the sensor is connected properly as example code from the library works well. The measured temperature is printed through serial so I can see if it is working but it is not printing anything and the code is stopping.
Show below is my setup and loop functions as well as the function to read the temperature.

void setup() {
  Serial.begin(115200); //Turn on serial monitor at 115200 baud
  Serial.print("Wildfire Detection System\n");

void loop() {
  float tempurature = getTemp();
  int flame = getFlame();
  int smoke = getSmoke();
  if ((tempurature > tempThresh) && (flame > flameThresh) && (smoke > smokeThresh)) {
float getTemp() {
  float t = dht.getTemperature();
  Serial.print("Temperature: ");
  return t;

Could you please suggest why this is not working as intended. I am happy to add the rest of my code or anything else that is required.
Thank You! :slight_smile:

I guess the error is in that part of the code you're hiding from us.

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