node mcu上使用dht11(采用arduino ide编程)

#include “DHT.h”
#define DHTTYPE DHT11 // DHT 11
#define dht_dpin D5 //引脚
DHT dht(dht_dpin, DHTTYPE);
void setup(void)
{
dht.begin();
Serial.begin(9600);
Serial.println(“Humidity and temperature\n\n”);
delay(700);
}

void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Current humidity = “);
Serial.print(h);
Serial.print(”% ");
Serial.print("temperature = ");
Serial.print(t);
Serial.println("C ");
delay(800);
}

你可能感兴趣的:(node mcu上使用dht11(采用arduino ide编程))