SunFounder ESP32 User manual

SunFounder ESP32 Starter Kit
www.sunfounder.com
Dec 29, 2023


CONTENTS
1 For Arduino User 3
1.1 1.1 Install Arduino IDE(Important) ................................... 3
1.2 1.2 Introduce of Arduino IDE ...................................... 9
1.3 1.3 Install the ESP32 Board(Important) ................................. 10
1.4 1.4 Install libraries (Important) ..................................... 15
1.5 2.1 Hello, LED! ............................................. 18
1.6 2.2 Fading ................................................ 22
1.7 2.3 Colorful Light ............................................ 26
1.8 2.4 Microchip - 74HC595 ........................................ 31
1.9 2.5 7 Segment Display .......................................... 34
1.10 2.6 Display Characters .......................................... 38
1.11 2.7 RGB LED Strip ........................................... 41
1.12 3.1 Beep ................................................. 45
1.13 3.2 Custom Tone ............................................. 48
1.14 4.1 Motor ................................................. 52
1.15 4.2 Pumping ............................................... 55
1.16 4.3 Swinging Servo ........................................... 58
1.17 5.1 Reading Button Value ........................................ 61
1.18 5.2 Tilt It ................................................. 66
1.19 5.3 Detect the Obstacle .......................................... 69
1.20 5.4 Detect the Line ............................................ 71
1.21 5.5 Detect Human Movement ...................................... 74
1.22 5.6 Two Kinds of Transistors ....................................... 77
1.23 5.7 Feel the Light ............................................. 83
1.24 5.8 Turn the Knob ............................................ 86
1.25 5.9 Measure Soil Moisture ........................................ 89
1.26 5.10 Thermometer ............................................ 91
1.27 5.11 Toggle the Joystick ......................................... 94
1.28 5.12 Measuring Distance ......................................... 96
1.29 5.13 Temperature - Humidity ...................................... 99
1.30 5.14 IR Receiver ............................................. 103
1.31 6.1 Fruit Piano .............................................. 107
1.32 6.2 Flowing Light ............................................ 111
1.33 6.3 Reversing Aid ............................................ 113
1.34 6.4 Digital Dice ............................................. 117
1.35 6.5 Color Gradient ............................................ 121
1.36 6.6 Plant Monitor ............................................. 125
1.37 6.7 Guess Number ............................................ 128
1.38 7.1 Bluetooth ............................................... 132
1.39 7.2 Bluetooth Control RGB LED .................................... 141
i

