first commit
This commit is contained in:
1
code/DHT11/.pydio
Normal file
1
code/DHT11/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
e0c786df-dadb-46fe-90ef-812c4fcd06cc
|
||||
36
code/DHT11/DHT11.ino
Normal file
36
code/DHT11/DHT11.ino
Normal file
@@ -0,0 +1,36 @@
|
||||
#include "DHT.h"
|
||||
|
||||
#define DHTTYPE DHT11
|
||||
#define DHTPIN D3
|
||||
|
||||
DHT dht(DHTPIN, DHTTYPE);
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(9600);
|
||||
dht.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
delay(2000);
|
||||
|
||||
// 湿度
|
||||
float h = dht.readHumidity();
|
||||
// 摄氏温度温度
|
||||
float t = dht.readTemperature();
|
||||
|
||||
|
||||
if (isnan(h) || isnan(t)) {
|
||||
Serial.println(F("Failed to read from DHT sensor!"));
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print(F("Humidity: "));
|
||||
Serial.print(h);
|
||||
|
||||
Serial.print(F("% Temperature: "));
|
||||
Serial.print(t);
|
||||
|
||||
Serial.println(F("°C "));
|
||||
}
|
||||
Reference in New Issue
Block a user