SunFounder ESP32 Starter Kit
(continued from previous page)
humi = sensor.humidity()
# Print temperature and humidity
print("Temperature: {}, Humidity: {}".format(temp, humi))
# Wait for 1 second between measurements
time.sleep(1)
except Exception as e:
print("Error: ", e)
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 401