humi
=
sensor.humidity()
# Print temperature and humidity
print("Temperature: {}, Humidity:
# Wait for 1 second between measurements
time.sleep(1)
except Exception as
print("Error:
time.sleep(1)
When the code is running, you will see the Shell continuously print out the temperature and humidity, and as the
program runs steadily, these two values will become more and more accurate.
Learn More
You can also display the temperature and humidity on the I2C LCD1602.
Note:
• Open the 5.13_dht11_lcd.py file located in the esp32-starter-kit-main\micropython\codes path, or
copy and paste the code into Thonny. Then, click "Run Current Script" or press F5 to execute it.
• Make sure to select the "MicroPython (ESP32).COMxx" interpreter in the bottom right corner.
3.31. 5.13 Temperature - Humidity
e:
", e)
{}".format(temp, humi))
SunFounder ESP32 Starter Kit
(continued from previous page)
401
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?