Sorry, I can't seem to find out how to search the forum for this topic. I can't seem to find a working library for a DHT11 sensor and Arduino Mega. Any help will be appreciated.
Thanks
Google: Arduino DHT11 or go to your Library Manager, write DHT11 and you will find many options. Choose DHT Sensor Library for instance.
The libraries I have found give me an error , "Error compiling for board for Arduino Mega".
Any other suggestions?
Thanks
Sure - post your code, and include a link to where you got any libraries you are using.
Attach as an .ino file works best, unless it's very short.
cxplorrken:
Sorry, I can't seem to find out how to search the forum for this topic. I can't seem to find a working library for a DHT11 sensor and Arduino Mega. Any help will be appreciated.
The following sketch works well with MEGA+dht11 + the attached Library.
#include "DHT.h"
#define DHTPIN 8 // what digital pin we're connected to
#define DHTTYPE DHT11 // DHT11
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
dht.begin();
}
void loop()
{
delay(2000);
float humi = dht.readHumidity();
float tempC = dht.readTemperature();
float tempF = dht.readTemperature(true);
if (isnan(humi) || isnan(tempC) || isnan(tempF))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");Serial.print(humi);Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(tempC);Serial.print(" *C ");
Serial.print(tempF);Serial.println(" *F");
}
DHT-sensor-library-master.zip (13.9 KB)