Arduino DHT11温湿度传感器示例程序
作者:互联网
1.首先安装SimpleDHT库文件
项目-》加载库-》管理库-》搜索SimpleDHT-》点击安装
2.示例程序
#include <SimpleDHT.h>
int pinDHT11 = D4; //温度传感器的输出引脚接到Arduino板子引脚上。此处用的是nodemcu的D4引脚
SimpleDHT11 dht11(pinDHT11);
void setup()
{
Serial.begin(9600); //设置串口波特率为9600;
}
void loop()
{
byte temperature = 0;
byte humidity = 0;
Serial.print("temperature: ");
Serial.print((int)temperature);
Serial.println(" *C ");
Serial.print("humidity: ");
Serial.print((int)humidity);
Serial.println(" H ");
delay(1500);
}
标签:temperature,Arduino,int,温湿度,引脚,示例,humidity,print,Serial 来源: https://blog.csdn.net/qq_41638072/article/details/104739457