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 #404 background imageLoading...
Page #404 background image
SunFounder ESP32 Starter Kit
(continued from previous page)
# Record the time when the echo pin goes high
time1 = time.ticks_us()
# Wait for the echo pin to go low
while ECHO.value():
pass
# Record the time when the echo pin goes low
time2 = time.ticks_us()
# Calculate the time difference between the two recorded times
during = time.ticks_diff(time2, time1)
# Calculate and return the distance (in cm) using the speed of sound (340 m/s)
return during * 340 / 2 / 10000
# Continuously measure and print the distance
while True:
dis = distance()
print('Distance: %.2f ' % dis)
time.sleep_ms(300) # Wait for 300 milliseconds before repeating
Once the program is running, the Shell will print out the distance of the ultrasonic sensor from the obstacle ahead.
3.31 5.13 Temperature - Humidity
The DHT11 is a temperature and humidity sensor commonly used for environmental measurements. It is a digital
sensor that communicates with a microcontroller to provide temperature and humidity readings.
In this project, we will be reading the DHT11 sensor and printing out the temperature and humidity values it detects.
By reading the data provided by the sensor, we can obtain the current temperature and humidity values in the environ-
ment. These values can be used for real-time monitoring of environmental conditions, weather observations, indoor
climate control, humidity reports, and more.
Required Components
In this project, we need the following components.
Its definitely convenient to buy a whole kit, heres the link:
Name ITEMS IN THIS KIT LINK
ESP32 Starter Kit 320+
You can also buy them separately from the links below.
398 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