1.40 7.3 Bluetooth Audio Player ....................................... 147
1.41 7.4 SD Card Write and Read ....................................... 151
1.42 7.5 MP3 Player with SD Card Support .................................. 155
1.43 7.6 Take Photo SD ............................................ 158
1.44 8.1 Real-time Weather From @OpenWeatherMap ............................ 165
1.45 8.2 Camera Web Server ......................................... 169
1.46 8.3 Custom Video Streaming Web Server ................................ 173
1.47 8.4 IoT Communication with MQTT .................................. 178
1.48 8.5 CheerLights ............................................. 185
1.49 8.6 Temperature and Humidity Monitoring with Adafruit IO ...................... 189
1.50 8.7 ESP Camera with Telegram Bot ................................... 200
1.51 8.8 Camera with Home Assistant .................................... 207
1.52 8.9 Blynk-based Intrusion Notification System ............................. 221
1.53 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth ............. 238
2 Arduino Video Course 253
2.1 Video 1 - Introduce this Kit ....................................... 253
2.2 Video 2 - What’s ESP32, Camera Extension Board? .......................... 253
2.3 Video 3: “Hello LED” Project ...................................... 254
2.4 Video 4 - Data Types, Variables, and Serial Monitor .......................... 254
2.5 Video 5: LED Fade - Controlling LED Brightness ........................... 255
2.6 Video 6: Controlling RGB LEDs .................................... 255
2.7 Video 7: Arrays and Loops in Arduino Programming .......................... 256
2.8 Video 8: Walking Light with 74HC595 Shift Register ......................... 256
2.9 Video 9: Toggle LED with Push Button ................................. 257
2.10 Video 10: Digital Counter with Seven-Segment Display ........................ 257
2.11 Video 11: Using LCD1602/LCD2004 with ESP32 ........................... 257
2.12 Video 12: Using WS2812 RGB Strip .................................. 258
2.13 Video 13: Arduino Beep with Active Buzzer .............................. 258
2.14 Video 14: Playing Custom Music Note ................................. 259
2.15 Video 15: DC Motor Speed Control with ESP32 L293D ........................ 259
2.16 Video 16: Mini Water Pump using ESP32 and L293D ......................... 260
2.17 Video 17: Controlling Servo Motor ................................... 260
3 For MicroPython User 261
3.1 1.1 Introduction of MicroPython ..................................... 261
3.2 1.2 Install Thonny IDE .......................................... 262
3.3 1.3 Install MicroPython on the ESP32(Important) ............................ 264
3.4 1.4 Upload the Libraries (Important) .................................. 268
3.5 1.5 Quick Guide on Thonny ....................................... 271
3.6 1.6 (Optional) MicroPython Basic Syntax ................................ 280
3.7 2.1 Hello, LED! ............................................. 307
3.8 2.2 Fading LED ............................................. 311
3.9 2.3 Colorful Light ............................................ 315
3.10 2.4 Microchip - 74HC595 ........................................ 320
3.11 2.5 Number Display ........................................... 325
3.12 2.6 Display Characters .......................................... 329
3.13 2.7 RGB LED Strip ........................................... 332
3.14 3.1 Beep ................................................. 336
3.15 3.2 Custom Tone ............................................. 339
3.16 4.1 Small Fan ............................................... 344
3.17 4.2 Pumping ............................................... 349
3.18 4.3 Swinging Servo ........................................... 352
3.19 5.1 Reading Button Value ........................................ 355
ii

3.20 5.2 Tilt It ................................................. 359
3.21 5.3 Detect the Obstacle .......................................... 363
3.22 5.4 Detect the Line ............................................ 365
3.23 5.5 Detect Human Movement ...................................... 368
3.24 5.6 Two Kinds of Transistors ....................................... 373
3.25 5.7 Feel the Light ............................................. 379
3.26 5.8 Turn the Knob ............................................ 382
3.27 5.9 Measure Soil Moisture ........................................ 385
3.28 5.10 Temperature Sensing ........................................ 387
3.29 5.11 Toggle the Joystick ......................................... 393
3.30 5.12 Measuring Distance ......................................... 395
3.31 5.13 Temperature - Humidity ...................................... 398
3.32 5.14 IR Remote Control ......................................... 402
3.33 6.1 Fruit Piano .............................................. 407
3.34 6.2 Flowing Light ............................................ 412
3.35 6.3 Light Theremin ............................................ 415
3.36 6.4 Reversing Aid ............................................ 419
3.37 6.5 Color Gradient ............................................ 424
3.38 6.6 Digital Dice ............................................. 428
3.39 6.7 Guess Number ............................................ 432
3.40 6.8 Plant Monitor ............................................. 439
4 Play with Scratch 445
4.1 1.1 Install PictoBlox ........................................... 446
4.2 1.2 Interface Introduction ........................................ 447
4.3 1.3 Quick Guide on PictoBlox ...................................... 448
4.4 2.1 Table Lamp .............................................. 469
4.5 2.2 Breathing LED ............................................ 476
4.6 2.3 Colorful Balls ............................................ 483
4.7 2.4 Moving Mouse ............................................ 491
4.8 2.5 Doorbell ............................................... 498
4.9 2.6 Low Temperature Alarm ....................................... 505
4.10 2.7 Light Alarm Clock .......................................... 513
4.11 2.8 Read Temperature and Humidity ................................... 520
4.12 2.9 Rotating Fan ............................................. 526
4.13 2.10 Light Sensitive Ball ......................................... 534
4.14 2.11 GAME - Shooting .......................................... 547
4.15 2.12 GAME - Inflating the Balloon ................................... 560
4.16 2.13 GAME - Star-Crossed ........................................ 569
4.17 2.14 GAME - Eat Apple ......................................... 579
4.18 2.15 GAME - Flappy Parrot ....................................... 590
4.19 2.16 GAME - Breakout Clone ...................................... 599
4.20 2.17 GAME - Fishing .......................................... 610
4.21 2.18 GAME - Don’t Tap on The White Tile ............................... 619
4.22 2.19 GAME - Protect Your Heart .................................... 639
4.23 2.20 GAME - Kill Dragon ........................................ 656
5 Learn about the Components in Your Kit 679
5.1 ESP32 WROOM 32E .......................................... 680
5.2 ESP32 Camera Extension ........................................ 683
5.3 Breadboard ................................................ 689
5.4 Resistor .................................................. 693
5.5 Capacitor ................................................. 696
5.6 Jumper Wires ............................................... 698
iii

