Created
June 4, 2018 14:46
-
-
Save clive520/516b1652796f4948c54683177363018b to your computer and use it in GitHub Desktop.
NodeMCU_DHT11_LCD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//NodeMCU接線 | |
//I2C 1602 LCD顯示器 VCC接到5V;SDA接到D2;SCL接到D1 | |
//DHT11 VCC接到5V;Data接到D4;VCC和Data中間要接一個4.7K的電阻 | |
// | |
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
#include "DHT.h" | |
LiquidCrystal_I2C lcd(0x27,16,2); | |
DHT dht2(2,DHT11); | |
void setup() | |
{ | |
Serial.begin(9600); | |
lcd.begin(); | |
Serial.println("start....."); | |
} | |
void loop() | |
{ | |
lcd.setCursor(0, 0); | |
lcd.print("Temperature:"); | |
lcd.setCursor(12, 0); | |
lcd.print((dht2.readTemperature( ))); | |
lcd.setCursor(0, 1); | |
lcd.print("Humidity:"); | |
lcd.setCursor(9, 1); | |
lcd.print((dht2.readHumidity( ))); | |
Serial.println("Temperature"); | |
Serial.println((dht2.readTemperature( ))); | |
Serial.println("Humidity"); | |
Serial.println((dht2.readHumidity( ))); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment