Jump to content

NodeMCU Projects: Difference between revisions

Line 92:
 
== DHT11 Temp Sensor ==
 
Source: [https://github.com/lvidarte/esp8266/wiki/MicroPython:-DHT11 github.com]
 
*Use DHT11 Module driectly, Do not use Sensor board with Pull Up resistor.
Line 110 ⟶ 112:
 
<syntaxhighlight lang="python">
import time
from machine import I2C, Pin
from dht import DHT11
from esp8266_i2c_lcd import I2cLcd
 
d = DHT11(Pin(14)) # Pin D5
from machine import Pin
from dht import DHT11
 
di2c = DHT11I2C(scl=Pin(145), sda=Pin(4), freq=400000) # Pin D5D1 & D2
lcd = I2cLcd(i2c, 63, 2, 16)
 
while True:
d.measure()
d.temperature() d.humidity()
lcd.putstr("Temp is: " + str(d.temperature()) + "'C \nHum is: " + str(d.humidity()) + "%")
time.sleep(10)
lcd.clear()
 
</syntaxhighlight>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.