5.7 Transistor ................................................. 699
5.8 74HC595 ................................................. 701
5.9 L293D .................................................. 706
5.10 LED ................................................... 707
5.11 RGB LED ................................................ 713
5.12 7-segment Display ............................................ 716
5.13 I2C LCD1602 .............................................. 722
5.14 WS2812 RGB 8 LEDs Strip ....................................... 724
5.15 Buzzer .................................................. 725
5.16 Audio Module and Speaker ....................................... 726
5.17 DC Motor ................................................. 729
5.18 Servo ................................................... 731
5.19 Centrifugal Pump ............................................. 733
5.20 Button .................................................. 734
5.21 Tilt Switch ................................................ 736
5.22 Potentiometer ............................................... 737
5.23 Joystick Module ............................................. 738
5.24 IR Receiver ................................................ 740
5.25 Photoresistor ............................................... 742
5.26 Thermistor ................................................ 743
5.27 DHT11 Humiture Sensor ......................................... 744
5.28 PIR Motion Sensor Module ....................................... 746
5.29 Line Tracking Module .......................................... 748
5.30 Soil Moisture Module .......................................... 749
5.31 Obstacle Avoidance Module ....................................... 751
5.32 Ultrasonic Module ............................................ 752
6 FAQ 755
6.1 How to use Blynk on mobile device? .................................. 755
6.2 How to format the SD card? ....................................... 757
6.3 Always displaying “Unknown COMxx”? ................................ 760
7 Thank You 763
8 Copyright Notice 765
iv

SunFounder ESP32 Starter Kit
Thanks for choosing our ESP32 Starter Kit.
Note: This document is available in the following languages.
•
•
•
Please click on the respective links to access the document in your preferred language.
Welcome to the ESP32 Learning Kit! This comprehensive package is designed to offer both beginners and seasoned
developers a deep dive into the versatile world of the ESP32 microcontroller. With the ESP32 WROOM 32E at its
core, and a range of accompanying components like LEDs, sensors, motors, and more, users can explore a vast array
of projects.
Whether you’re keen on basic electronics, IoT integrations, this kit has it all. For MicroPython enthusiasts, we provide a
structured introduction to MicroPython, complete with IDE setups and basic syntax lessons. Arduino users are not left
behind, with a dedicated section on getting started with Arduino, and a suite of basic projects to jumpstart the learning
process.
For the creatives, there’s a delightful section on integrating with Scratch, allowing for a blend of programming and sto-
rytelling. Each project in the kit is meticulously outlined, ensuring you understand the objectives, the circuit assembly,
and the programming aspects.
With a myriad of game projects, practical applications, and troubleshooting FAQs, this kit promises an enriching learn-
ing experience for all. Dive in and let the ESP32 adventure begin!
If you have any questions or other interesting ideas, feel free to send an email to service@sunfounder.com.
CONTENTS 1

