Try to figure out how to interface with the DHT22, but it's not working right yet.
This commit is contained in:
parent
bed9a808b9
commit
e087e51ecb
|
@ -1,3 +1,6 @@
|
|||
[submodule "eeprom/lib/AT24Cx"]
|
||||
path = eeprom/lib/AT24Cx
|
||||
url = https://github.com/cyberp/AT24Cx.git
|
||||
[submodule "dht22/lib/SimpleDHT"]
|
||||
path = dht22/lib/SimpleDHT
|
||||
url = https://github.com/winlinvip/SimpleDHT
|
|
@ -0,0 +1,45 @@
|
|||
#include "lib/SimpleDHT/SimpleDHT.h"
|
||||
#include "lib/SimpleDHT/SimpleDHT.cpp"
|
||||
|
||||
const int dhtA_pin = 5;
|
||||
|
||||
SimpleDHT22 dhtA;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.println("DHT22 Demo");
|
||||
Serial.println("==========");
|
||||
|
||||
Serial.print("Configuring pins - ");
|
||||
pinMode(dhtA_pin, INPUT_PULLUP);
|
||||
Serial.println("done");
|
||||
|
||||
Serial.print("Waiting to warm DHT22 up - ");
|
||||
delay(2000); // Give the DHT22 time to warm up
|
||||
Serial.println("done");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
float temp, humidity;
|
||||
|
||||
int read_error = dhtA.read2(dhtA_pin, &temp, &humidity, NULL);
|
||||
if(read_error != SimpleDHTErrSuccess) {
|
||||
Serial.print("Error: Failed reading from the DHT22. Code: ");
|
||||
Serial.println(read_error);
|
||||
delay(2000); // We can only read every 2 seconds or so
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print("Error code: ");
|
||||
Serial.println(read_error);
|
||||
Serial.print("Temperature: ");
|
||||
Serial.print(temp);
|
||||
Serial.println(" deg celsius");
|
||||
Serial.print("Humidity: ");
|
||||
Serial.print(humidity);
|
||||
Serial.println("%");
|
||||
Serial.println("*****");
|
||||
|
||||
delay(2000); // We can only read every 2 seconds
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 80ac2b47c9caca07edf75f38289cfd64023872c9
|
Loading…
Reference in New Issue