Hello folks,
I am facing issue to get data from my DHT22 sensor .I tried several sketch but no luck.
I would like to get the temp and humidity sensor on my dashboard, if run the program without cayenne it works but i’m unable to get value from cayenne.
My sensor is connected on PIn 2 with arduino uno
here is my code
> //Libraries
> #include <DHT.h>;
> //Constants
> #define CAYENNE_PRINT Serial // Comment this out to disable prints and save space
> #include <CayenneEthernet.h>
> #define VIRTUAL_TEMP V2
> #define VIRTUAL_HUM V1
> #define DHTPIN 2 // what pin we're connected to
> #define DHTTYPE DHT22 // DHT 22 (AM2302)
> DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
> char token[] = "<token>";
> //Variables
> int chk;
> float hum; //Stores humidity value
> float temp; //Stores temperature value
> void setup()
> {
> Serial.begin(9600);
> Cayenne.begin(token);
> dht.begin();
> }
> void loop()
> {
> Cayenne.run();
> //Read data and store it to variables hum and temp
> hum = dht.readHumidity();
> temp= dht.readTemperature();
> //Print temp and humidity values to serial monitor
> Serial.print("Humidity: ");
> Serial.print(hum);
> Serial.print(" %, Temp: ");
> Serial.print(temp);
> Serial.println(" Celsius");
> delay(2000); //Delay 2 sec.
> }
appreciate some help thanks !