EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #450 background imageLoading...
Page #450 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
# Measure temperature and humidity
dht11.measure()
# Get temperature and humidity values
temp = dht11.temperature()
humi = dht11.humidity()
except Exception as e:
print("Error: ", e)
# Display temperature and humidity
lcd.write(0, 0, "Temp: {}\xDFC".format(temp))
lcd.write(0, 1, "Humi: {}%".format(humi))
# If page is 0, display the soil moisture and light
else:
light = photoresistor.read()
moisture = moisture_pin.read()
# Clear the LCD display
lcd.clear()
# Display the value of soil moisture and light
lcd.write(0, 0, f"Moisture: {moisture}")
lcd.write(0, 1, f"Light: {light}")
except KeyboardInterrupt:
# Stop the motor when KeyboardInterrupt is caught
stop()
• When the code is running, the I2C LCD1602 alternately displays temperature and humidity, as well as soil
moisture and light intensity analog values, with a 2-second interval.
• Press the button to start the water pump, and press it again to stop the water pump.
Note: If the code and wiring are correct, but the LCD still fails to display any content, you can adjust the potentiometer
on the back to increase the contrast.
444 Chapter 3. For MicroPython User

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish