I have a MegaPi and also wish to interface to a DHT11 sensor to get both temperature and humidity. For hardware I have the 3-pin sensor mounted on a board with a pullup resistor (http://www.uugear.com/portfolio/dht11-humidity-temperature-sensor-module/).
I started by using the MeHumitureSensorTest1.ino example in the Arduino IDE, which refers to “MeHumiture humiture(PORT_6);”. This code seems to
I’ve connected the GND, VCC and DAT from the DHT11 to the 3 pins on A6 (GND, VCC and SIG when I read them top to bottom). My code for MeHumitureSensorTest1 Sketch was modified to include megapi, temp and humidity header files:
include MeMegaPi.h
include MeHumitureSensor.h
MeHumiture humiture(PORT_6);
void setup()
{
Serial.begin(9600);
}
void loop()
{
humiture.update();
Serial.print(“Humidity (%) =”);
Serial.print( humiture.getHumidity() );
Serial.print(", Temperature (oC) =");
Serial.println( humiture.getTemperature() );
Serial.println("###########################");
delay(1000);
}
The code successfully compiles and I can see the following sent repeatedly over the Serial Monitor screen but the values are all zero:
Humidity (%) =0, Temperature (oC) =0
I suspect either I’ve:
- got DHT11 wired improperly into A6
- used incorrect syntax for addressing A6 port
- using incorrect function call syntax for the MegaPi hardware
Any suggestions would be greatly appreciated - thanks!
P.S. Note I added this same topic as a reply to another DHT11 question. Don’t mean to clutter up the forum but thought it should get it’s own topic. Please let me know if I should remove this new topic.