Skip to content

Instantly share code, notes, and snippets.

@baobao
Created August 20, 2019 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baobao/4c9b7d2d29b963213d37f1df0071ccc4 to your computer and use it in GitHub Desktop.
Save baobao/4c9b7d2d29b963213d37f1df0071ccc4 to your computer and use it in GitHub Desktop.
#include <DHT.h>
int pin = 9;
DHT dht(pin, DHT11);
void setup()
{
Serial.begin(9600);
dht.begin();
}
void loop()
{
// 湿度
float percentHumidity = dht.readHumidity();
// 温度
float temperature = dht.readTemperature( isFahrenheit_ );
Serial.println(percentHumidity);
Serial.println(temperature);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment