I am writing a sketch that includes then below header file util.h
Earlier I had code to read DHT11 in the sketch iteself now I have moved it to a separate file.
after moving to separate file I am getting strange result after putting get data from DHT11 to a function in header
#include <dht.h>
namespace util
{
double* getTempHumdata(const int sensorPin)
{
dht DHT;
double nums [2];
int chk = DHT.read11(sensorPin);
// int chk = DHT.read(sensorPin);
int hum;
double temp;
int foo [] = { 10, 20, 30 };
Serial.print("Sensor ");
Serial.print(sensorPin);
Serial.print(" ");
switch (chk)
{
case 0:
hum = (double) DHT.humidity;
temp = (double) DHT.temperature;
nums[0] = temp;
nums[1] = hum;
Serial.print("Temperature: ");
Serial.print(nums[0]);
Serial.print(" Humidity: ");
Serial.println(nums[1]);
Serial.print(hum);
Serial.print(" % ");
Serial.print(temp);
Serial.println(" &#38;#38;#8451");
break;
case -1: Serial.println(" Checksum error"); break;
case -2: Serial.println(" Time out error"); break;
default: Serial.println(" Unknown error"); break;
return nums;
}
}
}
I have no clue why is this happening ?