SunFounder ESP32 Starter Kit
2 CONTENTS

CHAPTER
ONE
FOR ARDUINO USER
Here is the complete code package for the ESP32 Starter Kit. You can click on the following link to download it:
•SunFounder ESP32 Starter Kit
Once the download is complete, unzip the file and open the relevant example code or project files in the corresponding
software. This will allow you to browse and utilize all the code and resources provided by the kit.
1. Get Started
1.1 1.1 Install Arduino IDE(Important)
The Arduino IDE, known as Arduino Integrated Development Environment, provides all the software support needed to
complete an Arduino project. It is a programming software specifically designed for Arduino, provided by the Arduino
team, that allows us to write programs and upload them to the Arduino board.
The Arduino IDE 2.0 is an open-source project. It is a big step from its sturdy predecessor, Arduino IDE 1.x, and
comes with revamped UI, improved board & library manager, debugger, autocomplete feature and much more.
In this tutorial, we will show how to download and install the Arduino IDE 2.0 on your Windows, Mac, or Linux
computer.
1.1.1 Requirements
•Windows - Win 10 and newer, 64 bits
•Linux - 64 bits
•Mac OS X - Version 10.14: “Mojave” or newer, 64 bits
1.1.2 Download the Arduino IDE 2.0
1. Vist .
2. Download the IDE for your OS version.
3

SunFounder ESP32 Starter Kit
1.1.3 Installation
Windows
1. Double click the arduino-ide_xxxx.exe file to run the downloaded file.
2. Read the License Agreement and agree it.
3. Choose installation options.
4 Chapter 1. For Arduino User

SunFounder ESP32 Starter Kit
4. Choose install location. It is recommended that the software be installed on a drive other than the system drive.
5. Then Finish.
1.1. 1.1 Install Arduino IDE(Important) 5

SunFounder ESP32 Starter Kit
macOS
Double click on the downloaded arduino_ide_xxxx.dmg file and follow the instructions to copy the Arduino
IDE.app to the Applications folder, you will see the Arduino IDE installed successfully after a few seconds.
6 Chapter 1. For Arduino User

SunFounder ESP32 Starter Kit
Linux
For the tutorial on installing the Arduino IDE 2.0 on a Linux system, please refer to: https://docs.arduino.cc/software/
ide-v2/tutorials/getting-started/ide-v2-downloading-and-installing#linux
1.1.4 Open the IDE
1. When you first open Arduino IDE 2.0, it automatically installs the Arduino AVR Boards, built-in libraries, and
other required files.
2. In addition, your firewall or security center may pop up a few times asking you if you want to install some device
driver. Please install all of them.
1.1. 1.1 Install Arduino IDE(Important) 7

SunFounder ESP32 Starter Kit
3. Now your Arduino IDE is ready!
Note: In the event that some installations didn’t work due to network issues or other reasons, you
can reopen the Arduino IDE and it will finish the rest of the installation. The Output window will not
automatically open after all installations are complete unless you click Verify or Upload.
8 Chapter 1. For Arduino User

SunFounder ESP32 Starter Kit
1.2 1.2 Introduce of Arduino IDE
1. Verify: Compile your code. Any syntax problem will be prompted with errors.
2. Upload: Upload the code to your board. When you click the button, the RX and TX LEDs on the board will
flicker fast and won’t stop until the upload is done.
3. Debug: For line-by-line error checking.
4. Select Board: Quick setup board and port.
5. Serial Plotter: Check the change of reading value.
6. Serial Monitor: Click the button and a window will appear. It receives the data sent from your control board. It
is very useful for debugging.
7. File: Click the menu and a drop-down list will appear, including file creating, opening, saving, closing, some
parameter configuring, etc.
8. Edit: Click the menu. On the drop-down list, there are some editing operations like Cut,Copy,Paste,Find,
and so on, with their corresponding shortcuts.
9. Sketch: Includes operations like Verify,Upload,Add files, etc. More important function is Include Library -
where you can add libraries.
1.2. 1.2 Introduce of Arduino IDE 9

