// IIC转接板的VCC、GND分别连接开发板5V、GND,转接板的SDA、SCL连接开发板A4、A5。
#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN,DHTTYPE);
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {
// put your setup code here, to run once:
dht.begin();
lcd.init();
lcd.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
float hum=dht.readHumidity();
float temp=dht.readTemperature();
lcd.setCursor(0,0);
lcd.print(" hum:");
lcd.print(hum);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("temp:");
lcd.print(temp);
lcd.print("C");
delay(1000);
}