SunFounder ESP32 Starter Kit
10. Tool: Includes some tools - the most frequently used Board (the board you use) and Port (the port your board is
at). Every time you want to upload the code, you need to select or check them.
11. Help: If you’re a beginner, you may check the options under the menu and get the help you need, including
operations in IDE, introduction information, troubleshooting, code explanation, etc.
12. Output Bar: Switch the output tab here.
13. Output Window: Print information.
14. Board and Port: Here you can preview the board and port selected for code upload. You can select them again
by Tools -> Board /Port if any is incorrect.
15. The editing area of the IDE. You can write code here.
16. Sketchbook: For managing sketch files.
17. Board Manager: For managing board driver.
18. Library Manager: For managing your library files.
19. Debug: Help debugging code.
20. Search: Search the codes from your sketches.
1.3 1.3 Install the ESP32 Board(Important)
To program the ESP32 microcontroller, we need to install the ESP32 board package in the Arduino IDE. Follow the
step-by-step guide below:
Install the ESP32 Board
1. Open the Arduino IDE. Go to File and select Preferences from the drop-down menu.
2. In the Preferences window, locate the Additional Board Manager URLs field. Click on it to activate the text
box.
10 Chapter 1. For Arduino User

SunFounder ESP32 Starter Kit
3. Add the following URL to the Additional Board Manager URLs field: https://espressif.github.io/
arduino-esp32/package_esp32_index.json. This URL points to the package index file for the ESP32 boards.
Click the OK button to save the changes.
4. In the Boards Manager window, type ESP32 in the search bar. Click the Install button to start the installation
1.3. 1.3 Install the ESP32 Board(Important) 11

SunFounder ESP32 Starter Kit
process. This will download and install the ESP32 board package.
5. Congratulations! You have successfully installed the ESP32 board package in the Arduino IDE.
Upload the Code
1. Now, connect the ESP32 WROOM 32E to your computer using a Micro USB cable.
2. Then select the correct board, ESP32 Dev Module, by clicking on Tools -> Board -> esp32.
12 Chapter 1. For Arduino User

SunFounder ESP32 Starter Kit
3. If your ESP32 is connected to the computer, you can choose the correct port by clicking on Tools -> Port.
4. Additionally, Arduino 2.0 introduced a new way to quickly select the board and port. For ESP32, it is usually
not automatically recognized, so you need to click on Select other board and port.
5. In the search box, type ESP32 Dev Module and select it when it appears. Then, choose the correct port and click
OK.
1.3. 1.3 Install the ESP32 Board(Important) 13

SunFounder ESP32 Starter Kit
6. Afterward, you can select it through this quick access window. Note that during subsequent use, there may be
times when ESP32 is not available in the quick access window, and you will need to repeat the above two steps.
7. Both methods allow you to select the correct board and port, so choose the one that suits you best. Now, everything
is ready to upload the code to the ESP32.
14 Chapter 1. For Arduino User
Table of contents
Popular Controllers manuals by other brands

Seltron
Seltron Regulus RCD2 Installation and maintenance manual

Mitsubishi
Mitsubishi MELSEC-A AJ35PTC-CNV user manual

Bray
Bray Series 70 Operation and maintenance manual

Unitronics
Unitronics Vision OPLC V350-35-TR20 installation guide

TECH
TECH EU-21DHW user manual

Hamilton
Hamilton C2000 Operational manual

thomann
thomann BOTEX Rainbow Rider DMX user manual

Superior Electric
Superior Electric STABILINE WHR34 S Series instructions

SE Controls
SE Controls OS2 Technical information and operating instructions

Auber Instruments
Auber Instruments KIT-RSPb installation guide

Auber
Auber RDK-300B instruction manual

Zodiac
Zodiac pH Perfect manual