Page 7
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.
CHAPTER 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.
Page 10
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. Chapter 1. For Arduino User...
Page 11
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)
Page 12
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. Chapter 1. For Arduino User...
Page 13
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.
Page 14
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.
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.
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.
Page 17
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)
Page 18
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. Chapter 1. For Arduino User...
Page 19
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 1.3. 1.3 Install the ESP32 Board(Important)
Page 20
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.
SunFounder ESP32 Starter Kit 1.4 1.4 Install libraries (Important) A library is a collection of pre-written code or functions that extend the capabilities of the Arduino IDE. Libraries provide ready-to-use code for various functionalities, allowing you to save time and effort in coding complex features.
Page 22
1. Open the Arduino IDE and go to Sketch -> Include Library -> Add .ZIP Library. 2. Navigate to the directory where the library files are located, such as the esp32-starter-kit\c\libraries folder, and select the desired library file, like ESP32-A2DP.zip. Then, click Open.
Page 23
SunFounder ESP32 Starter Kit 3. After a short while, you will receive a notification indicating a successful installation. 4. Repeat the same process to add the ESP8266Audio.zip library. Note: The libraries installed using either of the above methods can be found in the default library directory of the Arduino IDE, which is usually located at C:\Users\xxx\Documents\Arduino\libraries.
SunFounder ESP32 Starter Kit 2. Displays 1.5 2.1 Hello, LED! Just as printing “Hello, world!” is the first step in learning to program, using a program to drive an LED is the traditional introduction to learning physical programming. Required Components In this project, we need the following components.
Page 25
Breadboard Jumper Wires Resistor Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic This circuit works on a simple principle, and the current direction is shown in the figure.
Page 26
1. You can open the file 2.1_hello_led.ino under the path of esp32-starter-kit-main\c\codes\2. 1_hello_led. Or copy this code to the Arduino IDE directly . 2. Then connect the ESP32 WROOM 32E to your computer using a Micro USB cable. • Always displaying “Unknown COMxx”?
Page 27
SunFounder ESP32 Starter Kit 3. Select the board (ESP32 Dev Module) and the appropriate port. 4. Now, click the Upload button to upload the code to the ESP32 board. 5. After the code is uploaded successfully, you will see the LED blinking.
LED gradually brightening and dimming, simulating a breathing effect. By using the PWM capabilities of the ESP32 WROOM 32E, we can achieve smooth and precise control over the LED’s brightness. This breathing effect adds a dynamic and visually appealing element to your projects, creating an eye-catching display or ambiance.
Page 29
Breadboard Jumper Wires Resistor Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 30
Note: • You can open the file 2.2_fading_led.ino under the path of esp32-starter-kit-main\c\codes\2. 2_fading_led. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is uploaded successfully, you can see the LED breathing.
Page 31
SunFounder ESP32 Starter Kit void setup() { ledcSetup(0, 5000, 8); // Configure the PWM channel (0) with 5000Hz␣ frequency and 8-bit resolution ledcAttachPin(ledPin, 0); // Attach the LED pin to the PWM channel Here we use the (LED control) peripheral which is primarly designed to control the intensity of LEDs, although it can also be used to generate PWM signals for other purposes.
Jumper Wires Resistor RGB LED Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic Chapter 1.
Page 33
SunFounder ESP32 Starter Kit The PWM pins pin27, pin26 and pin25 control the Red, Green and Blue pins of the RGB LED respectively, and connect the common cathode pin to GND. This allows the RGB LED to display a specific color by superimposing light on these pins with different PWM values.
Page 34
Note: • You can open the file 2.3_rgb_led.ino under the path of esp32-starter-kit-main\c\codes\2. 3_rgb_led. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Chapter 1. For Arduino User...
Page 35
SunFounder ESP32 Starter Kit Write the RGB value into color_set(), you will be able to see the RGB light up the colors you want. How it works? 1. Define the GPIO pins, the PWM channels and the frequency (in Hz) and resolution (in bits).
Page 36
SunFounder ESP32 Starter Kit (continued from previous page) Here we use the (LED control) peripheral which is primarly designed to control the intensity of LEDs, although it can also be used to generate PWM signals for other purposes. • uint32_t ledcSetup(uint8_t channel, uint32_t freq, uint8_t resolution_bits);: This function is used to setup the LEDC channel frequency and...
Jumper Wires Resistor 74HC595 Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic 1.8.
Page 38
SunFounder ESP32 Starter Kit • When MR (pin10) is high level and CE (pin13) is low level, data is input in the rising edge of SHcp and goes to the memory register through the rising edge of SHcp. • If the two clocks are connected together, the shift register is always one pulse earlier than the memory register.
Page 39
• Always displaying “Unknown COMxx”? When you finish uploading the codes to the ESP32 board, you can see the LEDs turning on one after another. How it works? 1. Declare an array, store several 8 bit binary numbers that are used to change the working state of the eight LEDs controlled by 74HC595.
SunFounder ESP32 Starter Kit datArray[] {B00000000, B00000001, B00000011, B00000111, B00001111,␣ B00011111, B00111111, B01111111, B11111111}; 2. loop() function. void loop() for(int 0; num <10; num++) digitalWrite(STcp,LOW); //Set ST_CP and hold low for as long as␣ you are transmitting shiftOut(DS,SHcp,MSBFIRST,datArray[num]); digitalWrite(STcp,HIGH); //pull the ST_CPST_CP to save the data delay(1000);...
Page 41
Resistor 7-segment Display 74HC595 Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 42
SunFounder ESP32 Starter Kit Table 1: Wiring 74HC595 LED Segment Display Wiring Chapter 1. For Arduino User...
Page 43
Code Note: • Open the 2.5_7segment.ino file under the path of esp32-starter-kit-main\c\codes\2.5_7segment. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is uploaded successfully, you will be able to see the LED Segment Display display 0~9 in sequence.
You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Jumper Wires I2C LCD1602 Available Pins Here is a list of available pins on the ESP32 board for this project. Chapter 1. For Arduino User...
Page 45
Code Note: • Open the 2.6_lcd1602.ino file under the path of esp32-starter-kit-main\c\codes\2.6_lcd1602. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The LiquidCrystal I2C library is used here, you can install it from the Library Manager.
Page 46
SunFounder ESP32 Starter Kit When this program is uploaded, the I2C LCD1602 will display the welcome message, “Hello, Sunfounder!”, for 3 seconds. After that, the screen will show a “COUNT:” label and the count value, which increments every second. 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.
SunFounder ESP32 Starter Kit void nobacklight() • Turn the LCD display on. void display() • Turn the LCD display off quickly. void nodisplay() • Clear display, set cursor position to zero. void clear() • Set the cursor position to col,row.
Page 48
WS2812 RGB 8 LEDs Strip Schematic Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Note: IO33 is not available for this project.
Page 49
• You can open the file 2.7_rgb_strip.ino under the path of esp32-starter-kit-main\c\codes\2. 7_rgb_strip. Or copy this code into Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
Page 50
SunFounder ESP32 Starter Kit When the code is successfully uploaded, the LEDs on the strip will sequentially turn on with a yellow color and then turn off, creating a simple chasing effect. How it works? 1. Include the Adafruit NeoPixel library: This line imports the Adafruit NeoPixel library so that the sketch can use its functions and classes to control the LED strip.
SunFounder ESP32 Starter Kit (continued from previous page) delay(100); // Wait for 100 milliseconds // Turn off LEDs one by one for (int 0; i < NUM_LEDS; i++) { strip.setPixelColor(i, 0, 0, 0); // Set the color of the i-th LED to␣...
Page 52
Resistor Buzzer Transistor Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic When the IO14 output is high, after the 1K current limiting resistor (to protect the transistor), the S8050 (NPN transistor) Chapter 1.
Page 53
SunFounder ESP32 Starter Kit will conduct, so that the buzzer will sound. The role of S8050 (NPN transistor) is to amplify the current and make the buzzer sound louder. In fact, you can also connect the buzzer directly to IO14, but you will find that the buzzer sound is smaller.
SunFounder ESP32 Starter Kit • You can open the file 3.1_beep.ino under the path of esp32-starter-kit-main\c\codes\3.1_beep. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is uploaded successfully, you will hear a beep every second.
Page 55
SunFounder ESP32 Starter Kit When the IO14 output is high, after the 1K current limiting resistor (to protect the transistor), the S8050 (NPN transistor) will conduct, so that the buzzer will sound. The role of S8050 (NPN transistor) is to amplify the current and make the buzzer sound louder. In fact, you can also connect the buzzer directly to IO14, but you will find that the buzzer sound is smaller.
Page 56
Note: • Open the 3.2_custom_tone.ino file under the path of esp32-starter-kit-main\c\codes\3. 2_custom_tone. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is successfully uploaded, you will hear the passive buzzer play a sequence of 7 musical notes.
Page 57
SunFounder ESP32 Starter Kit void playFrequency(int frequency, duration) { ledcWriteTone(0, frequency); // Start the tone delay(duration); // Wait for the specified duration ledcWriteTone(0, 0); // Stop the buzzer • uint32_t ledcWriteTone(uint8_t chan, uint32_t freq);: This function is used to setup the LEDC channel to 50 % PWM tone on selected frequency.
Jumper Wires DC Motor L293D Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic Chapter 1.
Page 59
SunFounder ESP32 Starter Kit Wiring Note: Since the motor requires a relatively high current, it is necessary to first insert the battery and then slide the switch on the expansion board to the ON position to activate the battery supply.
Page 60
Code Note: • Open the 4.1_motor.ino file under the path of esp32-starter-kit-main\c\codes\4.1_motor. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Once the code is successfully uploaded, you will observe the motor rotating clockwise for one second, then counter- clockwise for one second, followed by a two-second pause.
Jumper Wires Centrifugal Pump L293D Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic 1.15.
Page 62
SunFounder ESP32 Starter Kit Wiring Note: It is recommended here to insert the battery and then slide the switch on the expansion board to the ON position to activate the battery supply. Chapter 1. For Arduino User...
Page 63
Code Note: • You can open the file 4.2_pump.ino under the path of esp32-starter-kit-main\c\codes\4.2_pump. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Connect the tubing to the pump and place it inside the water-filled container. Once the code has been successfully uploaded, you will observe the water in the container gradually being drained.
ESP32 Camera Extension Jumper Wires Servo Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic Chapter 1.
Page 65
Note: • Open the 4.3_servo.ino file under the path of esp32-starter-kit-main\c\codes\4.3_servo. Or copy this code into Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The ESP32Servo library is used here, you can install it from the Library Manager.
Page 66
SunFounder ESP32 Starter Kit Once you finish uploading the code, you can see the servo arm rotating in the range 0°~180°. How it works? 1. Include the library: This line imports the ESP32Servo library, which is required to control the servo motor.
SunFounder ESP32 Starter Kit – pin: The GPIO pin number that the servo is connected to. – The min and max: the minimum and maximum pulse widths, respectively, in microseconds. These values define the range of motion of the servo motor.
Page 68
Resistor Button Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO14, IO25, I35, I34, I39, I36, IO18, IO19, IO21, IO22, IO23 For Output IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 •...
Page 69
SunFounder ESP32 Starter Kit Schematic To ensure proper functionality, connect one side of the button pin to 3.3V and the other side to IO14. When the button is pressed, IO14 will be set to high, causing the LED to light up. When the button is released, IO14 will return to its suspended state, which may be either high or low.
Page 70
Code Note: • You can open the file 5.1_button.ino under the path of esp32-starter-kit-main\c\codes\5.1_button. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Once the code is uploaded successfully, the LED lights up when you press the button and goes off when you release it.
Page 71
The previous projects all involved outputting signals, either in the form of digital or PWM signals. This project involves receiving input signals from external component to the ESP32 board. You can view the input signal through the Serial Monitor in Arduino IDE.
SunFounder ESP32 Starter Kit void loop() { // read the state of the button value buttonState digitalRead(buttonPin); Serial.println(buttonState); delay(100); // if the button is pressed, the buttonState is HIGH HIGH) { (buttonState // turn LED on digitalWrite(ledPin, HIGH); else // turn LED off digitalWrite(ledPin, LOW);...
Page 73
Resistor Tilt Switch Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO14, IO25, I35, I34, I39, I36, IO18, IO19, IO21, IO22, IO23 For Output IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 •...
Page 74
SunFounder ESP32 Starter Kit When the tilt switch is in an upright position, IO14 will be set to high, resulting in the LED being lit. Conversely, when the tilt switch is tilted, IO14 will be set to low, causing the LED to turn off.
Note: • You can open the file 5.2_tilt_switch.ino under the path of esp32-starter-kit-main\c\codes\5. 2_tilt_switch. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After code upload successfully, the LED will be turned on when the switch is upright, and turned off when the switch is tilted.
Page 76
Obstacle Avoidance Module Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23 •...
Note: • You can open the file 5.3.detect_the_obstacle.ino under the path of esp32-starter-kit-main\c\ codes\5.3.detect_the_obstacle. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is uploaded successfully, if the IR obstacle avoidance module detects something blocking in front of it, “0”...
Page 78
Line Tracking Module Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23 •...
Page 79
Note: • You can open the file 5.4_detect_the_line.ino under the path of esp32-starter-kit-main\c\codes\ 5.4_detect_the_line. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? If the line tracking module detects a black line after the code has been uploaded successfully, “Black” will be shown in the Serial Monitor.
PIR Motion Sensor Module Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23...
Page 81
SunFounder ESP32 Starter Kit Generally, it is not recommended to use them as input pins. If you wish to use these pins, consider the potential impact on the booting process. For more details, please refer to the Strapping Pins section.
Page 82
Code Note: • You can open the file 5.5_pir.ino under the path of esp32-starter-kit-main\c\codes\5.5_pir. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Chapter 1. For Arduino User...
SunFounder ESP32 Starter Kit After the code has been uploaded successfully, the LED will light up and then go off when the PIR module detects someone passing. Note: The PIR module has two potentiometers: one adjusts sensitivity, the other adjusts detection distance. To make the PIR module work better, you need to turn both of them counterclockwise to the end.
Page 84
Button Transistor Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO14, IO25, I35, I34, I39, I36, IO18, IO19, IO21, IO22, IO23 For Output IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 •...
Page 85
SunFounder ESP32 Starter Kit section. Way to connect NPN (S8050) transistor In this circuit, when the button is pressed, IO14 is high. By programming IO26 to output high, after a 1k current limiting resistor (to protect the transistor), the S8050 (NPN transistor) is allowed to conduct, thus allowing the LED to light up.
Page 86
SunFounder ESP32 Starter Kit Way to connect PNP(S8550) transistor Chapter 1. For Arduino User...
Page 87
SunFounder ESP32 Starter Kit In this circuit, IO14 is low by the default and will change to high when the button is pressed. By programming IO26 to output low, after a 1k current limiting resistor (to protect the transistor), the S8550 (PNP transistor) is allowed to conduct, thus allowing the LED to light up.
Page 88
Always displaying “Unknown COMxx”? Two types of transistors can be controlled using the same code. When we press the button, the ESP32 will send a high-level signal to the transistor; when we release it, it will send a low-level signal.
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 90
SunFounder ESP32 Starter Kit As the light intensity increases, the resistance of the light-dependent resistor (LDR) decreases, resulting in a decrease in the value read on I35. Wiring Chapter 1. For Arduino User...
Page 91
After the code is uploaded successfully, the Serial Monitor prints out the photoresistor values from 0 ~ 4095. The stronger the current ambient brightness, the larger the value displayed on the serial monitor. Note: For the ESP32, the resolution is between 9 to 12 and it will change the ADC hardware resolution. Else value will be shifted.
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 93
SunFounder ESP32 Starter Kit When you rotate the potentiometer, the value of I35 will change. By programming, you can use the value of I35 to control the brightness of the LED. Therefore, as you rotate the potentiometer, the brightness of the LED will also change accordingly.
Page 94
Code Note: • You can open the file 5.8_pot.ino under the path of esp32-starter-kit-main\c\codes\5.8_pot. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is uploaded successfully, rotate the potentiometer and you will see the brightness of the LED change accordingly.
SunFounder ESP32 Starter Kit 2. Configure the system in the setup() function. void setup() { Serial.begin(115200); // Configure PWM ledcSetup(channel, freq, resolution); ledcAttachPin(ledPin, channel); • In the setup() function, the Serial communication is started at a baud rate of 115200.
Page 96
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Code Note: • Open the 5.9_moisture.ino file under the path of esp32-starter-kit-main\c\codes\5.9_moisture. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Once the code is successfully uploaded, the serial monitor will print out the soil moisture value.
Page 98
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 99
Note: • Open the 5.10_thermistor.ino file under the path of esp32-starter-kit-main\c\codes\5. 10_thermistor. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is successfully uploaded, the Serial Monitor will print out the Celsius and Fahrenheit temperatures.
Note: • You can open the file 5.10_thermistor_lcd.ino under the path of euler-kit/arduino/5. 10_thermistor_lcd. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The LiquidCrystal I2C library is used here, you can install it from the Library Manager.
Page 101
ESP32 Camera Extension Jumper Wires Joystick Module • Available Pins Here is a list of available pins on the ESP32 board for this project. For Analog Input IO14, IO25, I35, I34, I39, I36 For Digital Input IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO15, IO2, IO0, IO4, IO5,...
Code Note: • Open the 5.11_joystick.ino file under the path of esp32-starter-kit-main\c\codes\5.11_joystick. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? Open the serial monitor after the code has been uploaded successfully to see the x,y,z values of the joystick.
Page 103
Schematic The ESP32 sends a set of square wave signals to the Trig pin of the ultrasonic sensor every 10 seconds. This prompts the ultrasonic sensor to emit a 40kHz ultrasound signal outward. If there is an obstacle in front, the ultrasound waves will be reflected back.
Page 104
Note: • Open the 5.12_ultrasonic.ino file under the path of esp32-starter-kit-main\c\codes\5. 12_ultrasonic. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? After the code is successfully uploaded, the serial monitor will print out the distance between the ultrasonic sensor and the obstacle ahead.
Jumper Wires DHT11 Humiture Sensor • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic 1.29.
Page 107
Code Note: • Open the 5.13_dht11.ino file under the path of esp32-starter-kit-main\c\codes\5.13_dht11. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The DHT sensor library library is used here, you can install it from the Library Manager.
Page 108
Note: • You can open the file 5.10_thermistor_lcd.ino under the path of euler-kit/arduino/5. 10_thermistor_lcd. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The LiquidCrystal_I2C and DHT sensor library libraries are used here, you can install them from the Library Manager.
ESP32 Camera Extension Breadboard Jumper Wires IR Receiver Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO15, IO0, IO5, IO18, IO19, IO21, IO22, IO23 Schematic...
Page 110
SunFounder ESP32 Starter Kit When you press a button on the remote control, the infrared receiver detects the signal, and you can use an infrared library to decode it. This decoding process allows you to obtain the key value associated with the button press.
Page 111
Note: • Open the 5.14_ir_receiver.ino file under the path of esp32-starter-kit-main\c\codes\5. 14_ir_receiver. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The IRremoteESP8266 library is used here, you can install it from the Library Manager.
Page 112
SunFounder ESP32 Starter Kit (continued from previous page) IRrecv irrecv(IR_RECEIVE_PIN); // Create a decode_results object decode_results results; 2. In the setup() function, serial communication is started at a baud rate of 115200, and the IR receiver is enabled using irrecv.enableIRIn().
Have you ever wanted to play the piano but couldn’t afford one? Or maybe you just want to have some fun with diy a fruit piano? Well, this project is for you! With just a few touch sensors on the ESP32 board, you can now play your favorite tunes and enjoy the experience of playing the piano without breaking the bank.
Page 114
• Sensitivity The touch sensor on the ESP32 is very sensitive and can detect even small changes in capacitance. The sensitivity can be adjusted using software settings. • ESD Protection The touch pins on the ESP32 have built-in ESD (Electrostatic Discharge) protection, which helps to prevent damage to the board from static electricity.
Page 115
SunFounder ESP32 Starter Kit The idea behind this project is to use touch sensors to detect when a user touches a specific pin. Each touch pin is associated with a specific note, and when the user touches a pin, the corresponding note is played on the passive buzzer.
Page 116
• Or copy this code into Arduino IDE. You can connect fruits to these ESP32 pins: 4, 15, 13, 12, 14, 27, 33, 32. When the script runs, touching these fruits will play the notes C, D, E, F, G, A, B and C5.
SunFounder ESP32 Starter Kit You can run the script first to see the values printed by the shell. After touching the fruits on pins 12, 14, and 27, the printed values are as follows. Therefore, I set the threshold to 30, which means that when a value less than 30 is detected, it is considered to be touched, and the buzzer will emit different notes.
Page 118
SunFounder ESP32 Starter Kit Schematic Diagram The WS2812 LED strip is composed of a series of individual LEDs that can be programmed to display different colors and patterns. In this project, the strip is set up to display a running light that moves in a particular direction and changes direction when an obstacle is detected by the obstacle avoidance module.
SunFounder ESP32 Starter Kit • You can open the file 6.2_flowing_led.ino under the path of esp32-starter-kit-main\c\codes\6. 2_flowing_led directly. • Or copy this code into Arduino IDE. This project extends the functionality of the project by adding the ability to display random colors 2.7 RGB LED Strip...
Page 121
SunFounder ESP32 Starter Kit The ultrasonic sensor in the project emits high-frequency sound waves and measures the time it takes for the waves to bounce back after hitting an object. By analyzing this data, the distance between the sensor and the object can be calculated.
Page 122
Note: • You can open the file 6.3_reversing_aid.ino under the path of esp32-starter-kit-main\c\codes\6. 3_reversing_aid directly. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The LiquidCrystal I2C library is used here, you can install it from the Library Manager.
SunFounder ESP32 Starter Kit 1. Loop to read distance and update parameters In the loop, the code first reads the distance measured by the ultrasonic module and updates the interval parameter based on the distance. // Update the distance distance readDistance();...
Page 124
SunFounder ESP32 Starter Kit Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 125
SunFounder ESP32 Starter Kit This project builds upon the project by adding a button to control the digit displayed on the 2.5 7 Segment Display seven-segment display. The button is directly connected to IO13 without an external pull-up or pull-down resistor because IO13 has an internal pull-up resistor of 47K, eliminating the need for an additional external resistor.
Page 126
Code Note: • Open the 6.4_digital_dice.ino file under the path of esp32-starter-kit-main\c\codes\6. 4_digital_dice. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? This project is based on with a button to start/pause the scrolling display on the 7-segment 2.5 7 Segment Display...
SunFounder ESP32 Starter Kit 1.35 6.5 Color Gradient Are you ready to experience a world of color? This project will take you on a magical journey where you can control an RGB LED and achieve smooth color transitions. Whether you’re looking to add some color to your home decor or seeking a fun programming project, this project has got you covered.
Page 129
SunFounder ESP32 Starter Kit The RGB LED has 4 pins: the long pin is the common cathode pin, which is usually connected to GND; the left pin next to the longest pin is Red; and the two pins on the right are Green and Blue.
Page 130
Note: • You can open the file 6.5_color_gradient.ino under the path of esp32-starter-kit-main\c\codes\ 6.5_color_gradient. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? This project uses an RGB LED and a potentiometer to create a color mixing effect. The potentiometer is used to adjust the hue value of the LED, which is then converted into RGB values using a color conversion function.
Welcome to the Plant Monitor project! In this project, we will be using an ESP32 board to create a system that helps us take care of our plants. With this system, we can monitor the temperature, humidity, soil moisture, and light levels of our plants, and ensure that they are getting the care and attention they need to thrive.
Page 132
SunFounder ESP32 Starter Kit The system uses a DHT11 sensor to measure the temperature and humidity levels of the surrounding environment. Meanwhile, a soil moisture module is used to measure the moisture level of the soil and a photoresistor is used to measure the light level.
Page 133
Note: • You can open the file 6.6_plant_monitor.ino under the path of esp32-starter-kit-main\c\codes\6. 6_plant_monitor. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The LiquidCrystal_I2C and DHT sensor library libraries are used here, you can install them from the Library Manager.
SunFounder ESP32 Starter Kit 1.37 6.7 Guess Number Are you feeling lucky? Want to test your intuition and see if you can guess the right number? Then look no further than the Guess Number game! With this project, you can play a fun and exciting game of chance.
Page 136
SunFounder ESP32 Starter Kit Code Note: • You can open the file 6.7_guess_number.ino under the path of esp32-starter-kit-main\c\codes\6. 7_guess_number directly. • The LiquidCrystal_I2C and IRremoteESP8266 libraries are used here, refer to for a Manual Installation tutorial to install. • After the code is successfully uploaded, press any number button on the remote control to start the game.
Page 137
SunFounder ESP32 Starter Kit on the back to increase the contrast. How it works? 1. In the setup() function, the I2C LCD screen and IR receiver are initialized. Then call the initNewValue() function to generate a new random lucky number, and a welcome message is displayed on the LCD screen.
BLE is a low-power wireless communication protocol that is designed for short-range communication. This document will cover the steps to set up the ESP32 to act as a BLE server and communicate with a BLE client over a serial connection.
Page 139
SunFounder ESP32 Starter Kit 2. Open the 7.1_bluetooth.ino file located in the esp32-starter-kit-main\c\codes\7.1_bluetooth di- rectory, or copy the code into the Arduino IDE. 3. To avoid UUID conflicts, it is recommended to randomly generate three new UUIDs using the , and fill them in the following lines of code.
Page 140
SunFounder ESP32 Starter Kit 4. Select the correct board and port, then click the Upload button. Chapter 1. For Arduino User...
Page 141
5. After the code has been successfully uploaded, turn on Bluetooth on your mobile device and open the LightBlue app. 6. On the Scan page, find ESP32-Bluetooth and click CONNECT. If you don’t see it, try refreshing the page a few times. When “Connected to device!” appears, the Bluetooth connection is successful. Scroll down to see the three UUIDs set in the code.
Page 142
SunFounder ESP32 Starter Kit 8. Go back to the Arduino IDE, open the Serial Monitor, set the baud rate to 115200, then type “welcome” and press Enter. Chapter 1. For Arduino User...
Page 143
SunFounder ESP32 Starter Kit 9. You should now see the “welcome” message in the LightBlue app. 10. To send information from the mobile device to the Serial Monitor, click the Send UUID, set the data format to “UTF-8 String”, and write a message.
Page 144
11. You should see the message in the Serial Monitor. How it works? This Arduino code is written for the ESP32 microcontroller and sets it up to communicate with a Bluetooth Low Energy (BLE) device. Chapter 1. For Arduino User...
Page 145
SunFounder ESP32 Starter Kit The following is a brief summary of the code: • Include necessary libraries: The code begins by including necessary libraries for working with Bluetooth Low Energy (BLE) on the ESP32. #include "BLEDevice.h" #include "BLEServer.h" #include "BLEUtils.h"...
Page 146
(connected or disconnected) of the BLE server. MyCharacteristicCallbacks is used to handle write events on the BLE characteristic, i.e., when a connected device sends a string to the ESP32 over BLE, it’s captured and stored in receivedText, and the current time is recorded in lastMessageTime.
SunFounder ESP32 Starter Kit (continued from previous page) nullptr) { (pServer Serial.println("Error creating BLE server"); return; pServer->setCallbacks(new MyServerCallbacks()); // Set the BLE server␣ callbacks // Create the BLE service BLEService *pService pServer->createService(SERVICE_UUID); // Print the error message if the BLE service creation fails...
Page 148
SunFounder ESP32 Starter Kit You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor RGB LED Operation Steps 1. Build the circuit. The RGB LED has 4 pins: the long pin is the common cathode pin, which is usually connected to GND;...
Page 149
SunFounder ESP32 Starter Kit 2. Open the 7.2_bluetooth_rgb_led.ino file located in the esp32-starter-kit-main\c\codes\7. 2_bluetooth_rgb_led directory, or copy the code into the Arduino IDE. 3. To avoid UUID conflicts, it is recommended to randomly generate three new UUIDs using the provided by the Bluetooth SIG, and fill them in the following lines of code.
Page 150
5. After the code has been successfully uploaded, turn on Bluetooth on your mobile device and open the LightBlue app. 6. On the Scan page, find ESP32-Bluetooth and click CONNECT. If you don’t see it, try refreshing the page a few times. When “Connected to device!” appears, the Bluetooth connection is successful. Scroll down to see the three UUIDs set in the code.
Page 151
SunFounder ESP32 Starter Kit 7. Tap the Send UUID, then set the data format to “UTF-8 String”. Now you can write these commands: “led_off”, “red”, “green”, “blue”, “yellow”, and “purple” to see if the RGB LED responds to these instructions.
Page 152
SunFounder ESP32 Starter Kit This code is an extension of a previous project(7.1 Bluetooth), adding RGB LED configurations and custom commands such as “led_off”, “red”, “green”, etc. These commands allow the RGB LED to be controlled by sending commands from a mobile device using LightBlue.
DAC. When using the internal DAC of the ESP32, it is important to note that the output voltage level is limited to 1.1V. Therefore, it is recommended to use an external amplifier to boost the output voltage level to the desired level. It is also important to ensure that the audio data is in the correct format and sample rate to prevent distortion or noise during playback.
Page 154
SunFounder ESP32 Starter Kit It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E...
Page 155
7.3_bluetooth_audio_player.ino esp32-starter-kit-main\c\codes\7.3_bluetooth_audio_player. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? • The ESP32-A2DP library is used here, refer to for a tutorial to install.
Page 156
SunFounder ESP32 Starter Kit 5. Play audio on the device and the audio should be played through the speaker connected to the ESP32. Code Explanation 1. The code starts by including the BluetoothA2DPSink.h library, which is used to receive audio data from the Bluetooth-enabled device.
1.41 7.4 SD Card Write and Read This project demonstrates the core capabilities of using an SD card with the ESP32 microcontroller. It showcases essential operations such as mounting the SD card, creating a file, writing data to the file, and listing all files within the root directory.
Page 158
SunFounder ESP32 Starter Kit 3. Select the appropriate port and board in the Arduino IDE and upload the code to your ESP32. Note: • Open the 7.4_sd_read_write.ino file under the path of esp32-starter-kit-main\c\ codes\7.4_sd_read_write. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.
Page 159
How it works? The purpose of this project is to demonstrate the usage of the SD card with the ESP32 board. The ESP32’s built-in SDMMC host peripheral is used to connect with the SD card. The project begins by initializing the serial communication and then attempts to mount the SD card. If the SD card fails to mount successfully, the program will print an error message and exit the setup function.
Page 160
SunFounder ESP32 Starter Kit File file SD_MMC.open("/test.txt", FILE_WRITE); (!file) { Serial.println("Failed to open file for writing"); // Print error␣ message if file failed to open return; • Write data to the file Write the text “Test file write” to the file. If the write operation is successful, it prints “File write successful”;...
1.42 7.5 MP3 Player with SD Card Support Welcome to the exciting world of music with your ESP32! This project brings the power of audio processing to your fingertips, making your ESP32 not just an amazing microcontroller for computing but also your personalized music player.
Page 162
If your SD card’s music is already soft, you can remove or replace the resistor with a smaller value. 5. Connect ESP32-WROOM-32E to the computer using the USB cable. Chapter 1. For Arduino User...
Page 163
Manual Installation 7. Select the appropriate port and board in the Arduino IDE and upload the code to your ESP32. 8. After successfully uploading the code, you will hear your favorite music playing. How it works? •...
1.43 7.6 Take Photo SD This document describes a project that involves taking a photo using the ESP32-CAM and saving it to an SD card. The aim of the project is to provide a simple solution for capturing images using the ESP32-CAM and storing them on an SD card.
Page 165
Related Precautions When using the ESP32-CAM, it is important to note that the GPIO 0 pin must be connected to GND to upload a sketch. Additionally, after connecting GPIO 0 to GND, the ESP32-CAM onboard RESET button must be pressed to put the board in flashing mode.
Page 166
5. Open the code. Note: • Open the 7.6_take_photo_sd.ino file under the path of esp32-starter-kit-main\c\ codes\7.6_take_photo_sd. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? 6. Now, enable PSRAM.
Page 167
7. Set the partition scheme to Huge APP (3MB No OTA/1MB SPIFFS). 8. Select the appropriate port and board in the Arduino IDE and upload the code to your ESP32. 9. After the successful upload of the code, press the Reset button to take a photo. Additionally, you can check the...
Page 168
How it works? This code operates an AI Thinker ESP32-CAM to take a photo, save it to an SD card, and then put the ESP32-CAM into deep sleep. Here is a breakdown of the key parts: •...
Page 169
SD card. pictureNumber • Setup Function: In the setup() function, several tasks are accomplished: – First, the brown-out detector is disabled to prevent the ESP32-CAM from resetting during high current draws (like when the camera is operating). WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0);...
Page 170
SunFounder ESP32 Starter Kit (continued from previous page) config.pin_sscb_scl SIOC_GPIO_NUM; config.pin_pwdn PWDN_GPIO_NUM; config.pin_reset RESET_GPIO_NUM; config.xclk_freq_hz 20000000; config.pixel_format PIXFORMAT_JPEG; – The camera is then initialized with the configuration, and if it fails, an error message is printed. esp_err_t err esp_camera_init(&config); (err ESP_OK) { Serial.printf("Camera init failed with error...
OUTPUT); digitalWrite(4, LOW); rtc_gpio_hold_en(GPIO_NUM_4); – Sleep Mode: The ESP32-CAM goes into deep sleep after taking each photo to conserve power. It can be woken up by a reset or by a signal on specific pins. delay(2000); Serial.println("Going to sleep now");...
Page 172
SunFounder ESP32 Starter Kit You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Jumper Wires I2C LCD1602 Get OpenWeather API keys is an online service, owned by OpenWeather Ltd, that provides global weather data via API, including current weather data, forecasts, nowcasts and historical weather data for any geographical location.
Page 173
SunFounder ESP32 Starter Kit 4. Under Current weather and forecasts collection , subscribe to the appropriate service. In our project, Free is good enough. 5. Copy the Key from the API keys page. 1.44. 8.1 Real-time Weather From @OpenWeatherMap...
Page 174
• Open the iot_1_open_weather.ino file located in the esp32-starter-kit-main\c\ codes\iot_1_open_weather directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
1.45 8.2 Camera Web Server This project combines the ESP32 board with a camera module to stream high-quality video over a local network. Set up your own camera system effortlessly and monitor any location in real-time. With the project’s web interface, you can access and control the camera feed from any device connected to the net- work.
Page 176
• Open the iot_2_camera_server.ino file located in the esp32-starter-kit-main\c\ codes\iot_2_camera_server directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? 4.
Page 177
SunFounder ESP32 Starter Kit 6. Set the partition scheme to Huge APP (3MB No OTA/1MB SPIFFS). 7. After selecting the correct board (ESP32 Dev Module) and port, click the “Upload” button. 1.45. 8.2 Camera Web Server...
Page 178
SunFounder ESP32 Starter Kit 8. You will see a successful WiFi connection message and the assigned IP address in the Serial Monitor..WiFi connected Starting web server on port: Starting stream server on port: Camera Ready! Use http://192.168.18.77 to connect 9.
SunFounder ESP32 Starter Kit Note: • This ESP32 module supports Face Detection. To enable it, set the resolution to 240x240 and toggle the Face Detection option at the bottom of the interface. • This ESP32 module does not support Face Recognition.
Page 180
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor How to do? 1. First plug in the camera. 2. Build the circuit. Chapter 1. For Arduino User...
Page 181
SunFounder ESP32 Starter Kit 3. Then, connect ESP32-WROOM-32E to the computer using the USB cable. 1.46. 8.3 Custom Video Streaming Web Server...
Page 182
• Open the iot_3_html_cam_led.ino file located in the esp32-starter-kit-main\c\ codes\iot_3_html_cam_led directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? 5.
Page 183
SunFounder ESP32 Starter Kit 9. Insert a battery into the expansion board and remove the USB cable. Now you can place the device anywhere you desire within the Wi-Fi range. 1.46. 8.3 Custom Video Streaming Web Server...
In this project, we explore the implementation of MQTT by building a circuit that includes an LED, a button, and a thermistor. The ESP32-WROOM-32E microcontroller is used to establish a connection to WiFi and communicate with an MQTT broker. The code allows the microcontroller to subscribe to specific topics, receive messages, and control the LED based on the received information.
Page 185
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Button Thermistor Code Upload 1. Build the circuit. Note: When establishing a connection to WiFi, only the 36, 39, 34, 35, 32, 33 pins can be employed for analog reading.
Page 186
SunFounder ESP32 Starter Kit 2. Then, connect ESP32-WROOM-32E to the computer using the USB cable. Chapter 1. For Arduino User...
Page 187
• Open the iot_4_mqtt.ino file located in the esp32-starter-kit-main\c\codes\ iot_4_mqtt directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
Page 188
SunFounder ESP32 Starter Kit (continued from previous page) const char* password "<PASSWORD>"; 5. Find the next line and modify your unique_identifier. Guarantee that your unique_identifier is truly unique as any IDs that are identical trying to log in to the same MQTT Broker may result in a login failure.
Page 189
"off") { Serial.println("off"); digitalWrite(ledPin, LOW); 3. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button. 4. Open the serial monitor and if the following information is printed, it indicates a successful connection to the MQTT server.
Page 190
SunFounder ESP32 Starter Kit 3. Publish a message in the Topic you have subscribed to. In this project, you can publish on or off to control your LED. Message Publication to MQTT We can also utilize the code to publish information to the Topic. In this demonstration, we have coded a feature that sends the temperature measured by the thermistor to the Topic when you press the button.
SunFounder ESP32 Starter Kit 2. Fill in the topics you desire to follow and click Subscribe. In the code, we send temperature information to the topic SF/TEMP. void loop() { (!client.connected()) { reconnect(); client.loop(); // if the button pressed, publish the temperature to topic "SF/TEMP"...
Page 192
COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Jumper Wires WS2812 RGB 8 LEDs Strip How to do? 1. Build the circuit. 2. Then, connect ESP32-WROOM-32E to the computer using the USB cable. Chapter 1. For Arduino User...
Page 193
• Open the iot_5_cheerlights.ino file located in the esp32-starter-kit-main\c\codes\ iot_5_cheerlights directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
Page 194
"sunfounder-client-sdgvsasdda"; 6. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button. 7. At this point, you can see that your RGB strip is displaying a certain color. Place it on your desk and you will notice that it periodically changes colors.
SunFounder ESP32 Starter Kit 1.49 8.6 Temperature and Humidity Monitoring with Adafruit IO In this project, we will guide you on how to use a popular IoT platform. There are many free (or low-cost) platforms available online for programming enthusiasts. Some examples are Adafruit IO, Blynk, Arduino Cloud, ThingSpeak, and so on.
Page 196
SunFounder ESP32 Starter Kit You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor DHT11 Humiture Sensor Setting up the Dashboard 1. Visit , then click on Start for free to create a free account.
Page 197
SunFounder ESP32 Starter Kit 3. After creating an Adafruit account, you’ll need to reopen Adafruit io. Click on the Dashboards, then click on New Dashboard. 1.49. 8.6 Temperature and Humidity Monitoring with Adafruit IO...
Page 198
SunFounder ESP32 Starter Kit 4. Create a New Dashboard. 5. Enter the newly created Dashboard and create a new block. Chapter 1. For Arduino User...
Page 199
SunFounder ESP32 Starter Kit 6. Create 1 Toggle block. 7. Next, you’ll need to create a new feed here. This toggle will be used to control the LED, and we’ll name this feed “LED”. 1.49. 8.6 Temperature and Humidity Monitoring with Adafruit IO...
Page 200
SunFounder ESP32 Starter Kit 8. Check the LED feed, then move to the next step. 9. Complete the block settings (mainly Block Title, On Text, and Off Text), then click on the Create block button at the bottom right to finish.
Page 201
SunFounder ESP32 Starter Kit 10. We also need to create two Text Blocks next. They will be used to display temperature and humidity. So, create two feeds named temperature and humidity. 11. After creation, your Dashboard should look something like this:...
Page 202
SunFounder ESP32 Starter Kit 12. You can adjust the layout by using the Edit Layout option on the Dashboard. 13. Click on API KEY, and you will see your username and API KEY displayed. Note these down as you’ll need them for your code.
Page 203
SunFounder ESP32 Starter Kit Running the Code 1. Build the circuit. 1.49. 8.6 Temperature and Humidity Monitoring with Adafruit IO...
Page 204
SunFounder ESP32 Starter Kit 2. Then, connect ESP32-WROOM-32E to the computer using the USB cable. Chapter 1. For Arduino User...
Page 205
• Open the iot_6_adafruit_io.ino file located in the esp32-starter-kit-main\c\codes\ iot_6_adafruit_io directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
LED toggle switch to control the on/off state of the external LED connected to the circuit. 1.50 8.7 ESP Camera with Telegram Bot In this project, we’ll demonstrate how to integrate the ESP32 with your favorite messaging application. For this demon- stration, we’re using Telegram.
Page 207
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor PIR Motion Sensor Module Creating a Telegram Bot 1. Head to Google Play or the App Store and download and install Telegram.
Page 208
SunFounder ESP32 Starter Kit 4. Enter /newbot and follow the provided instructions to create your bot. Once successful, the BotFather will provide you with the access link and API for your new bot. Chapter 1. For Arduino User...
Page 209
SunFounder ESP32 Starter Kit Authorizing Telegram Users As anyone can interact with the bot you’ve created, there’s a risk of information leakage. To address this, we want the bot to only respond to authorized users. 1. In your Telegram account, search for IDBot or open the link: t.me/myidbot.
Page 210
SunFounder ESP32 Starter Kit 2. Send the command /getid. Save the provided ID for later use in our program. Upload the Code 1. First plug in the camera. 2. Build the circuit. Chapter 1. For Arduino User...
Page 211
• Open the iot_7_cam_telegram.ino file located in the esp32-starter-kit-main\c\ codes\iot_7_cam_telegram directory, or copy the code into the Arduino IDE. • After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button. • Always displaying “Unknown COMxx”? •...
Page 212
String BOTtoken "<BOTTOKEN>"; 7. After selecting the correct board (ESP32 Dev Module) and port, click the Upload button. 8. Open the Serial Monitor. If an IP address is printed, this indicates successful execution. Connecting to xxxx ESP32-CAM IP Address: 192.168.18.76 Init Done! 9.
1.51 8.8 Camera with Home Assistant This project will guide you in setting up a video stream web server for the ESP32 camera and integrating it with the popular home automation platform, Home Assistant. This integration will allow you to access the server from any device on your network.
Page 214
SunFounder ESP32 Starter Kit 3. Install ESPHome Addon. 4. Click START, then OPEN WEB UI. Chapter 1. For Arduino User...
Page 215
SunFounder ESP32 Starter Kit 5. Add new devices. 6. A prompt might appear. Click CONTINUE. 1.51. 8.8 Camera with Home Assistant...
Page 216
SunFounder ESP32 Starter Kit 7. Create a configuration. Here, you can enter any desired name for Name. For WiFi, enter details of the network on which your Home Assistant system is present. Chapter 1. For Arduino User...
Page 217
SunFounder ESP32 Starter Kit 8. Select the ESP32 as the device type. 1.51. 8.8 Camera with Home Assistant...
Page 218
SunFounder ESP32 Starter Kit 9. When you see a fireworks celebration icon, it means you’ve successfully created the device. Click skip (DO NOT click INSTALL). Chapter 1. For Arduino User...
Page 219
SunFounder ESP32 Starter Kit At this point, you’ve only added the device in ESPHome. To integrate the ESP32 module into Home Assistant, additional configurations are needed: 10. Click EDIT. 11. After entering the .yaml interface, modify the ssid and password with your WiFi details.
Page 220
SunFounder ESP32 Starter Kit 12. Under the captive_portal section, paste the following code: # Example configuration entry esp32_camera: external_clock: pin: GPIO0 frequency: 20MHz i2c_pins: sda: GPIO26 scl: GPIO27 data_pins: [GPIO5, GPIO18, GPIO19, GPIO21, GPIO36, GPIO39, GPIO34,␣ GPIO35] vsync_pin: GPIO25 href_pin: GPIO23...
Page 221
SunFounder ESP32 Starter Kit (continued from previous page) # ... Note: For more details on the .yaml configuration for ESP32, you can refer to ESP32 Camera - ESPHome. 13. Save, then click INSTALL. 14. Choose the USB port method for installation.
Page 222
15. Wait for the INFO Successfully compiled program. message, indicating firmware compilation is com- plete. Note: At this point, you should see the node as ONLINE. If not, ensure your ESP32 is on the same network segment or try rebooting the device.
Page 223
SunFounder ESP32 Starter Kit 2. Now you should see the esphome tab. Click CONFIGURE. 3. Click SUBMIT. 4. Wait for the Success message. 1.51. 8.8 Camera with Home Assistant...
Page 224
SunFounder ESP32 Starter Kit 5. In Overview, click the top-right menu and select Edit Dashboard. 6. Click ADD CARD. Chapter 1. For Arduino User...
Page 225
SunFounder ESP32 Starter Kit 7. Choose Picture entity. 8. In the entity field, select the ESP32 you just added. Then save. 1.51. 8.8 Camera with Home Assistant...
Page 226
SunFounder ESP32 Starter Kit 9. Lastly, click DONE to exit the EDIT interface. Now, you can view your camera feed on Home Assistant. Chapter 1. For Arduino User...
SunFounder ESP32 Starter Kit 1.52 8.9 Blynk-based Intrusion Notification System This project demonstrate a simple home intrusion detection system using a PIR motion sensor (HC-SR501). When the system is set to “Away” mode through the Blynk app, the PIR sensor monitors for motion. Any detected movement triggers a notification on the Blynk app, alerting the user of potential intrusion.
Page 228
SunFounder ESP32 Starter Kit 1.52.1 1. Circuit Assembly 1.52.2 2. Blynk Configuration 2.1 Initializing Blynk 1. Navigate to the and select START FREE. Chapter 1. For Arduino User...
Page 229
SunFounder ESP32 Starter Kit 2. Enter your email to initiate the registration process. 3. Confirm your registration through your email. 1.52. 8.9 Blynk-based Intrusion Notification System...
Page 230
SunFounder ESP32 Starter Kit 4. After confirmation, Blynk Tour will appear. It is recommended to select “Skip”. If Quick Start also appears, consider skipping it as well. 2.2 Template Creation 1. First, create a template in Blynk. Follow the subsequent instructions to create the Intrusion Alert System template.
Page 231
SunFounder ESP32 Starter Kit 2. Assign a name to the template, select ESP32 Hardware, and select Connection Type as WiFi, then select Done. 2.3 Datastream Generation Open the template you just set up, let’s create two datastreams. 1. Click New Datastream.
Page 232
SunFounder ESP32 Starter Kit 2. In the popup, choose Virtual Pin. 3. Name the Virtual Pin V0 as AwayMode. Set the DATA TYPE as Integer with MIN and MAX values as 0 and Chapter 1. For Arduino User...
Page 233
SunFounder ESP32 Starter Kit 4. Similarly, create another Virtual Pin datastream. Name it Current Status and set the DATA TYPE to String. 2.4 Setting Up an Event Next, we’ll set up an event that sends an email notification if an intrusion is detected.
Page 234
SunFounder ESP32 Starter Kit 1. Click Add New Event. 2. Define the event’s name and its specific code. For TYPE, choose Warning and write a short description for the email to be sent when the event happens. You can also adjust how often you get notified.
Page 235
SunFounder ESP32 Starter Kit 3. Go to the Notifications section to turn on notifications and set up email details. 2.5 Fine-Tuning the Web Dashboard Making sure the Web Dashboard interacts perfectly with the Intrusion Alert System is vital. 1. Simply drag and place both the Switch widget and the Label widget onto the Web Dashboard.
Page 236
SunFounder ESP32 Starter Kit 2. When you hover over a widget, three icons will appear. Use the settings icon to adjust the widget’s properties. 3. In the Switch widget settings, select Datastream as AwayMode(V0). Set ONLABEL and OFFLABEL to display “away” and “home”, respectively.
Page 237
SunFounder ESP32 Starter Kit 4. In the Label widget settings, select Datastream as Current Status(V1). 2.6 Saving the Template Lastly, don’t forget to save your template. 1.52. 8.9 Blynk-based Intrusion Notification System...
Page 238
SunFounder ESP32 Starter Kit 2.7 Making a Device 1. It’s time to create a new device. 2. Click on From template to start with a new setup. Chapter 1. For Arduino User...
Page 239
3. Then, pick the Intrusion Alert System template and click on Create. 4. Here, you’ll see the Template ID, Device Name, and AuthToken. You need to copy these into your code so the ESP32 can work with Blynk. 1.52. 8.9 Blynk-based Intrusion Notification System...
Page 240
1. Before running the code, make sure to install the Blynk library from the Library Manager on the Arduino IDE. 2. Open the iot_9_intrusion_alert_system.ino file, which is located in the esp32-starter-kit-main\ c\codes\iot_9_intrusion_alert_system directory. You can also copy its content into the Arduino IDE.
Page 241
SunFounder ESP32 Starter Kit 5. Choose the correct board (ESP32 Dev Module) and port, then click the Upload button. 6. Open the Serial monitor (set baud rate to 115200) and wait for a successful connection message. 7. After a successful connection, activating the switch in Blynk will start the PIR module’s surveillance. When motion is detected (state of 1), it will say, “Somebody here!”...
Page 242
SunFounder ESP32 Starter Kit 1.52.4 4. Code explanation 1. Configuration & Libraries Here, you set up the Blynk constants and credentials. You also include the necessary libraries for the ESP32 and Blynk. /* Comment this out to disable prints and save space */ #define BLYNK_PRINT Serial #define BLYNK_TEMPLATE_ID "xxxxxxxxxxx"...
Page 243
SunFounder ESP32 Starter Kit The loop function continuously runs Blynk and the Blynk timer functions. void loop() { Blynk.run(); timer.run(); 6. Blynk App Interaction These functions are called when the device connects to Blynk and when there’s a change in the state of the virtual pin V0 on the Blynk app.
SunFounder ESP32 Starter Kit (continued from previous page) Reference • • • • • • • 1.53 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth The objective of this project is to develop an Android application capable of manipulating the hue of an RGB LED through a smartphone using Bluetooth technology.
Page 245
2. After logging in, navigate to Projects -> Import project (.aia) from my computer. Subse- quently, upload the control_rgb_led.aia file located in the path esp32-starter-kit-main\c\codes\ iot_10_bluetooth_app_inventor. 3. Upon uploading the .aia file, you will see the application on the MIT App Inventor software. This is a pre- configured template.
Page 246
SunFounder ESP32 Starter Kit 4. In MIT App Inventor, you have 2 primary sections: the Designer and the Blocks. 5. The Designer allows you to add buttons, text, screens, and modify the overall aesthetic of your application. Chapter 1. For Arduino User...
Page 247
SunFounder ESP32 Starter Kit 6. Subsequently, you have the Blocks section. The Blocks section facilitates the creation of bespoke functions for your application. 1.53. 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth...
Page 248
SunFounder ESP32 Starter Kit 7. To install the application on a smartphone, navigate to the Build tab. • You can generate a .apk file. After selecting this option, a page will appear allowing you to choose between downloading a .apk file or scanning a QR code for installation. Follow the installation guide to complete the application installation.
Page 249
Red; and the two pins on the right symbolize Green and Blue. 2. Subsequently, connect the ESP32-WROOM-32E to your computer using a USB cable. 1.53. 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth...
Page 250
3. Open the iot_10_bluetooth_app_inventor.ino file situated in the esp32-starter-kit-main\c\ codes\iot_10_bluetooth_app_inventor directory, or copy the code into the Arduino IDE. 4. Upon selecting the appropriate board (ESP32 Dev Module) and port, click the Upload button. 3. App and ESP32 Connection Ensure that the application created earlier is installed on your smartphone.
Page 251
SunFounder ESP32 Starter Kit 2. Navigate to the Bluetooth settings on your smartphone and find ESP32RGB. 1.53. 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth...
Page 252
SunFounder ESP32 Starter Kit 3. After clicking it, agree to the Pair request in the pop-up window. Chapter 1. For Arduino User...
Page 253
SunFounder ESP32 Starter Kit 4. Now open the recently installed Control_RGB_LED APP. 5. In the APP, click on Connect Bluetooth to establish a connection between the APP and ESP32. 1.53. 8.10 Android Application - RGB LED Operation via Arduino and Bluetooth...
Page 254
SunFounder ESP32 Starter Kit 6. Select the xx.xx.xx.xx.xx.xx ESP32RGB that comes up. if you changed SerialBT.begin("ESP32RGB"); in the code, then just select the name of your setting. Chapter 1. For Arduino User...
Page 255
SunFounder ESP32 Starter Kit 7. If you have been waiting for a while and still can’t see any device names, it may be that this APP is not allowed to scan surrounding devices. In this case, you need to adjust the settings manually.
Page 256
SunFounder ESP32 Starter Kit • Locate Nearby devices, and select Always to allow this APP to scan for nearby devices. Chapter 1. For Arduino User...
Page 257
SunFounder ESP32 Starter Kit • Now, restart the APP and repeat steps 5 and 6 to successfully connect to Bluetooth. 8. Upon successful connection, you will automatically return to the main page, where it will display connected. Now you can adjust the RGB values and change the color of the RGB display by pressing the Change Color button.
Embark on a journey through the Arduino world with the comprehensive Arduino Video Course, using SunFounder’s ESP32 Starter Kit. This series begins with an introduction to the Arduino ecosystem and the capabilities of the ESP32 board, setting the stage for a deep dive into practical applications and programming techniques. You’ll learn the basics of controlling LEDs, understanding serial communication, and manipulating various components like RGB LEDs, buttons, and shift registers.
• Arduino Code: An in-depth explanation of the Arduino code used in the project, highlighting key elements and the upload process to the ESP32. • Testing: Practical instructions on how to test the LED blink demonstration, ensuring that the project works as intended.
• Code Explanation: Describes the Arduino code for fading an LED. Covers functions like ledcSetup, ledcAttachPin, and ledcWrite, explaining parameters and usage. • Practical Demonstration: Shows how to upload the code to ESP32, check the wiring, and observe the LED fading effect. Tips for adjusting fade speed and brightness levels.
Video 2.8 Video 8: Walking Light with 74HC595 Shift Register This tutorial is designed for learners to understand how to use a shift register with the ESP32 for controlling multiple LEDs, creating a dynamic lighting effect. • Introduction: Uses ESP32 microcontroller and 74HC595 shift register.
2.9 Video 9: Toggle LED with Push Button This tutorial is aimed at beginners, providing a practical guide to using a push button to control an LED with the ESP32. • Project Focus: Teaches how to read a push button’s state and toggle an LED on and off.
2.6 Display Characters 2.12 Video 12: Using WS2812 RGB Strip This tutorial is perfect to learn how to utilize the WS2812 LED strip with ESP32 for creating various colors and controlling individual LEDs: • WS2812 LED Strip Introduction: A flexible strip with adhesive back, 5050 LEDs, and individual control capabilities.
2.14 Video 14: Playing Custom Music Note In this tutorial, you’ll learn how to use the SunFounder ESP32 IoT Learning Kit to play custom musical notes: • Passive Buzzer Introduction: Unlike the previous tutorial with an active buzzer, this one uses a passive buzzer which requires an external signal for sound generation.
• Water Pump Basics: Understand the functionality of a 5V DC water pump included in the SunFounder kit. • Using L293D with ESP32: Learn how L293D motor driver helps in interfacing the water pump with ESP32. • Project Setup: Step-by-step guidance on connecting the water pump to ESP32 using L293D.
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.
While Python has the same advantages, for some Microcontroller boards like the ESP32, they are small, simple and have little memory to run the Python language at all. That’s why MicroPython has evolved, keeping the main Python features and adding a bunch of new ones to work with these Microcontroller boards.
Page 269
SunFounder ESP32 Starter Kit 3. Next, click Next and Install to finish installing Thonny. 3.2. 1.2 Install Thonny IDE...
3.3 1.3 Install MicroPython on the ESP32(Important) 1. Download the from the MicroPython official website and then download the latest version of the firmware. 2. Connect the ESP32 WROOM 32E to your computer using a Micro USB cable. Chapter 3. For MicroPython User...
Page 271
SunFounder ESP32 Starter Kit 3. Click on the bottom right corner of Thonny IDE, select “MicroPython(ESP32).COMXX” from the pop-up menu, and then select “Configure interpreter”. 4. Click “Install or Update MicroPython” in the new pop-up window. 3.3. 1.3 Install MicroPython on the ESP32(Important)
Page 272
SunFounder ESP32 Starter Kit 5. Select the correct port and the firmware you downloaded earlier, and click “Install”. Chapter 3. For MicroPython User...
Page 273
SunFounder ESP32 Starter Kit 6. After a successful installation, you can close this page. 7. When you return to the Thonny homepage, you will see MicroPython version and ESP32-related prompts, instead 3.3. 1.3 Install MicroPython on the ESP32(Important)
3.4 1.4 Upload the Libraries (Important) In some projects, you will need additional libraries. So here we upload these libraries to ESP32 first, and then we can run the code directly later. 1. Download the relevant code from the link below.
Page 275
SunFounder ESP32 Starter Kit 3. Open Thonny IDE and click on the “MicroPython (ESP32).COMXX” interpreter in the bottom right corner. 4. In the top navigation bar, click View -> Files. 5. Switch the path to the folder where you downloaded the...
Page 276
SunFounder ESP32 Starter Kit 6. Select all the files or folders in the libs/ folder, right-click and click Upload to, it will take a while to upload. 7. Now you will see the files you just uploaded inside your drive MicroPython device.
The code section in the projects tells you exactly which code is used, so double-click on the .py file with the serial number in the esp32-starter-kit-main\micropython\codes\ path to open it. However, you must first download the package and upload the libraries, as described in 1.4 Upload the Libraries...
Page 278
SunFounder ESP32 Starter Kit 2. Plug the esp32 into your computer with a micro USB cable. 3. Select correct interpreter Select the “MicroPython (ESP32).COMxx” interpreter. Chapter 3. For MicroPython User...
Page 279
If the code contains any information that needs to be printed, it will appear in the Shell; otherwise, only the following information will appear. Click View -> Edit to open the Shell window if it doesn’t appear on your Thonny. MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32 Type "help()" for more information. >>> %Run -c $EDITOR_CONTENT •...
Page 280
You can save changes made to the open example by pressing Ctrl+S or clicking the Save button on Thonny. The code can be saved as a separate file within the MicroPython drive(ESP32) by clicking on File -> Save As. Select MicroPython drive.
Page 281
SunFounder ESP32 Starter Kit Then click OK after entering the file name and extension .py. On the MicroPython drive, you will see your saved file. Note: Regardless of what name you give your code, it’s best to describe what type of code it is, and not give it a meaningless name like abc.py.
Page 282
SunFounder ESP32 Starter Kit 2. Copy code Copy the code from the project to the Thonny IDE. 3. Plug the esp32 into your computer with a micro USB cable. Chapter 3. For MicroPython User...
Page 283
SunFounder ESP32 Starter Kit 4. Select correct interpreter Select the “MicroPython (ESP32).COMxx” interpreter in the bottom right corner. 5. Run the code You need click Run Current Script or simply press F5 to run it. 3.5. 1.5 Quick Guide on Thonny...
Page 284
If the code contains any information that needs to be printed, it will appear in the Shell; otherwise, only the following information will appear. Click View -> Edit to open the Shell window if it doesn’t appear on your Thonny. MicroPython v1.19.1 on 2022-06-18; ESP32 module with ESP32 Type "help()" for more information. >>> %Run -c $EDITOR_CONTENT •...
Page 285
SunFounder ESP32 Starter Kit Then click OK or Save after entering the file name and extension .py. Note: Regardless of what name you give your code, it’s best to describe what type of code it is, and not give it a meaningless name like abc.py. When you save the code as main.py, it will run automatically when the power is turned on.
SunFounder ESP32 Starter Kit 3.6 1.6 (Optional) MicroPython Basic Syntax 3.6.1 Indentation Indentation refers to the spaces at the beginning of a code line. Like standard Python programs, MicroPython programs usually run from top to bottom: It traverses each line in turn, runs it in the interpreter, and then continues to the next line, Just like you type them line by line in the Shell.
Page 287
SunFounder ESP32 Starter Kit #print("Can't run it") print("hello world") #This is a annotationhello world >>> %Run -c $EDITOR_CONTENT hello world Multi-line comment If you want to comment on multiple lines, you can use multiple # signs. #This is a comment...
Page 288
SunFounder ESP32 Starter Kit >>> %Run -c $EDITOR_CONTENT ( pear , apple , grape ) Print two messages and specify the separator: print("Hello", "how are you?", sep="---") >>> %Run -c $EDITOR_CONTENT Hello---how are you? 3.6.4 Variables Variables are containers used to store data values.
Page 289
SunFounder ESP32 Starter Kit Get the Type You can get the data type of a variable with the type() function. "hello" print(type(x),type(y),type(z)) >>> %Run -c $EDITOR_CONTENT <class int > <class str > <class float > Single or Double Quotes? In MicroPython, single quotes or double quotes can be used to define string variables.
Page 290
SunFounder ESP32 Starter Kit Example > print(num, "is a positive number.") print("End with this line") >>> %Run -c $EDITOR_CONTENT 8 is a positive number. End with this line if. . . else test expression: Body of else: Body of else The if..else statement evaluates test expression and will execute the body of if only when the test condition is True.
Page 291
SunFounder ESP32 Starter Kit Example > print(num, "is a positive number.") else: print(num, "is a negative number.") >>> %Run -c $EDITOR_CONTENT -8 is a negative number. if. . . elif. . . else test expression: Body of elif test expression:...
Page 292
SunFounder ESP32 Starter Kit if. . . elif. . . else Statement Flowchart Example > print("x is greater than y") elif print("x and y are equal") else: print("x is greater than y") >>> %Run -c $EDITOR_CONTENT x is greater than y...
Page 293
SunFounder ESP32 Starter Kit Nested if We can embed an if statement into another if statement, and then call it a nested if statement. Example > print("Above ten,") > print("and also above 20!") else: print("but not above 20.") >>> %Run -c $EDITOR_CONTENT...
Page 294
SunFounder ESP32 Starter Kit while > print(x) >>> %Run -c $EDITOR_CONTENT Break Statement With the break statement we can stop the loop even if the while condition is true: while > print(x) (continues on next page) Chapter 3. For MicroPython User...
Page 295
SunFounder ESP32 Starter Kit (continued from previous page) break >>> %Run -c $EDITOR_CONTENT While Loop with Else Like the if loop, the while loop can also have an optional else block. If the condition in the while loop is evaluated as False, the else part is executed.
Page 296
SunFounder ESP32 Starter Kit numbers [1, 2, 3, 4] numbers: sum+val print("The sum is", sum) >>> %Run -c $EDITOR_CONTENT The sum is 10 The break Statement With the break statement we can stop the loop before it has looped through all the items:...
Page 297
SunFounder ESP32 Starter Kit The continue Statement With the continue statement we can stop the current iteration of the loop, and continue with the next: numbers [1, 2, 3, 4] numbers: continue print(val) >>> %Run -c $EDITOR_CONTENT The range() function We can use the range() function to generate a sequence of numbers.
Page 298
SunFounder ESP32 Starter Kit >>> %Run -c $EDITOR_CONTENT I like pear I like apple I like grape Else in For Loop The for loop can also have an optional else block. If the items in the sequence used for the loop are exhausted, the else part is executed.
Page 299
SunFounder ESP32 Starter Kit Create a Function def function_nameparameters) """docstring""" statement(s) • A function is defined using the def keyword • A function name to uniquely identify the function. Function naming is the same as variable naming, and both follow the following rules.
Page 300
SunFounder ESP32 Starter Kit my_function(): print("Your first function") print(my_function()) >>> %Run -c $EDITOR_CONTENT Your first function None Here, None is the return value, because the return statement is not used. Arguments Information can be passed to the function as arguments.
Page 301
SunFounder ESP32 Starter Kit (continued from previous page) File "<stdin>", line 6, in <module> TypeError: function takes 2 positional arguments but 1 were given welcome()No arguments >>> %Run -c $EDITOR_CONTENT Traceback (most recent call last): File "<stdin>", line 6, in <module>...
Page 302
SunFounder ESP32 Starter Kit Keyword Arguments When we call a function with certain values, these values will be assigned to arguments based on their position. For example, in the above function welcome(), when we called it as welcome(“Lily”, “Welcome to China”), the value “Lily”...
Page 303
SunFounder ESP32 Starter Kit Here, we have called the function with multiple arguments. These arguments are packed into a tuple before being passed into the function. Inside the function, we use a for loop to retrieve all the arguments. Recursion In Python, we know that a function can call other functions.
Page 304
SunFounder ESP32 Starter Kit 3.6.9 Data Types Built-in Data Types MicroPython has the following data types: • Text Type: str • Numeric Types: int, float, complex • Sequence Types: list, tuple, range • Mapping Type: dict • Set Types: set, frozenset •...
Page 305
SunFounder ESP32 Starter Kit Setting the Specific Data Type If you want to specify the data type, you can use the following constructor functions: Example Date Type x = int(20) x = float(20.5) float x = complex(1j) complex x = str(“Hello World”) x = list((“apple”, “banana”, “cherry”))
Page 306
SunFounder ESP32 Starter Kit (continued from previous page) print(a) print(b) print(c) Note: You cannot convert complex numbers into another number type. 3.6.10 Operators Operators are used to perform operations on variables and values. • Arithmetic Operators • Assignment operators •...
Page 307
SunFounder ESP32 Starter Kit (continued from previous page) print(f) print(g) >>> %Run -c $EDITOR_CONTENT 1.66667 >>> Assignment operators Assignment operators can used to assign values to variables. Operator Example Same As a = 6 a =6 a += 6 a = a + 6...
Page 308
SunFounder ESP32 Starter Kit Comparison Operators Comparison operators are used to compare two values. Operator Name Equal Not equal < Less than > Greater than >= Greater than or equal to <= Less than or equal to print(a>b) >>> %Run test.py False >>>...
Page 309
SunFounder ESP32 Starter Kit ["hello", "welcome"] ["hello", "welcome"] print(a # returns True because z is the same object as x print(a # returns False because x is not the same object as y, even if they have the same content...
Page 310
SunFounder ESP32 Starter Kit print(num & print(num print(num << >>> %Run -c $EDITOR_CONTENT >>> 3.6.11 Lists Lists are used to store multiple items in a single variable, and are created using square brackets: B_list ["Blossom", "Bubbles","Buttercup"] print(B_list) List items are changeable, ordered, and allow duplicate values. The list items are indexed, with the first item having index [0], the second item having index [1], and so on.
Page 311
SunFounder ESP32 Starter Kit List Length To determine how many items are in the list, use the len() function. ["Banana", 255, False, 3.14] A_list print(len(A_list)) >>> %Run -c $EDITOR_CONTENT Check List items Print the second item of the list: ["Banana", 255, False, 3.14]...
Page 312
SunFounder ESP32 Starter Kit A_list ["Banana", 255, False, 3.14] A_list[1:2] [True,"Orange"] print(A_list) >>> %Run -c $EDITOR_CONTENT [ Banana , True, Orange , False, 3.14] Add List Items Using the append() method to add an item: C_list ["Red", "Blue", "Green"] C_list.append("Orange") print(C_list) >>>...
SunFounder ESP32 Starter Kit (continued from previous page) Orange [ Banana , False, 3.14, True] The del keyword also removes the specified index: C_list ["Red", "Blue", "Green"] C_list[1] print(C_list) >>> %Run -c $EDITOR_CONTENT [ Red , Green ] The clear() method empties the list. The list still remains, but it has no content.
Page 314
SunFounder ESP32 Starter Kit Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic This circuit works on a simple principle, and the current direction is shown in the figure.
Page 315
# Wait for 0.5 seconds (500 milliseconds) while the LED is off time.sleep(0.5) 2. Connect the ESP32 WROOM 32E to your computer using a Micro USB cable. 3. Then click on the “MicroPython (ESP32).COMXX” interpreter in the bottom right corner.
Page 316
SunFounder ESP32 Starter Kit 4. Finally, click “Run Current Script” or press F5 to execute it. 5. After the code runs, you will see the LED blinking. How it works? 1. It imports two modules, machine and time. The machine module provides low-level access to the microcon- troller’s hardware, while the time module provides functions for time-related operations.
LED gradually brightening and dimming, simulating a breathing effect. By using the PWM capabilities of the ESP32 WROOM 32E, we can achieve smooth and precise control over the LED’s brightness. This breathing effect adds a dynamic and visually appealing element to your projects, creating an eye-catching display or ambiance.
Page 318
Breadboard Jumper Wires Resistor Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 319
• Open the 2.2_fading_led.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. # Import the necessary libraries...
Page 320
SunFounder ESP32 Starter Kit (continued from previous page) duty_cycle range(1023, -1, -1): led.duty(duty_cycle) time.sleep(0.01) The LED will gradually become brighter as the code runs. How it works? Overall, this code demonstrates how to use PWM signals to control the brightness of an LED.
Jumper Wires Resistor RGB LED Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic 3.9.
Page 322
SunFounder ESP32 Starter Kit The PWM pins pin27, pin26 and pin25 control the Red, Green and Blue pins of the RGB LED respectively, and connect the common cathode pin to GND. This allows the RGB LED to display a specific color by superimposing light on these pins with different PWM values.
Page 323
• Open the 2.3_colorful_light.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. from...
Page 324
• Open the 2.3_colorful_light_rgb.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 • Make sure to select the “MicroPython (ESP32).COMxx” interpreter in the bottom right corner. from...
Page 325
SunFounder ESP32 Starter Kit (continued from previous page) # Map input values from one range to another interval_mapping(x, in_min, in_max, out_min, out_max): return in_min) (out_max out_min) (in_max in_min) out_min # Convert color values (0-255) to duty cycle values (0-1023) color_to_duty(rgb_value):...
Jumper Wires Resistor 74HC595 Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic Chapter 3.
Page 327
SunFounder ESP32 Starter Kit • When MR (pin10) is high level and CE (pin13) is low level, data is input in the rising edge of SHcp and goes to the memory register through the rising edge of SHcp. • If the two clocks are connected together, the shift register is always one pulse earlier than the memory register.
Page 328
• Open the 2.4_microchip_74hc595.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. import...
Page 329
SunFounder ESP32 Starter Kit (continued from previous page) rclk machine.Pin(27, machine.Pin.OUT) # STcp srclk machine.Pin(26, machine.Pin.OUT) # SHcp # Define the hc595_shift function to shift data into the 74HC595 shift register hc595_shift(dat): # Set the RCLK pin to low rclk.off()
Page 330
SunFounder ESP32 Starter Kit # Initialize the pins for the 74HC595 shift register machine.Pin(25, machine.Pin.OUT) # DS rclk machine.Pin(27, machine.Pin.OUT) # STcp srclk machine.Pin(26, machine.Pin.OUT) # SHcp 3. A function called hc595_shift() is defined to write an 8-bit data to the shift register.
Resistor 7-segment Display 74HC595 Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 332
SunFounder ESP32 Starter Kit Schematic Here the wiring principle is basically the same as 74HC595, the only difference is that Q0-Q7 are 2.4 Microchip - connected to the a ~ g pins of the 7 Segment Display. Table 1: Wiring...
Page 333
• Open the 2.5_number_display.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. import...
Page 334
SunFounder ESP32 Starter Kit (continued from previous page) rclk.off() # Iterate through each bit (from 7 to 0) range(7, -1, -1): # Extract the current bit from the input data value & (dat >> bit) # Set the SRCLK pin to low srclk.off()
SunFounder ESP32 Starter Kit • Hexadecimal • BinaryHex Converter The following table shows the hexadecimal patterns that need to be written to the shift register to display the numbers 0 to 9 on a 7-segment display. Table 2: Glyph Code...
Page 336
COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Jumper Wires I2C LCD1602 Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins Usage Description IO21 IO22 Schematic Wiring Chapter 3. For MicroPython User...
Page 337
Thonny. Then, click “Run Current Script” or press F5 to execute • Make sure to select the “MicroPython (ESP32).COMxx” interpreter in the bottom right corner. • The lcd1602.py library is used here and check if it’s uploaded to ESP32. Refer to 1.4 Upload the Libraries for a tutorial.
SunFounder ESP32 Starter Kit 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. How it works? In the lcd1602 library, we integrate the relevant functions of lcd1602 into the LCD class.
Page 339
WS2812 RGB 8 LEDs Strip Schematic Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Note: IO33 is not available for this project.
Page 340
• Open the 2.7_rgb_strip.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. from...
Page 341
• Open the 2.7_rgb_strip_random.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. from...
You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Buzzer Transistor Available Pins Here is a list of available pins on the ESP32 board for this project. Chapter 3. For MicroPython User...
Page 343
SunFounder ESP32 Starter Kit Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic When the IO14 output is high, after the 1K current limiting resistor (to protect the transistor), the S8050 (NPN transistor) will conduct, so that the buzzer will sound.
Page 344
• Open the 3.1_beep.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. Chapter 3. For MicroPython User...
SunFounder ESP32 Starter Kit import machine import time # Create a Pin object representing pin 14 and set it to output mode buzzer machine.Pin(14, machine.Pin.OUT) # Enter an infinite loop while True: # Iterate over the values 0 to 3 using a for loop...
Page 346
Resistor Buzzer Transistor Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic When the IO14 output is high, after the 1K current limiting resistor (to protect the transistor), the S8050 (NPN transistor) Chapter 3.
Page 347
SunFounder ESP32 Starter Kit will conduct, so that the buzzer will sound. The role of S8050 (NPN transistor) is to amplify the current and make the buzzer sound louder. In fact, you can also connect the buzzer directly to IO14, but you will find that the buzzer sound is smaller.
Page 348
• Open the 3.2_custom_tone.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. import...
Page 349
• Open the 3.2_custom_tone_music.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. import...
SunFounder ESP32 Starter Kit (continued from previous page) (G5, half_note), (G5, quarter_note), (F5, quarter_note), (E5, quarter_note), (D5, half_note), (C5, quarter_note), (C5, quarter_note), (D5, quarter_note), (E5, half_note), (D5, quarter_note), (C5, quarter_note), (C5, half_note), # Define a function to play a note with the given frequency and duration tone(pin,frequency,duration): pin.freq(frequency)
Page 351
Jumper Wires DC Motor L293D Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 Schematic 3.16.
Page 352
SunFounder ESP32 Starter Kit Wiring Note: Since the motor requires a relatively high current, it is necessary to first insert the battery and then slide the switch on the expansion board to the ON position to activate the battery supply.
Page 353
• Open the 4.1_motor_turn.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. import...
Page 354
• Open the 4.1_motor_turn_pwm.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. from...
SunFounder ESP32 Starter Kit (continued from previous page) power range(1023, 0, -20): motor1A.duty(power) motor2A.duty(0) time.sleep(0.1) # Rotate the motor in the opposite direction by gradually increasing the power on␣ the motor2A pin power range(0, 1023, 20): motor1A.duty(0) motor2A.duty(power) time.sleep(0.1) # Decreasing the power on the motor2A pin...
Page 356
Jumper Wires Centrifugal Pump L293D Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 357
• Open the 4.2_pumping.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. import...
You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Jumper Wires Servo Available Pins Here is a list of available pins on the ESP32 board for this project. Chapter 3. For MicroPython User...
Page 359
• Open the 4.3_swinging_servo.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.18. 4.3 Swinging Servo...
Page 360
SunFounder ESP32 Starter Kit import machine import time # Create a PWM (Pulse Width Modulation) object on Pin 25 servo machine.PWM(machine.Pin(25)) # Set the frequency of the PWM signal to 50 Hz, common for servos servo.freq(50) # Define a function for interval mapping...
SunFounder ESP32 Starter Kit interval_mapping(x, in_min, in_max, out_min, out_max): return in_min) (out_max out_min) (in_max in_min) out_min 4. Define a servo_write function that takes a PWM object and an angle as inputs. It calculates the pulse width and duty cycle based on the given angle, and then sets the PWM output accordingly.
Page 362
Resistor Button Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO14, IO25, I35, I34, I39, I36, IO18, IO19, IO21, IO22, IO23 For Output IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 •...
Page 363
SunFounder ESP32 Starter Kit Schematic To ensure proper functionality, connect one side of the button pin to 3.3V and the other side to IO14. When the button is pressed, IO14 will be set to high, causing the LED to light up. When the button is released, IO14 will return to its suspended state, which may be either high or low.
Page 364
• Open the 5.1_read_button_value.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. import...
You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Tilt Switch Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. 3.20. 5.2 Tilt It...
Page 367
SunFounder ESP32 Starter Kit When the tilt switch is in an upright position, IO14 will be set to high, resulting in the LED being lit. Conversely, when the tilt switch is tilted, IO14 will be set to low, causing the LED to turn off.
Page 368
• Open the 5.2_tilt_switch.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. import...
Obstacle Avoidance Module Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23 •...
Page 370
• Open the 5.3_avoid.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. import...
Line Tracking Module Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23 •...
Page 372
SunFounder ESP32 Starter Kit Generally, it is not recommended to use them as input pins. If you wish to use these pins, consider the potential impact on the booting process. For more details, please refer to the Strapping Pins section.
Page 373
• Open the 5.4_detect_the_line.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. import...
SunFounder ESP32 Starter Kit (continued from previous page) # Create a pin object named greyscale, set pin number 14 as input line machine.Pin(14, machine.Pin.IN) while True: # Check if the value is 1 (black) line.value() # Print "black" print("black") time.sleep(0.5)
Page 375
SunFounder ESP32 Starter Kit Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO13, IO14, IO27, IO26, IO25, IO33, I35, I34, I39, I36, IO4, IO18, IO19, IO21, IO22, IO23...
Page 376
SunFounder ESP32 Starter Kit When the PIR module detects motion, IO14 will go high, and the LED will be lit. Otherwise, when no motion is detected, IO14 will be low, and the LED will turn off. Note: The PIR module has two potentiometers: one adjusts sensitivity, the other adjusts detection distance. To make the PIR module work better, you need to turn both of them counterclockwise to the end.
Page 377
• Open the 5.5_detect_human_movement.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 • Make sure to select the “MicroPython (ESP32).COMxx” interpreter in the bottom right corner. import...
Page 378
SunFounder ESP32 Starter Kit (continued from previous page) # Function to handle the interrupt motion_detected(pin): global motion_detected_flag print("Motion detected!") motion_detected_flag True # Attach the interrupt to the PIR sensor pin pir_sensor.irq(trigger=machine.Pin.IRQ_RISING, handler=motion_detected) # Main loop while True: motion_detected_flag: led.value(1) # Turn on the LED time.sleep(5)
SunFounder ESP32 Starter Kit 2. Attach the interrupt to the PIR sensor pin, with the trigger set to “rising” (i.e., when the pin goes from low to high voltage): pir_sensor.irq(trigger=machine.Pin.IRQ_RISING, handler=motion_detected) This sets up an interrupt on the pir_sensor pin, which is connected to the PIR motion sensor.
Page 380
Button Transistor Available Pins • Available Pins Here is a list of available pins on the ESP32 board for this project. For Input IO14, IO25, I35, I34, I39, I36, IO18, IO19, IO21, IO22, IO23 For Output IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO32, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23 •...
Page 381
SunFounder ESP32 Starter Kit In this circuit, when the button is pressed, IO14 is high. By programming IO26 to output high, after a 1k current limiting resistor (to protect the transistor), the S8050 (NPN transistor) is allowed to conduct, thus allowing the LED to light up.
Page 382
SunFounder ESP32 Starter Kit Way to connect PNP(S8550) transistor Chapter 3. For MicroPython User...
Page 383
SunFounder ESP32 Starter Kit In this circuit, IO14 is low by the default and will change to high when the button is pressed. By programming IO26 to output low, after a 1k current limiting resistor (to protect the transistor), the S8550 (PNP transistor) is allowed to conduct, thus allowing the LED to light up.
Page 384
• Open the 5.6_transistor.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. import...
# turn the LED off Two types of transistors can be controlled using the same code. When we press the button, the ESP32 will send a high-level signal to the transistor; when we release it, it will send a low-level signal.
Page 386
SunFounder ESP32 Starter Kit • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 387
• Open the 5.7_feel_the_light.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. from...
SunFounder ESP32 Starter Kit After the program runs, the Shell prints out the photoresistor values. You can shine a flashlight on it or cover it up with your hand to see how the value will change. • atten(photoresistor.ATTN_11DB): Configure the ADC attenuation to 11dB for full range.
Page 389
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 390
• Open the 5.8_turn_the_knob.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. from...
SunFounder ESP32 Starter Kit (continued from previous page) # Scale the value to the range of 0-1023 for ESP32 PWM duty cycle pwm_value int(value 1023 4095) # Update the LED brightness based on the potentiometer value led.duty(pwm_value) # Read the voltage in microvolts and convert it to volts voltage pot.read_uv()
Page 392
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
• Open the 5.9_moisture.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. from...
Page 394
IO14, IO25, I35, I34, I39, I36 • Strapping Pins The following pins are strapping pins, which affect the startup process of the ESP32 during power on or reset. However, once the ESP32 is booted up successfully, they can be used as regular pins.
Page 395
• Open the 5.10_thermistor.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. # Import the necessary libraries...
Page 396
SunFounder ESP32 Starter Kit (continued from previous page) # Define the beta value of the thermistor, typically provided in the datasheet beta 3950 # Create an ADC object (thermistor) thermistor ADC(Pin(35, Pin.IN)) # Set the attenuation thermistor.atten(thermistor.ATTN_11DB) # Start an infinite loop to continuously monitor the temperature...
Page 397
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. • Here you need to use the library called lcd1602.py, please check if it has been uploaded to ESP32, for a detailed tutorial refer to 1.4 Upload the Libraries...
Page 398
SunFounder ESP32 Starter Kit (continued from previous page) import time import math # Define the beta value of the thermistor, typically provided in the datasheet beta 3950 # Create an ADC object (thermistor) thermistor ADC(Pin(35, Pin.IN)) # Set the attenuation thermistor.atten(thermistor.ATTN_11DB)
ESP32 Camera Extension Jumper Wires Joystick Module • Available Pins Here is a list of available pins on the ESP32 board for this project. For Analog Input IO14, IO25, I35, I34, I39, I36 For Digital Input IO13, IO14, IO27, IO26, IO25, IO33, IO4, IO18, IO19, IO21, IO22, IO23 •...
Page 400
• Open the 5.11_joystick.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. Chapter 3. For MicroPython User...
SunFounder ESP32 Starter Kit from machine import ADC,Pin import time xAxis ADC(Pin(34, Pin.IN)) # create an ADC object acting on a pin xAxis.atten(xAxis.ATTN_11DB) yAxis ADC(Pin(35, Pin.IN)) # create an ADC object acting on a pin yAxis.atten(yAxis.ATTN_11DB) button Pin(33, Pin.IN, Pin.PULL_UP)
Page 402
Schematic The ESP32 sends a set of square wave signals to the Trig pin of the ultrasonic sensor every 10 seconds. This prompts the ultrasonic sensor to emit a 40kHz ultrasound signal outward. If there is an obstacle in front, the ultrasound waves...
Page 403
• Open the 5.12_ultrasonic.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. import...
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()
Page 405
Jumper Wires DHT11 Humiture Sensor • Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO33, IO15, IO2, IO0, IO4, IO5, IO18, IO19, IO21, IO22, IO23...
Page 406
• Open the 5.13_dht11.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. import...
Page 407
• 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...
SunFounder ESP32 Starter Kit • Here you need to use the library called lcd1602.py, please check if it has been uploaded to ESP32, for a detailed tutorial refer to 1.4 Upload the Libraries (Important). import import machine import time from...
Page 409
ESP32 Camera Extension Breadboard Jumper Wires IR Receiver Available Pins Here is a list of available pins on the ESP32 board for this project. Available Pins IO13, IO12, IO14, IO27, IO26, IO25, IO15, IO0, IO5, IO18, IO19, IO21, IO22, IO23 Schematic...
Page 410
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. • Here, you need to utilize the libraries found in the ir_rx folder. Please ensure they have been uploaded to the ESP32.
Page 411
SunFounder ESP32 Starter Kit (continued from previous page) decodeKeyValue(data): data 0x16: return "0" data 0x0C: return "1" data 0x18: return "2" data 0x5E: return "3" data 0x08: return "4" data 0x1C: return "5" data 0x5A: return "6" data 0x42: return "7"...
Page 412
SunFounder ESP32 Starter Kit (continued from previous page) NEC_8(pin_ir, callback) # Instantiate the NEC_8 receiver # Show debug information ir.error_function(print_error) # keep the script running until interrupted by a keyboard interrupt (Ctrl+C) try: while True: pass except KeyboardInterrupt: ir.close() # Close the receiver When the program is running, press the key on the remote control, the value and name of the key will appear in the Shell.
Have you ever wanted to play the piano but couldn’t afford one? Or maybe you just want to have some fun with diy a fruit piano? Well, this project is for you! With just a few touch sensors on the ESP32 board, you can now play your favorite tunes and enjoy the experience of playing the piano without breaking the bank.
Page 414
About the Touch Pins The ESP32 microcontroller has built-in touch sensor functionality, which allows you to use certain pins on the board as touch-sensitive inputs. The touch sensor works by measuring changes in capacitance on the touch pins, which are caused by the electrical properties of the human body.
Page 415
The touch pins on the ESP32 have built-in ESD (Electrostatic Discharge) protection, which helps to prevent damage to the board from static electricity. • Multitouch The touch sensor on the ESP32 supports multitouch, which means that you can detect multiple touch events simultaneously. Schematic The idea behind this project is to use touch sensors to detect when a user touches a specific pin.
Page 416
• Open the 6.1_fruit_piano.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. from...
Page 417
You can connect fruits to these ESP32 pins: 4, 15, 13, 12, 14, 27, 33, 32. When the script runs, touching these fruits will play the notes C, D, E, F, G, A, B and C5. Note: Touch_threshold needs to be adjusted based on the conductivity of different fruits.
SunFounder ESP32 Starter Kit 3.34 6.2 Flowing Light Have you ever wanted to add some fun and interactive element to your living space? This project involves creating a running light using WS2812 LED strip and a obstacle avoidance module. The running light changes direction when an obstacle is detected, making it an exciting addition to your home or office decor.
Page 419
SunFounder ESP32 Starter Kit The WS2812 LED strip is composed of a series of individual LEDs that can be programmed to display different colors and patterns. In this project, the strip is set up to display a running light that moves in a particular direction and changes direction when an obstacle is detected by the obstacle avoidance module.
Page 420
• Open the 6.2_flowing_led.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. from...
The electric signals from the theremin are amplified and sent to a loudspeaker. We cannot reproduce the same instrument through ESP32, but we can use photoresistor and passive buzzer to achieve similar gameplay.
Page 422
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Photoresistor Buzzer Transistor Schematic Before starting the project, calibrate the range of light intensity by waving your hand over the photoresistor. The LED...
Page 423
• Open the 6.3_light_theremin.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. from...
SunFounder ESP32 Starter Kit 3.36 6.4 Reversing Aid Imagine this: You’re in your car, about to reverse into a tight parking spot. With our project, you will have an ultrasonic module mounted on the rear of your vehicle, acting as a digital eye. As you engage the reverse gear, the module springs to life, emitting ultrasonic pulses that bounce off obstacles behind you.
Page 426
SunFounder ESP32 Starter Kit The ultrasonic sensor in the project emits high-frequency sound waves and measures the time it takes for the waves to bounce back after hitting an object. By analyzing this data, the distance between the sensor and the object can be calculated.
Page 427
• Open the 6.4_reversing_aid.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. # Import required libraries...
Page 428
SunFounder ESP32 Starter Kit (continued from previous page) # Initialize the LCD1602 display LCD() # Calculate the distance distance(): # Ensure trigger is off initially TRIG.off() time.sleep_us(2) # Wait for 2 microseconds # Send a 10-microsecond pulse to the trigger pin TRIG.on()
Page 429
SunFounder ESP32 Starter Kit (continued from previous page) # Beep function for the buzzer beep(): buzzer.value(1) time.sleep(0.1) buzzer.value(0) time.sleep(0.1) # Initialize the intervals variable intervals 10000000 previousMills time.ticks_ms() time.sleep(1) # Main loop while True: # Update intervals based on distance <...
SunFounder ESP32 Starter Kit 3.37 6.5 Color Gradient Are you ready to experience a world of color? This project will take you on a magical journey where you can control an LED strip and achieve smooth color transitions. Whether you’re looking to add some color to your home decor or seeking a fun programming project, this project has got you covered.
Page 431
SunFounder ESP32 Starter Kit This project uses an LED strip and a potentiometer to create a color mixing effect. The potentiometer is used to adjust the hue value of the LED, which is then converted into RGB values using a color conversion function. The RGB values are then used to update the color of the LED.
Page 432
• Open the 6.5_color_gradient.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. from...
Page 433
SunFounder ESP32 Starter Kit (continued from previous page) potentiometer.atten(ADC.ATTN_11DB) # Initialize the NeoPixel LED strip neopixel.NeoPixel(Pin(PIN_NUM), NUM_LEDS) # Function to convert HSL color space to RGB color space hsl_to_rgb(h, s, l): # Helper function to convert hue to RGB hue_to_rgb(p, q, t): <...
SunFounder ESP32 Starter Kit (continued from previous page) # Sleep for a short period to allow for smooth transitions time.sleep(0.1) As the code runs, slowly rotate the potentiometer and you will see the color of the RGB Strip fade from red to purple.
Page 435
SunFounder ESP32 Starter Kit This project builds upon the project by adding a button to control the digit displayed on the seven- 2.5 Number Display segment display. The button is directly connected to IO13 without an external pull-up or pull-down resistor because IO13 has an internal pull-up resistor of 47K, eliminating the need for an additional external resistor.
Page 436
• Open the 6.6_digital_dice.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. import...
Page 437
SunFounder ESP32 Starter Kit (continued from previous page) # Define the hc595_shift function to shift data into the 74HC595 shift register hc595_shift(dat): # Set the RCLK pin to low rclk.off() # Iterate through each bit (from 7 to 0) range(7, -1, -1):...
SunFounder ESP32 Starter Kit (continued from previous page) time.sleep_ms(10) # Adjust this value to control the display refresh rate While the program is running, pressing the button will make the 7-segment display scroll and randomly display a number between 1 and 6.
Page 440
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. • The lcd1602.py and ir_rx libraries are used here and check if it’s uploaded to ESP32. Refer to 1.4 Upload for a tutorial.
Page 441
SunFounder ESP32 Starter Kit (continued from previous page) # IR receiver configuration pin_ir Pin(14, Pin.IN) # Initialize the guessing game variables lower upper pointValue int(urandom.uniform(lower, upper)) count # Initialize the LCD1602 display LCD() # Initialize a new random value for the game...
Page 442
SunFounder ESP32 Starter Kit (continued from previous page) "Power": init_new_value() lcd_show(False) elif "+": result number_processing() lcd_show(result) result: time.sleep(5) init_new_value() lcd_show(False) else: lcd_show(False) elif key.isdigit(): else count count int(key) count int(key) <= count lcd_show(False) # Decode the received data and return the corresponding key name...
Page 443
SunFounder ESP32 Starter Kit (continued from previous page) data 0x40: return "BACKWARD" data 0x45: return "POWER" data 0x47: return "MUTE" data 0x46: return "MODE" return "ERROR" callback(data, addr, ctrl): data < pass else: decodeKeyValue(data) "ERROR": process_key(key) # Initialize the IR receiver object with the callback function NEC_8(pin_ir, callback) # ir.error_function(print_error)
Page 444
SunFounder ESP32 Starter Kit lower upper pointValue int(urandom.uniform(lower, upper)) count • lower and upper bounds for the secret number. • The secret number (pointValue) randomly generated between lower and upper bounds. • The user’s current guess (count). 2. This function resets the guessing game values and generates a new secret number.
Welcome to the Plant Monitor project! In this project, we will be using an ESP32 board to create a system that helps us take care of our plants. With this system, we can monitor the temperature, humidity, soil moisture, and light levels of our plants, and ensure that they are getting the care and attention they need to thrive.
Page 446
SunFounder ESP32 Starter Kit Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below. COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor DHT11 Humiture Sensor...
Page 447
SunFounder ESP32 Starter Kit The system uses a DHT11 sensor to measure the temperature and humidity levels of the surrounding environment. Meanwhile, a soil moisture module is used to measure the moisture level of the soil and a photoresistor is used to measure the light level.
Page 448
• Open the 6.8_plant_monitor.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. from...
Page 449
SunFounder ESP32 Starter Kit (continued from previous page) motor2A Pin(26, Pin.OUT) # I2C LCD1602 setup LCD() # Rotate the pump rotate(): motor1A.value(1) motor2A.value(0) # Stop the pump stop(): motor1A.value(0) motor2A.value(0) False button_state # Define the button callback function to toggle the button state...
Page 450
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 print("Error: ", e) # Display temperature and humidity lcd.write(0, 0, "Temp: {}\xDFC".format(temp)) lcd.write(0, 1, "Humi:...
- PictoBlox. It keeps the basic functions of Scratch 3, but also adds control boards, such as Arduino Uno, Mega, Nano, ESP32, Microbit and STEAMPedia homemade main boards, which can use external sensors, robots to control the sprites on the stage, with strong hardware interaction capabilities.
SunFounder ESP32 Starter Kit 1. Get Started 4.1 1.1 Install PictoBlox Click this linkhttps://thestempedia.com/product/pictoblox/download-pictoblox/choose the appropriate Operating Sys- tem (Windows, macOS, Linux) and follow the steps to install. Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 4.2 1.2 Interface Introduction Sprites A sprite is an object, or a character, that performs different actions in a project. It understands and obeys the commands given to it. Each sprite has specific costumes and sounds that you can also customize.
SunFounder ESP32 Starter Kit For more information, please refer to: https://thestempedia.com/tutorials/getting-started-pictoblox 4.3 1.3 Quick Guide on PictoBlox 4.3.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name...
Page 456
4.3.2 Stage Mode 1. Connect to ESP32 Board Connect your ESP32 board to the computer with a USB cable, usually the computer will automatically recognize your board and finally assign a COM port. Open PictoBlox, the Python programming interface will open by default. And we need to switch to the Blocks interface.
Page 457
SunFounder ESP32 Starter Kit Click Board in the upper right navigation bar to select the board. For example, choose ESP32. 4.3. 1.3 Quick Guide on PictoBlox...
Page 458
SunFounder ESP32 Starter Kit A connection window will then pop up for you to select the port to connect to, and return to the home page when the connection is complete. If you break the connection during use, you can also click Connect to reconnect.
Page 459
SunFounder ESP32 Starter Kit At the same time, ESP32 related palettes, such as ESP32, Actuators, etc., will appear in the Block Palette. 4.3. 1.3 Quick Guide on PictoBlox...
Page 460
SunFounder ESP32 Starter Kit 2. Upload Firmware Since we’re going to work in the Stage mode, we must upload the firmware to the board. It will ensure real-time communication between the board and the computer. Uploading the firmware it is a one-time process. To do so, click on the Upload Firmware button.
Page 461
You can click on File in the top right corner and then choose Open. Choose Open from Computer. Then go to the path of esp32-starter-kit-main\scratch, and open 1. Stage Mode.sb3. Please ensure that you have downloaded the required code from github.
Page 462
Click directly on the script to run it, some projects are click on the green flag or click on the sprite. • Program step by step You can also write the script step by step by following these steps. Click on the ESP32 palette. Chapter 4. Play with Scratch...
Page 463
SunFounder ESP32 Starter Kit The LED is controlled by the digital pin 26 (only 2 states, HIGH or LOW), so drag the [set digital pin out as] block to the script area. Since the default state of the LED is lit, now set pin 23 to LOW and click on this block and you will see the LED go off.
Page 464
SunFounder ESP32 Starter Kit In order to see the effect of continuous blinking LED, you need to use the [Wait 1 seconds] and [forever] blocks in the Control palette. Click on these blocks after writing, there is a yellow halo means it is running.
Page 465
SunFounder ESP32 Starter Kit 4.3.3 Upload Mode 1. Connect to ESP32 Board Connect your ESP32 board to the computer with a USB cable, usually the computer will automatically recognize your board and finally assign a COM port. 4.3. 1.3 Quick Guide on PictoBlox...
Page 466
SunFounder ESP32 Starter Kit Open PictoBlox and click Board in the top right navigation bar to select the board. For example, choose ESP32. Chapter 4. Play with Scratch...
Page 467
SunFounder ESP32 Starter Kit A connection window will then pop up for you to select the port to connect to, and return to the home page when the connection is complete. If you break the connection during use, you can also click Connect to reconnect.
Page 468
SunFounder ESP32 Starter Kit At the same time, ESP32 related palettes, such as ESP32, Actuators, etc., will appear in the Block Palette. Chapter 4. Play with Scratch...
Page 469
SunFounder ESP32 Starter Kit After selecting Upload mode, the stage will switch to the original code area. 4.3. 1.3 Quick Guide on PictoBlox...
Page 470
• Open and run the script directly You can click on File in the top right corner. Choose Open from Computer. Then go to the path of esp32-starter-kit-main\scratch, and open 1. Upload Mode.sb3. Please ensure that you Chapter 4. Play with Scratch...
Page 471
Finally, click the Upload Code button. • Program step by step You can also write the script step by step by following these steps. Click on the ESP32 palette. 4.3. 1.3 Quick Guide on PictoBlox...
Page 472
SunFounder ESP32 Starter Kit Drag [when ESP32 starts up] to the script area, which is required for every script. The LED is controlled by the digital pin26 (only 2 states HIGH or LOW), so drag the [set digital pin out as] block to the script area.
Page 473
SunFounder ESP32 Starter Kit At this point you will see the code appear on the right side, if you want to edit this code, then you can turn Edit mode 4.3. 1.3 Quick Guide on PictoBlox...
Page 474
SunFounder ESP32 Starter Kit In order to see the effect of continuous blinking LED, you need to use the [Wait 1 seconds] and [forever] blocks in the Control palette. Click on these blocks after writing, there is a yellow halo means it is running.
Page 475
SunFounder ESP32 Starter Kit 2. Projects The following projects are written in order of programming difficulty, it is recommended to read these books in order. In each project, there are very detailed steps to teach you how to build the circuit and how to program it step by step to achieve the final result.
Page 476
SunFounder ESP32 Starter Kit 4.4.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 477
SunFounder ESP32 Starter Kit 4.4.2 You Will Learn • Breadboard, LEDs and Resistors • Building a circuit on a breadboard • Delete and select sprites • Switching costumes • Set a limited number of repeat loops 4.4.3 Build the Circuit Follow the diagram below to build the circuit on the breadboard.
Page 478
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 479
SunFounder ESP32 Starter Kit 4.4.4 Programming The whole programming is divided into 3 parts, the first part is to select the desired sprite, the second part is to switch the costume for the sprite to make it look clickable, and the third part is to make the LED blink.
Page 480
SunFounder ESP32 Starter Kit Click on Costumes in the top right corner and you will see that the Button3 sprite has 2 costumes, we set button3-a to be released and button3-b to be pressed. 2. Switching costumes. When the sprite is clicked (Events palette), it switches to costume for button3-b (looks palette).
SunFounder ESP32 Starter Kit 4.5 2.2 Breathing LED Now use another method to control the brightness of the LED. Unlike the previous project, here the brightness of the LED is made to slowly diminish until it disappears. When the sprite on the stage is clicked, the brightness of the LED slowly increases and then goes out instantly.
Page 483
PWM - Wikipedia signal to slowly light up or dim down the LED. The PWM signal range is 0-255, on the ESP32 board, 2, 5, 12~15, 18, 19, 21, 22, 25, 26 and 27 can output PWM signal. 4.5. 2.2 Breathing LED...
Page 484
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 485
SunFounder ESP32 Starter Kit 4.5.4 Programming 1. Select a sprite Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, enter button3 in the search box, and then click to add it.
Page 486
SunFounder ESP32 Starter Kit Enter the name of the variable, it can be any name, but it is recommended to describe its function. The data type is number and For all sprites. Once created, you will see pwm inside the Variables palette and in the checked state, which means this variable will appear on the stage.
Page 487
5 each time. • [set PWM pin]: from the ESP32 palette, used to set the output value of the pwm pin. 4.5. 2.2 Breathing LED...
Page 488
SunFounder ESP32 Starter Kit Finally, switch the costume of button3 back to button-a and make the PWM pin value 0, so that the LED will light up slowly and then turn off again. Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 4.6 2.3 Colorful Balls In this project, we will make the RGB LEDs display different colors. Clicking on different colored balls on the stage area will cause the RGB LED to light up in different colors.
Page 490
SunFounder ESP32 Starter Kit 4.6.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 491
SunFounder ESP32 Starter Kit 4.6.2 You Will Learn • The principle of RGB LED • Copy sprites and select different costumes • Three primary colors superimposed 4.6.3 Build the Circuit An RGB LED packages three LEDs of red, green, and blue into a transparent or semitransparent plastic shell. It can display various colors by changing the input voltage of the three pins and superimpose them, which, according to statistics, can create 16,777,216 different colors.
Page 492
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 493
SunFounder ESP32 Starter Kit 4.6.4 Programming 1. Select sprite Delete the default sprite, then choose the Ball sprite. And duplicate it 5 times. Choose different costumes for these 5 Ball sprites and move them to the corresponding positions. Note: Ball3 sprite costume color needs to be manually changed to red.
Page 494
SunFounder ESP32 Starter Kit 2. Make RGB LEDs light up in the appropriate color Before understanding the code, we need to understand the RGB color model. The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors.
Page 495
SunFounder ESP32 Starter Kit So the code to make the RGB LED light yellow is as follows. When the Ball sprite (yellow ball) is clicked, we set pin 27 high (red LED on), pin 26 high (green LED on) and pin 25 low (blue LED off) so that the RGB LED will light yellow.
Page 496
SunFounder ESP32 Starter Kit 4. Ball3 sprite (red) 5. Ball4 sprite (green) Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 6. Ball5 sprite (purple) 4.7 2.4 Moving Mouse Today we are going to make a mouse toy controlled by a potentiometer. When the green flag is clicked, the mouse on the stage moves forward, and when you rotate the potentiometer, the mouse will change the direction of movement.
Page 498
SunFounder ESP32 Starter Kit 4.7.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 499
The potentiometer is a resistive element with 3 terminals, the 2 side pins are connected to 5V and GND, and the middle pin is connected to pin35. After conversion by the ADC converter of the ESP32, the value range is 0-4095.
Page 500
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 501
SunFounder ESP32 Starter Kit 4.7.4 Programming 1. Choose a sprite Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, enter mouse in the search box, and then click to add it.
Page 502
SunFounder ESP32 Starter Kit 3. Read the value of pin35 Store the value of pin35 read into the variable value. • [set my variable to 0]: Set the value of the variable. • [read analog pin ()]: Read the value of pins in the range of 0-4095.
Page 503
SunFounder ESP32 Starter Kit 4. Move the sprite Use the [move steps] block to move the sprite, run the script and you will see the sprite move from the middle to the right. 5. Changing the sprite’s direction Now change the direction of the sprite’s movement by the value of pin35. Since the value of pin35 ranges from 0-4095, but the sprite’s rotation direction is -180~180, a [map] block needs to be used.
SunFounder ESP32 Starter Kit 4.8 2.5 Doorbell Here, we will use the button and the bell on the stage to make a doorbell. After the green flag is clicked, you can press the button and the bell on the stage will make a sound.
Page 505
SunFounder ESP32 Starter Kit 4.8.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 506
SunFounder ESP32 Starter Kit Build the circuit according to the following diagram. • Connect one of the pins on the left side of the button to pin14, which is connected to a pull-down resistor and a 0.1uF (104) capacitor (to eliminate jitter and output a stable level when the button is working).
Page 508
SunFounder ESP32 Starter Kit 4.8.4 Programming 1. Add a Backdrop Click the Choose a Backdrop button in the lower right corner. Choose Bedroom 1. 2. Select the sprite Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, enter bell in the search box, and then click to add it.
Page 509
SunFounder ESP32 Starter Kit Then select the bell sprite on the stage and move it to the right position. 4.8. 2.5 Doorbell...
Page 510
Use [if then] to make a conditional statement that when the value of the pin14 read is equal to 1 (the key is pressed), the sound xylo1 will be played. • [read status of digital pin]: This block is from the ESP32 palette and used to read the value of a digital pin, the result is 0 or 1.
SunFounder ESP32 Starter Kit 4.9 2.6 Low Temperature Alarm In this project, we will make a low temperature alarm system, when the temperature is below the threshold, the Snowflake sprite will appear on the stage. 4.9. 2.6 Low Temperature Alarm...
Page 512
SunFounder ESP32 Starter Kit 4.9.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 513
SunFounder ESP32 Starter Kit 4.9.2 You Will Learn • Thermistor working principle • Multivariable and Subtractive Operations 4.9.3 Build the Circuit A thermistor is a type of resistor whose resistance is strongly dependent on temperature, more so than in standard resistors, and there are two types of resistors, PTC (resistance increases as temperature increases) and PTC (resistance decreases as temperature increases).
Page 514
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 515
SunFounder ESP32 Starter Kit 4.9.4 Programming 1. Select a sprite Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, enter Snowflake in the search box, and then click to add it.
Page 516
SunFounder ESP32 Starter Kit 3. Read the value of pin35 When the green flag is clicked, the value of pin35 is read and stored in the variable before. 4. Read the value of pin35 again In [forever], read the value of pin35 again and store it in the variable current.
Page 517
SunFounder ESP32 Starter Kit 5. Determining temperature changes Using the [if else] block, determine if the current value of pin35 is 200 greater than before, which represents a decrease in temperature. At this point let Snowflake sprite show, otherwise hide.
Page 518
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 4.10 2.7 Light Alarm Clock In life, there are various kinds of time alarm clocks. Now let’s make a light-controlled alarm clock. When morning comes, the brightness of light increases and this light-controlled alarm clock will remind you that it’s time to get up.
Page 520
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Photoresistor 4.10.2 You Will Learn • Photoresistor working principle • Stopping sound playback and stopping scripts from running 4.10.3 Build the Circuit A photoresistor or photocell is a light-controlled variable resistor.
Page 522
SunFounder ESP32 Starter Kit 4.10.4 Programming 1. Select a sprite Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, enter bell in the search box, and then click to add it.
Page 523
SunFounder ESP32 Starter Kit 3. Make a sound When the value of current pin35 is greater than the previous 50, which represents the current light intensity is greater than the threshold, then let the sprite make a sound. 4.10. 2.7 Light Alarm Clock...
Page 524
SunFounder ESP32 Starter Kit 4. Turning the sprite Use [turn block] to make the bell sprite turn left and right to achieve the alarm effect. Chapter 4. Play with Scratch...
Page 525
SunFounder ESP32 Starter Kit 5. stop all Stops the alarm when it has been ringing for a while. 4.10. 2.7 Light Alarm Clock...
SunFounder ESP32 Starter Kit 4.11 2.8 Read Temperature and Humidity Previous projects have been using stage mode, but some functions are only available in upload mode, such as serial communication function. In this project, we will print the temperature and humidity of the DHT11 using the Serial...
Page 527
SunFounder ESP32 Starter Kit 4.11.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 528
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 529
2. Initializing the ESP32 and Serial Monitor In Upload mode, start ESP32 and then set the serial port baud rate. • [when ESP32 Starts up]: In Upload mode, start ESP32.
Page 530
SunFounder ESP32 Starter Kit 3. Read temperature and humidity Create 2 variables tem and humi to store the temperature and humidity respectively, the code will appear on the right side while you drag and drop the block. 4. Print them on the Serial Monitor Write the read temperature and humidity to the Serial Monitor.
Page 531
5. Uploading code Unlike the Stage mode, the code in Upload mode needs to be uploaded to the ESP32 board using the Upload Code button to see the effect. This also allows you to unplug the USB cable and still have the program running.
SunFounder ESP32 Starter Kit 4.12 2.9 Rotating Fan In this project, we will make a spinning star sprite and fan. Clicking on the left and right arrow sprites on the stage will control the clockwise and counterclockwise rotation of the motor and star sprite, click on the star sprite to stop the rotation.
Page 533
SunFounder ESP32 Starter Kit 4.12.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 534
SunFounder ESP32 Starter Kit 4.12.2 You Will Learn • Motor working principle • Broadcast function • Stop other script in sprite block 4.12.3 Build the Circuit 4.12.4 Programming The effect we want to achieve is to use 2 arrow sprites to control the clockwise and counterclockwise rotation of the motor and the star sprite respectively, clicking on the star sprite will stop the motor from rotating.
Page 535
SunFounder ESP32 Starter Kit In the Costumes option, change the Arrow1 sprite to a different direction costume. 4.12. 2.9 Rotating Fan...
Page 536
SunFounder ESP32 Starter Kit Adjust the size and position of the sprite appropriately. Chapter 4. Play with Scratch...
Page 537
SunFounder ESP32 Starter Kit 2. Left arrow sprite When this sprite is clicked, it broadcasts a message - turn, then sets digital pin12 to low and pin14 to high, and sets the variable flag to 1. If you click the left arrow sprite, you will find that the motor turns counterclockwise, if your turn is clockwise, then you swap the positions of pin12 and pin14.
Page 538
SunFounder ESP32 Starter Kit 3. right-arrow sprite When this sprite is clicked, broadcast a message turn, then set digital pin12 high and pin14 low to make the motor turn clockwise and set the flag variable to 0. Chapter 4. Play with Scratch...
Page 539
SunFounder ESP32 Starter Kit 4. star sprite There are 2 events included here. • When the star sprite receives the broadcasted message turn, it determines the value of flag; if flag is 1, it turns 10 degrees to the left, otherwise it reverses. Since it is in [FOREVER], it will keep turning.
SunFounder ESP32 Starter Kit 4.13 2.10 Light Sensitive Ball In this project, we use Photoresistor to make the ball on the stage fly upwards. Place your hand on top of the photoresistor to control the light intensity it receives. The closer your hand is to the photoresistor, the smaller its value and the higher the ball flies on the stage, otherwise it will fall.
Page 541
SunFounder ESP32 Starter Kit 4.13.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 542
SunFounder ESP32 Starter Kit 4.13.2 You Will Learn • Fill the sprite with colors • Touch between the sprites 4.13.3 Build the Circuit A photoresistor or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity.
Page 544
SunFounder ESP32 Starter Kit 4.13.4 Programming The effect we want to get is that the closer your hand is to the photoresistor, the ball sprite on the stage keeps going up, otherwise it will fall on the bowl sprite. If it touches the Line sprite while walking up or falling down, it will make a musical sound and emit star sprites in all directions.
Page 545
SunFounder ESP32 Starter Kit Set the size and direction of the Star sprite to 180 because we need it to fall down, or you can change it to another angle. Now add the Stars backdrop. 4.13. 2.10 Light Sensitive Ball...
Page 546
SunFounder ESP32 Starter Kit 2. Draw a Line sprite Add a Line sprite. Go to the Costumes page of the Line sprite, reduce the width of the red line on the canvas slightly, then copy it 5 times and align the lines.
Page 547
SunFounder ESP32 Starter Kit Now fill the lines with different colors. First choose a color you like, then click on the Fill tool and move the mouse over the line to fill it with color. 4.13. 2.10 Light Sensitive Ball...
Page 548
SunFounder ESP32 Starter Kit Follow the same method to change the color of the other lines. 3. Scripting the Ball sprite Set the initial position of the Ball sprite, then when the light value is less than 1500 (it can be any other value, depending on your current environment.), let the Ball move up.
Page 549
SunFounder ESP32 Starter Kit Otherwise, the Ball sprite will fall and limit its Y coordinate to a minimum of -100. This can be modified to make it look like it is falling on the Bowl sprite. 4.13. 2.10 Light Sensitive Ball...
Page 550
SunFounder ESP32 Starter Kit When the Line sprite is hit, the current Y coordinate is saved to the variable ball_coor and a Bling message is broadcast. Chapter 4. Play with Scratch...
Page 551
SunFounder ESP32 Starter Kit 4. Scripting the Star sprite When the script starts, first hide the Star sprite. When the Bling message is received, clone the Star sprite. 4.13. 2.10 Light Sensitive Ball...
Page 552
SunFounder ESP32 Starter Kit When the Star sprite appears as a clone, play the sound effect and set its coordinates to be in sync with the Ball sprite. Create the effect of the Star sprite appearing, and adjust it as needed.
SunFounder ESP32 Starter Kit 4.14 2.11 GAME - Shooting Have you seen those shooting games on TV? The closer a contestant shoots a bullet on the target to the bullseye, the higher his score. Today we are also doing a shooting game in Scratch. In the game, let the Crosshair shoot as far as possible to the bullseye to get a higher score.
Page 554
SunFounder ESP32 Starter Kit 4.14.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 555
SunFounder ESP32 Starter Kit 4.14.2 You Will Learn • How the Obstacle Avoidance module works and the angle range • Paint different sprites • Touch colors 4.14.3 Build the Circuit The obstacle avoidance module is a distance-adjustable infrared proximity sensor whose output is normally high and low when an obstacle is detected.
Page 556
SunFounder ESP32 Starter Kit Go to the Crosshair sprite’s Costumes page. Click on the Circle tool, remove the fill color, and set the color and width of the outline. Now draw a circle with the Circle tool. After drawing, you can click to the Select tool and move the circle so that the...
Page 557
SunFounder ESP32 Starter Kit original point is aligned with the center of the canvas. Using the Line tool, draw a cross inside the circle. 4.14. 2.11 GAME - Shooting...
Page 558
SunFounder ESP32 Starter Kit Paint the Target sprite Create a new sprite called Target sprite. Go to the Costumes page of the Target sprite, click on the Circle tool, select a fill color and remove the Outline and paint a large circle.
Page 559
SunFounder ESP32 Starter Kit Use the same method to draw additional circles, each with a different color, and you can use the Forward or Backbard tool to change the position of the overlapping circles. Note that you also need to select the tool to move the circles, so that the origin of all the circles and the center of the canvas are aligned.
Page 560
SunFounder ESP32 Starter Kit 3. Add a backdrop Add a suitable background which preferably does not have too many colors and does not match the colors in the Target sprite. Here I have chosen Wall1 backdrop. Chapter 4. Play with Scratch...
Page 561
SunFounder ESP32 Starter Kit 4. Script the Crosshair sprite Set the random position and size of the Crosshair sprite, and let it move randomly. When a hand is placed in front of the obstacle avoidance module, it will output a low level as a transmit signal.
Page 562
SunFounder ESP32 Starter Kit When the shooting message is received, the sprite stops moving and slowly shrinks, thus simulating the effect of a bullet being shot. Use the [Touch color ()] block to determine the position of the shot. Chapter 4. Play with Scratch...
Page 563
SunFounder ESP32 Starter Kit When the shot is inside the yellow circle, 10 is reported. 4.14. 2.11 GAME - Shooting...
Page 564
SunFounder ESP32 Starter Kit Use the same method to determine the position of the bullet shot, if it is not set on the Target sprite, it means it is out of the circle. Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 4.15 2.12 GAME - Inflating the Balloon Here, we will play a game of ballooning. After clicking the green flag, the balloon will become bigger and bigger. If the balloon is too big, it will be blown up;...
Page 567
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Button 4.15.2 You Will Learn • Paint costume for the sprite 4.15.3 Build the Circuit The button is a 4-pin device, since the pin 1 is connected to pin 2, and pin 3 to pin 4, when the button is pressed, the 4 pins are connected, thus closing the circuit.
Page 568
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 569
SunFounder ESP32 Starter Kit 4.15.4 Programming 1. Add a sprite and a backdrop Delete the default sprite, click the Choose a Sprite button in the lower right corner of the sprite area, then select the Balloon1 sprite. Add a Boardwalk backdrop via the Choose a backdrop button, or other backbackdrops you like.
Page 570
SunFounder ESP32 Starter Kit Select a color and then use the Brush tool to draw a pattern. Chapter 4. Play with Scratch...
Page 571
SunFounder ESP32 Starter Kit Select a color again, click the Fill tool, and move the mouse inside the pattern to fill it with a color. 4.15. 2.12 GAME - Inflating the Balloon...
Page 572
SunFounder ESP32 Starter Kit Finally, write the text BOOM, so that an explosion effect costume is complete. 3. Scripting the Balloon sprite Set the initial position and size of the Balloon1 sprite. Chapter 4. Play with Scratch...
Page 573
SunFounder ESP32 Starter Kit Then let the Balloon sprite slowly get bigger. When the button is pressed (value is 1), the size of the Balloon1 sprite stops getting bigger. • When the size is less than 90, it will fall (y coordinate decreases).
Page 574
SunFounder ESP32 Starter Kit If the button has not been pressed, the balloon slowly gets bigger and when the size is bigger than 120, it will explode (switch to the explode effect costume). Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit 4.16 2.13 GAME - Star-Crossed In the next projects, we will play some fun mini-games in PictoBlox. Here we use Joystick module to play a Star-Crossed game. After the script is run, stars will appear randomly on the stage, you need to use Joystick to control Rocketship to avoid the stars, if you touch it, the game will be over.
Page 576
SunFounder ESP32 Starter Kit 4.16.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 577
SunFounder ESP32 Starter Kit 4.16.2 You Will Learn • How Joystick module works • Set the x and y coordinates of the sprite 4.16.3 Build the Circuit A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling.
Page 578
SunFounder ESP32 Starter Kit 4.16.4 Programming The whole script is to achieve the effect that when the green flag is clicked, the Stars sprite moves in a curve on the stage and you need to use the joystick to move the Rocketship, so that it will not be touched by the Star sprite.
Page 579
SunFounder ESP32 Starter Kit 2. Scripting for Rocketship The Rocketship sprite is to achieve the effect that it will appear at a random position and then be controlled by the joystick to move it up, down, left, and right. The workflow is as follows.
Page 580
SunFounder ESP32 Starter Kit • The value of pin33 is in the range 0-4095 (the middle is about 1800). Use x-1800>200 to determine if Joystick is toggling to the right, and if so, make the x coordinate of the sprite +30 (to move the sprite to the right).
Page 581
SunFounder ESP32 Starter Kit • If the Joystick is toggled to the left, let the x coordinate of the sprite be -30 (let the sprite move to the left). 4.16. 2.13 GAME - Star-Crossed...
Page 582
SunFounder ESP32 Starter Kit • Since the Joystick’s y coordinate is from up (0) to down (4095), and the sprite’s y coordinate is from down to up. So in order to move the Joystick upwards and the sprite upwards, the y-coordinate must be -30 in the script.
Page 583
SunFounder ESP32 Starter Kit • If the joystick is flicked down, the y-coordinate of the sprite is +30. 3. Scripting for Star 4.16. 2.13 GAME - Star-Crossed...
Page 584
SunFounder ESP32 Starter Kit The effect to be achieved by the Star sprite is to appear at a random location, and if it hits Rocketship, the script stops running and the game ends. • When the green flag is clicked and the sprite goes to a random location, the [turn degrees] block is to make the Star sprite move forward with a bit of an angle change so you can see that it is moving in a curve and if on edge, bounce.
SunFounder ESP32 Starter Kit 4.17 2.14 GAME - Eat Apple In this project, we play a game that uses button to control Beetle to eat apple. When the green flag is clicked, press the button and Beetle will rotate, press the button again and Beetle stops running and goes forward at that angle.
Page 586
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Button 4.17.2 Build the Circuit The button is a 4-pin device, since the pin 1 is connected to pin 2, and pin 3 to pin 4, when the button is pressed, the 4 pins are connected, thus closing the circuit.
Page 588
SunFounder ESP32 Starter Kit 4.17.3 Programming The effect we want to achieve is to use the button to control the direction of the Beetle sprite to move forward and eat the apple without touching the black line on the Maze backdrop, which will switch the backdrop when eaten.
Page 589
SunFounder ESP32 Starter Kit Place the Beetle sprite at the entrance of the Maze backdrop, remembering the x,y coordinate values at this point, and resize the sprite to 40%. 4.17. 2.14 GAME - Eat Apple...
Page 590
SunFounder ESP32 Starter Kit 2. Draw a backdrop Now it’s time to simply draw a backdrop with the WIN! character appearing on it. First click on the backdrop thumbnail to go to the Backdrops page and click on the blank backdrop1.
Page 591
SunFounder ESP32 Starter Kit Now start drawing, you can refer to the picture below to draw, or you can draw a backdrop on your own, as long as the expression is winning. • Using the Circle tool, draw an ellipse with the color set to red and no outline.
Page 592
SunFounder ESP32 Starter Kit 3. Scripting for the backdrop The backdrop needs to be switched to Maze every time the game starts. 4. Writing scripts for the sprite Beetle Now write a script for the sprite Beetle to be able to move forward and turn direction under the control of a button. The workflow is as follows.
Page 593
SunFounder ESP32 Starter Kit Next, in the [forever] block, four [if] blocks are used to determine various possible scenarios. • If the button is 1 (pressed), use the [mod] block to toggle the value of the variable flag between 0 and 1 (alternating between 0 for this press and 1 for the next press).
Page 594
SunFounder ESP32 Starter Kit • If the Beetle sprite touches black (the black line on the Maze backdrop), the game ends and the script stops running. Note: You need to click on the color area in the [Touch color] block, and then select the eyedropper tool to pick up the color of the black line on the stage.
Page 595
SunFounder ESP32 Starter Kit • If Beetle touches red (Also use the straw tool to pick up the red color of the apple), the backdrop will be switched to Win, which means the game succeeds and stops the script from running.
SunFounder ESP32 Starter Kit 4.18 2.15 GAME - Flappy Parrot Here we use the ultrasonic module to play a flappy parrot game. After the script runs, the green bamboo will slowly move from the right to the left at a random height. Now place your hand on top of the ultrasonic module, if the distance between your hand and the ultrasonic module is less than 10, the parrot will fly upwards, otherwise it will fall downwards.
Page 597
SunFounder ESP32 Starter Kit 4.18.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 598
SunFounder ESP32 Starter Kit 4.18.2 Build the Circuit An ultrasonic sensor module is an instrument that measures the distance to an object using ultrasonic sound waves. It has two probes. One is to send ultrasonic waves and the other is to receive the waves and transform the time of sending and receiving into a distance, thus detecting the distance between the device and an obstacle.
Page 599
SunFounder ESP32 Starter Kit Now add the Paddle sprite, set its size to 150%, set its angle to 180, and move its initial position to the top right corner. 4.18. 2.15 GAME - Flappy Parrot...
Page 600
SunFounder ESP32 Starter Kit Go to the Costumes page of the Paddle sprite and remove the Outline. Chapter 4. Play with Scratch...
Page 601
SunFounder ESP32 Starter Kit 2. Scripting for the Parrot Sprite Now script the Parrot sprite, which is in flight and the flight altitude is determined by the detection distance of the ultrasonic module. • When the green flag is clicked, switch the costume every 0.2s so that it is always in flight.
Page 602
SunFounder ESP32 Starter Kit • If the ultrasonic detection distance is less than 10cm, let the y coordinate increase by 50, the Parrot sprite will fly upwards. Otherwise, the y-coordinate value is decreased by 40, Parrot will fall down. • If the Parrot sprite touches the Paddle sprite, the game ends and the script stops running.
Page 603
SunFounder ESP32 Starter Kit 3. Scripting for the Paddle sprite Now write the script for the Paddle sprite, which needs to appear randomly on the stage. • Hide the sprite Paddle when the green flag is clicked, and clone itself at the same time. The [create clone block is a control block and a stack block.
Page 604
SunFounder ESP32 Starter Kit • Use the [repeat] block to make its x coordinate value slowly decrease, so you can see the clone of the Paddle sprite slowly move from the right to the left until it disappears. • Re-clone a new Paddle sprite and delete the previous clone.
SunFounder ESP32 Starter Kit 4.19 2.16 GAME - Breakout Clone Here we use the potentiometer to play a Breakout Clone game. After clicking the green flag, you need to use the potentiometer to control the paddle on the stage to catch the ball so that it can go up and hit the bricks, all the bricks disappear then the game is won, if you don’t catch the ball, the game...
Page 606
The potentiometer is a resistive element with 3 terminals, the 2 side pins are connected to 5V and GND, and the middle pin is connected to pin35. After the conversion by the ADC converter of the esp32 board, the value range is 0-4095.
Page 608
SunFounder ESP32 Starter Kit 4.19.3 Programming There are 3 sprites on the stage. 1. Paddle sprite The effect to be achieved by the Paddle is that the initial position is in the middle of the bottom of the stage, and it is controlled by a potentiometer to move it to the left or to the right.
Page 609
SunFounder ESP32 Starter Kit • Now you can rotate the potentiometer to see if the Paddle can move left and right on the stage. 2. Ball sprite The effect of the ball sprite is that it moves around the stage and bounces when it touches the edge; it bounces down if it touches the block above the stage;...
Page 610
SunFounder ESP32 Starter Kit • Now let the Ball sprite move around the stage and bounce when it touches the edge, and you can click on the green flag to see the effect. • When the Ball sprite touches the Paddle sprite, do a reflection. The easy way to do this is to let the angle be directly inverted, but then you’ll find that the path of the ball is completely fixed, which is too boring.
Page 611
SunFounder ESP32 Starter Kit • When the Ball sprite falls to the edge of the stage, the script stops running and the game ends. 3. Block1 sprite The Block1 sprite is to appear with the effect of cloning 4x8 of itself above the stage in a random color, and deleting a clone if it is touched by the Ball sprite.
Page 612
SunFounder ESP32 Starter Kit The Block1 sprite is not available in the PictoBlox library, you need to draw it yourself or modify it with an existing sprite. Here we are going to modify it with the Button3 sprite. • After adding the Button3 sprite, go to the Costumes page. Now delete button-a first, then reduce both the width and height of button-b, and change the sprite name to Block1, as shown in the following image.
Page 613
SunFounder ESP32 Starter Kit • After the script is written, click on the green flag and look at the display on the stage, if it is too compact or too small, you can change the size. 4.19. 2.16 GAME - Breakout Clone...
Page 614
SunFounder ESP32 Starter Kit • Now write the trigger event. If the cloned Block1 sprite touches the Ball sprite, delete the clone and broadcast the message crush. Chapter 4. Play with Scratch...
Page 615
SunFounder ESP32 Starter Kit • Back to the Ball sprite, when the broadcast crush is received (the Ball sprite touches the clone of Block1 sprite), the Ball is popped from the opposite direction. 4.19. 2.16 GAME - Breakout Clone...
SunFounder ESP32 Starter Kit 4.20 2.17 GAME - Fishing Here, we play a fishing game with a button. When the script is running, the fish swim left and right on the stage, you need to press the button when the fish is almost close to the hook (it is recommended to press it for a longer time) to catch the fish, and the number of fish caught will be recorded automatically.
Page 617
SunFounder ESP32 Starter Kit COMPONENT INTRODUCTION PURCHASE LINK ESP32 WROOM 32E ESP32 Camera Extension Breadboard Jumper Wires Resistor Button 4.20.2 Build the Circuit The button is a 4-pin device, since the pin 1 is connected to pin 2, and pin 3 to pin 4, when the button is pressed, the 4 pins are connected, thus closing the circuit.
Page 618
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 619
SunFounder ESP32 Starter Kit 4.20.3 Programming We need to select an Underwater backdrop first, then add a Fish sprite and let it swim back and forth on the stage. Then draw a Fishhook sprite and control it by a button to start fishing. When the Fish sprite touches the Fishhook sprite in the hooked state (turns red), it will be hooked.
Page 620
SunFounder ESP32 Starter Kit it just at the center point. • Use the Line tool to draw a line as long as possible from the center point up (line out of the stage). Now that the sprite is drawn, set the sprite name to Fishhook and move it to the right position.
Page 621
SunFounder ESP32 Starter Kit • If the button is pressed, set the color effect to 0 (red, start fishing state), wait for 0.1 and then move the Fishhook sprite to the top of the stage. Release the button and let the Fishhook return to its initial position.
Page 622
SunFounder ESP32 Starter Kit 3. Fish sprite The effect to be achieved by the Fish sprite is to move left and right on the stage, and when it encounters a Fishhook sprite in the fishing state, it shrinks and moves to a specific position and then disappears, and then clones a new fish sprite again.
Page 623
SunFounder ESP32 Starter Kit • Create a variable score to store the number of fish caught, hide this sprite and clone it. • Show the clone of the fish sprite, switch its costume and finally set the initial position. 4.20. 2.17 GAME - Fishing...
Page 624
SunFounder ESP32 Starter Kit • Make the fish sprite’s clone move left and right and bounce back when it touches the edge. • The fish sprite (of the clone) will not react when it passes the Fishhook sprite; when it touches the Fishhook sprite in the fishing state (turns red), it will be caught, at which point the score (variable score) +1, and it will also show a score animation (shrinks 40%, quickly moves to the position of the scoreboard and disappears).
SunFounder ESP32 Starter Kit red color of the Fishhook sprite on the stage. If you choose a color arbitrarily, this [Touch color] block will not work. 4.21 2.18 GAME - Don’t Tap on The White Tile I’m sure many of you have played this game on your cell phones. This game is played by tapping on randomly appearing black to add points, the speed will get faster and faster, tap on white blocks or miss black blocks game over.
Page 626
SunFounder ESP32 Starter Kit 4.21.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 627
SunFounder ESP32 Starter Kit 4.21.2 Build the Circuit The obstacle avoidance module is a distance-adjustable infrared proximity sensor whose output is normally high and low when an obstacle is detected. Now build the circuit according to the diagram below. 4.21. 2.18 GAME - Don’t Tap on The White Tile...
Page 628
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
Page 629
SunFounder ESP32 Starter Kit 4.21.3 Programming Here we need to have 3 sprites, Tile , Left IR and Right IR. • Tile sprite: used to achieve the effect of alternating black and white tiles downward, in the cell phone this game is generally 4 columns, here we only do two columns.
Page 630
SunFounder ESP32 Starter Kit Select the rectangle and click Copy -> Paste to make an identical rectangle, then move the two rectangles to a flush position. Chapter 4. Play with Scratch...
Page 631
SunFounder ESP32 Starter Kit Select one of the rectangles and choose a fill color of black. 4.21. 2.18 GAME - Don’t Tap on The White Tile...
Page 632
SunFounder ESP32 Starter Kit Now select both rectangles and move them so that their center points match the center of the canvas. Chapter 4. Play with Scratch...
Page 633
SunFounder ESP32 Starter Kit Duplicate costume1, alternating the fill colors of the two rectangles. For example, the fill color of costume1 is white on the left and black on the right, and the fill color of costume2 is black on the left and white on the right.
Page 634
SunFounder ESP32 Starter Kit 2. Scripting the Tile sprite Now go back to the Blocks page and set the initial position of the Tile sprite so that it is at the top of the stage. Chapter 4. Play with Scratch...
Page 635
SunFounder ESP32 Starter Kit Create a variable -blocks and give it an initial value to determine the number of times the Tile sprite will appear. Use the [repeat until] block to make the variable blocks gradually decrease until blocks is 0. During this time, have the sprite Tile randomly switch its costume.
Page 636
SunFounder ESP32 Starter Kit Create clones of the Tile sprite while the variable blocks is decreasing, and stop the script from running when blocks is 0. Two [wait () seconds] blocks are used here, the first to limit the interval between Tile’s clones and the second is to let the variable blocks decrease to 0 without stopping the program immediately, giving the last tile sprite enough time to move.
Page 637
SunFounder ESP32 Starter Kit Now script the clone of the Tile sprite to move down slowly and delete it when it reaches the bottom of the stage. The change in the y coordinate affects the drop speed, the larger the value, the faster the drop speed.
Page 638
SunFounder ESP32 Starter Kit Hide the body and show the clone. Chapter 4. Play with Scratch...
Page 639
SunFounder ESP32 Starter Kit 3. Read the values of the 2 IR modules In the backdrop, read the values of the 2 IR modules and make the corresponding actions. • If the left IR obstacle avoidance module senses your hand, broadcast a message - left.
Page 640
SunFounder ESP32 Starter Kit Again, mouse over the Add sprite icon and select Paint to create a new sprite called Left IR. Go to the Costumes page of the Left IR sprite, select the fill color (any color out of black and white) and draw a circle.
Page 641
SunFounder ESP32 Starter Kit Now start scripting the Left IR sprite. When the message - left is received (the IR receiver module on the left detects an obstacle), then determine if the black block of the Tile sprite is touched, and if it is, let the variable count add 1, otherwise subtract 1.
Page 642
SunFounder ESP32 Starter Kit Note: You need to make the Tile sprite appear on the stage, and then absorb the color of the black block in the Tile sprite. Now let’s do the sensing effect (zoom in and out) for Left IR.
Page 643
SunFounder ESP32 Starter Kit Make the Left IR sprite hide when the green flag is clicked, show when the message - left is received, and finally hide again. 4.21. 2.18 GAME - Don’t Tap on The White Tile...
Page 644
SunFounder ESP32 Starter Kit 5. Right IR sprite Copy the Left IR sprite and rename it to Right IR. Then change the receive message to - right. Chapter 4. Play with Scratch...
SunFounder ESP32 Starter Kit Now all the scripting is done and you can click on the green flag to run the script. 4.22 2.19 GAME - Protect Your Heart In this project, let’s make a game that tests reaction speed.
Page 646
SunFounder ESP32 Starter Kit Here the color of the rectangle box is controlled by the Line Tracking module. When the module is placed on a black surface (a surface that is reflective), the color of the rectangle box is black, otherwise it is white.
Page 647
SunFounder ESP32 Starter Kit 4.22.2 Build the Circuit This is a digital Line Tracking module, when a black line is detected, it outputs 1; when a white line is detected, it outputs a value of 0. In addition, you can adjust its sensing distance through the potentiometer on the module.
Page 648
SunFounder ESP32 Starter Kit Now stick a black electrical tape on the desktop, put the Line Track module at a height of 2cm from the desktop. With the sensor facing down, observe the signal LED on the module to make sure it lights up on the white table and goes off on the black tape.
Page 649
SunFounder ESP32 Starter Kit Go to the Square Box sprite’s Costumes page and set the black and white costumes. • Click the selection tool • Select the rectangle on the canvas • Select the fill color as black • and name the costume Black...
Page 650
SunFounder ESP32 Starter Kit Select the second costume, set the fill color to white, name it White, and delete the rest of the costume. Chapter 4. Play with Scratch...
Page 651
SunFounder ESP32 Starter Kit 2. Add Heart sprite Also add a Heart sprite, set its position to (0, 0), and shrink its size so that it appears to be located inside the Square Box. 4.22. 2.19 GAME - Protect Your Heart...
Page 652
SunFounder ESP32 Starter Kit On the Costumes page, adjust the heart purple costume so that it appears to be broken. 3. Add Arrow1 sprite Chapter 4. Play with Scratch...
Page 653
SunFounder ESP32 Starter Kit Add an Arrow1 sprite. On the Costumes page, keep and copy the rightward facing costume and set its color to black and white. 4. Scripting for Square Box sprite Go back to the Blocks page and script Square Box sprite.
Page 654
SunFounder ESP32 Starter Kit • So when the value of the digital pin 2 (Line Following module) is 1 (black line detected), then switch the costume to Black. • Otherwise toggle the costume to White. 5. Scripting for Heart sprite Heart sprite is protected inside Square Box, and by default is a red costume.
Page 655
SunFounder ESP32 Starter Kit 6. Scripting for Arrow1 sprite Make the Arrow1 sprite hide and create a clone when the green flag is clicked. 4.22. 2.19 GAME - Protect Your Heart...
Page 656
SunFounder ESP32 Starter Kit Create an [init] block to initialize the Arrow1 sprite’s position, orientation and color. It appears at a random location, and if the distance between it and the Heart sprite is less than 200, it moves outward until the distance is greater than 200.
Page 657
SunFounder ESP32 Starter Kit Set its direction to face the Heart sprite. 4.22. 2.19 GAME - Protect Your Heart...
Page 658
SunFounder ESP32 Starter Kit Make its color alternate randomly between black/white. • Variable color is 0, toggle costume to White. • Variable color is 1, toggles the outfit to Black. Chapter 4. Play with Scratch...
Page 659
SunFounder ESP32 Starter Kit Now let it start moving, it will move faster as the value of the variable level increases. 4.22. 2.19 GAME - Protect Your Heart...
Page 660
SunFounder ESP32 Starter Kit Now set its collision effect with the Square Box sprite. • If the Arrow1 sprite and the Square Box sprite have the same color (which will be modified according to the value of the Line Track module), either black or white, a new clone is created and the game continues.
Page 661
SunFounder ESP32 Starter Kit Note: The two [touch color()] blocks need to pick up the black/white costumes of Square Box separately. 4.22. 2.19 GAME - Protect Your Heart...
SunFounder ESP32 Starter Kit 4.23 2.20 GAME - Kill Dragon Here, we use the joystick to play a game of dragon killing. When clicking on green, the dragon will float up and down on the right side and blow fire intermittently. You need to use the joystick to control the movement of the magic wand and launch star attacks at the dragon, while avoiding the flames it shoots, and finally defeat it.
Page 663
SunFounder ESP32 Starter Kit 4.23.1 Required Components In this project, we need the following components. It’s definitely convenient to buy a whole kit, here’s the link: Name ITEMS IN THIS KIT LINK ESP32 Starter Kit 320+ You can also buy them separately from the links below.
Page 664
SunFounder ESP32 Starter Kit 4.23.2 Build the Circuit A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. Joysticks are often used to control video games and robots.
Page 665
SunFounder ESP32 Starter Kit 4.23.3 Programming 1. Dragon Woods backdrop added via the Choose a Backdrop button. • Delete the default sprite and add the Dragon sprite. • Go to the Costumes page and flip the dragon-b and dragon-c horizontally.
Page 666
SunFounder ESP32 Starter Kit • Set the size to 50%. Chapter 4. Play with Scratch...
Page 667
SunFounder ESP32 Starter Kit • Now create a variable - dragon to record the dragon’s life points, and set the initial value to 50. • Next, switch the sprite costume to dragon-b and have the Dragon sprite up and down in a range.
Page 668
SunFounder ESP32 Starter Kit • Add a Lightning sprite as the fire blown by the Dragon sprite. You need to rotate it 90° clockwise in the Costumes page, this is to make the Lightning sprite move in the right direction.
Page 669
SunFounder ESP32 Starter Kit • Then adjust the dragon-c costume of the Dragon sprite so that its center point should be at the tail of the fire. This will make the positions of the Dragon sprite and the Lightning sprite correct, and prevent Lightning from launching from the dragon’s feet.
Page 670
SunFounder ESP32 Starter Kit • Adjust the size and orientation of the Lightning sprite to make the image look more harmonious. Chapter 4. Play with Scratch...
Page 671
SunFounder ESP32 Starter Kit • Now script the Lightning sprite. This is easy, just have it follow the Dragon sprite all the time. At this point, click on the green flag and you will see Dragon moving around with lightning in its mouth.
Page 672
SunFounder ESP32 Starter Kit to create a clone for the Lightning sprite. • Click on the Lightning sprite and let the Lightning clone shoot out at a random angle, it will bounce off the wall and disappear after a certain amount of time.
Page 673
SunFounder ESP32 Starter Kit • In the Lightning sprite, hide its body and show the clone. Now the dragon can move up and down and blow out fire. 4.23. 2.20 GAME - Kill Dragon...
Page 674
SunFounder ESP32 Starter Kit 2.Wand • Create a Wand sprite and rotate its direction to 180 to point to the right. • Now create a variable hp to record its life value, initially set to 3. Then read the Joystick’s value, which is used to control the wand’s movement.
Page 675
SunFounder ESP32 Starter Kit • The dragon has lightning, and the wand that crushes it has its “magic bullet”! Create a Star sprite, resize it, and script it to always follow the Wand sprite, and limit the number of stars to three.
Page 676
SunFounder ESP32 Starter Kit • Make the Wand sprite shoot stars automatically. The Wand sprite shoots stars the same way the dragon blows fire – by creating clones. Chapter 4. Play with Scratch...
Page 677
SunFounder ESP32 Starter Kit • Go back to the Star sprite and script its clone to spin and shoot to the right, disappear after going beyond the stage and restoring the number of stars. Same as Lightning sprite, hide the body and show the clone.
Page 678
SunFounder ESP32 Starter Kit Now we have a wand that shoots star bullets. 3. Fight! The wand and the dragon are currently still at odds with each other, and we’re going to make them fight. The dragon is strong, and the wand is the brave man who crusades against the dragon. The interaction between them consists of the following parts.
Page 679
SunFounder ESP32 Starter Kit • If Lightning (a Lightning sprite clone) hits the Wand sprite, it will make a pop sound and disappear, and the Wand will lose life points. 4.23. 2.20 GAME - Kill Dragon...
Page 680
SunFounder ESP32 Starter Kit • If a Star (clone of the Star sprite) hits the Dragon, it will emit a collect sound and disappear, while restoring the Star count, and the Dragon will lose life points. Chapter 4. Play with Scratch...
Page 681
SunFounder ESP32 Starter Kit 4. stage The battle between the Wand and the Dragon will eventually be divided into winners and losers, which we represent with the stage. • Add Blue Sky backgdrop, and write the character “WIN!” on it to represent that the dragon has been defeated and the dawn has come.
Page 682
SunFounder ESP32 Starter Kit • And modify the blank backdrop as follows, to represent that the game has failed and everything will be in dark- ness. Chapter 4. Play with Scratch...
Page 683
SunFounder ESP32 Starter Kit • Now write a script to switch these backgdrops, when the green flag is clicked, switch to Woods backgdrop; if the dragon’s life point is less than 1 , then the game succeeds and switch the backdrop to Blue Sky; if the life value point of the Wand is less than 1, then switch to Night backdrop and the game fails.
Page 684
SunFounder ESP32 Starter Kit Chapter 4. Play with Scratch...
CHAPTER FIVE LEARN ABOUT THE COMPONENTS IN YOUR KIT After opening the package, please check whether the quantity of components is compliance with product description and whether all components are in good condition. Below is the introduction to each component, which contains the operating principle of the component and the corre- sponding projects.
SunFounder ESP32 Starter Kit 5.1 ESP32 WROOM 32E The ESP32 WROOM-32E is a versatile and powerful module built around Espressif’s ESP32 chipset. It offers dual-core processing, integrated Wi-Fi and Bluetooth connectivity, and boasts a wide range of peripheral interfaces. Known for its low-power consumption, the module is ideal for IoT applications, enabling smart connectivity and robust performance in compact form factors.
Page 687
5.1.1 Pinout Diagram The ESP32 has some pin usage limitations due to various functionalities sharing certain pins. When designing a project, it’s a good practice to carefully plan the pin usage and cross-check for potential conflicts to ensure proper functioning and avoid issues.
Page 688
Defaults to pull-down, IO0 and IO2 will make ESP32 enter download mode. IO12(MTDI) Defaults to pull-down, if pulled high, ESP32 will fail to boot up normally. IO15(MTDO) Defaults to pull-up, if pulled low, debug log will not be visible. Additionally, the voltage level of IO5 and IO15 affects the Timing of SDIO Slave.
We have designed an expansion board that enables you to fully utilize the camera and SD card functionalities of the ESP32 WROOM 32E. By combining the OV2640 camera, Micro SD, and ESP32 WROOM 32E, you get an all-in-one expansion board.
Page 690
– Screw Terminal: 3.5mm pitch 14pin screw terminal, ensuring stable wire connections and making it suitable for IoT projects. • Indicator Lights – PWR: Lights up when the battery is powered or when a Micro USB is directly plugged into the ESP32. Chapter 5. Learn about the Components in Your Kit...
Page 691
Pinout Diagram. However, when the ESP32 WROOM 32E is inserted into the extension board, some of its pins may also be used to drive the Micro SD card or a camera. Consequently, pull-up or pull-down resistors have be added to these pins. If you’re using these pins as inputs, it’s crucial to account for these resistors as they can affect input levels.
Page 692
WS2812 RGB Strip. 5.2.3 Interface Insertion Guide Upload Code When you need to upload code to the ESP32 WROOM 32E, connect it to your computer using a Micro USB cable. Chapter 5. Learn about the Components in Your Kit...
Page 693
SunFounder ESP32 Starter Kit Inserting the Micro SD Card Gently push in the Micro SD card to secure it in place. Pushing it again will eject it. 5.2. ESP32 Camera Extension...
Page 694
SunFounder ESP32 Starter Kit Attaching the Camera When connecting the camera, ensure the black stripe of the FPC cable is facing upwards and is fully inserted into the connector. Battery Power and Charging Carefully insert the battery cable into the battery port, avoiding applying too much force to prevent pushing up the battery terminal.
SunFounder ESP32 Starter Kit Basic 5.3 Breadboard What is a “solderless” breadboard? A breadboard is a rectangular plastic board with many small holes in it. These small holes allow you to easily insert electronic components to build circuits. Technically speaking, these breadboards are known as solderless breadboards because they do not require soldering to make connections.
Page 696
SunFounder ESP32 Starter Kit • Material: ABS Plastic Panel, Tin Plated Phosphor Bronze Contact Sheet. • Voltage / Current: 300V/3-5A. • With Self-Adhesive Tape on the Back What is in the breadboard? The inside of the breadboard is made up of rows of small metal clips. When you insert the leads of a component into the holes of the breadboard, one of the clips catches it.
Page 697
SunFounder ESP32 Starter Kit Most breadboards have some numbers, letters and plus and minus signs on them. Although the labels will vary from breadboard to breadboard, the function is basically the same. These labels allow you to find the corresponding holes more quickly when building your circuit.
Page 698
SunFounder ESP32 Starter Kit As shown in the diagram, each set of five holes in the middle section, columns A-E or F-J, is electrically connected. This means, for example, that hole A1 is electrically connected to holes B1, C1, D1 and E1.
SunFounder ESP32 Starter Kit breadboard. Components such as resistors, capacitors, switches, diodes, etc. can be inserted in any of the rows, but ICs need to be arranged across the middle gap. 5.4 Resistor Resistor is an electronic element that can limit the branch current. A fixed resistor is a kind of resistor whose resistance cannot be changed, while that of a potentiometer or a variable resistor can be adjusted.
Page 700
SunFounder ESP32 Starter Kit As shown in the card, each color stands for a number. Black Brown Orange Yellow Green Blue Violet Grey White Gold Silver 0.01 The 4- and 5-band resistors are frequently used, on which there are 4 and 5 chromatic bands.
Page 701
SunFounder ESP32 Starter Kit Therefore, you can observe the gap between the two chromatic bands at one end of the resistor; if it’s larger than any other band gaps, then you can read from the opposite side. Let’s see how to read the resistance value of a 5-band resistor as shown below.
SunFounder ESP32 Starter Kit 5.5 Capacitor Chapter 5. Learn about the Components in Your Kit...
Page 703
SunFounder ESP32 Starter Kit Capacitor, refers to the amount of charge storage under a given potential difference, denoted as C, and the international unit is farad (F). Generally speaking, electric charges move under force in an electric field. When there is a medium be- tween conductors, the movement of electric charges is hindered and the electric charges accumulate on the conductors, resulting in accumulation of electric charges.
SunFounder ESP32 Starter Kit 5.6 Jumper Wires Wires that connect two terminals are called jumper wires. There are various kinds of jumper wires. Here we focus on those used in breadboard. Among others, they are used to transfer electrical signals from anywhere on the breadboard to the input/output pins of a microcontroller.
SunFounder ESP32 Starter Kit 5.7 Transistor Transistor is a semiconductor device that controls current by current. It functions by amplifying weak signal to larger amplitude signal and is also used for non-contact switch. A transistor is a three-layer structure composed of P-type and N-type semiconductors. They form the three regions internally.
Page 706
SunFounder ESP32 Starter Kit When a High level signal goes through an NPN transistor, it is energized. But a PNP one needs a Low level signal to manage it. Both types of transistor are frequently used for contactless switches, just like in this experiment.
SunFounder ESP32 Starter Kit • (Arduino Project) 3.1 Beep • (Arduino Project) 6.1 Fruit Piano • (MicroPython Project) 5.6 Two Kinds of Transistors • (MicroPython Project) 3.2 Custom Tone • (MicroPython Project) 6.3 Light Theremin Chip 5.8 74HC595 Do you ever find yourself wanting to control a lot of LEDs, or just need more I/O pins to control buttons, sensors, and servos all at once? Well, you can connect a few sensors to Arduino pins, but you will soon start to run out of pins on the Arduino.
Page 708
SunFounder ESP32 Starter Kit • Q0-Q7: 8-bit parallel data output pins, able to control 8 LEDs or 8 pins of 7-segment display directly. • Q7’: Series output pin, connected to DS of another 74HC595 to connect multiple 74HC595s in series •...
Page 709
SunFounder ESP32 Starter Kit Working Principle When MR (pin10) is high level and OE (pin13) is low level, data is input in the rising edge of SHcp and goes to the memory register through the rising edge of STcp. • Shift Register –...
Page 710
SunFounder ESP32 Starter Kit • Storage Register – When the storage register is in the rising edge state, the data of the shift register will be transferred to the storage register. – The storage register is directly connected to the 8 output pins, Q0 ~ Q7 will be able to receive a byte of data.
SunFounder ESP32 Starter Kit 5.9 L293D L293D is a 4-channel motor driver integrated by chip with high voltage and high current. It’s designed to connect to standard DTL, TTL logic level, and drive inductive loads (such as relay coils, DC, Stepper Motors) and power switching transistors etc.
SunFounder ESP32 Starter Kit • L293D Datasheet Example • (Arduino Project) 4.1 Motor • (Arduino Project) 4.2 Pumping • (MicroPython Project) 4.1 Small Fan • (MicroPython Project) 4.2 Pumping • (Scratch Project) 2.9 Rotating Fan Display 5.10 LED What’s LED?
Page 714
SunFounder ESP32 Starter Kit LEDs are very common electronic devices that can be used to decorate your room during the festival, and you can also use them as indicators for various things, such as whether the power to your home appliances is on or off. They come in dozens of different shapes and sizes, and the most common are LEDs with through hole LEDs, which generally have long leads and can be plugged into a breadboard.
Page 715
SunFounder ESP32 Starter Kit Red, yellow, blue, green, and white are the most common LED colors, and the light emitted is usually the same color as the appearance. We rarely use LEDs that are transparent or matte in appearance, but the light emitted may be a color other than white.
Page 716
SunFounder ESP32 Starter Kit Forward Voltage The Forward Voltage is a very important parameter to know when using LEDs, as it determines how much power you use and how large the current limiting resistor should be. The Forward Voltage is the voltage that the LED needs to use when it lights up. For most red, yellow, orange and light green LEDs, they generally use a voltage between 1.9V and 2.1V.
Page 717
SunFounder ESP32 Starter Kit According to Ohm’s law, the current through this circuit decreases as the resistance increases, which causes the LED to dim. I = (Vp-Vl)/R To get the LEDs to light up safely and with the right brightness, how much resistance should we use in the circuit? For 99% of 5mm LEDs, the recommended current is 20mA, as you can see from the Conditions column of its data sheet.
Page 718
SunFounder ESP32 Starter Kit Now convert the above formula as shown below. R = (Vp-Vl)/I If Vp is 5V, Vl (Forward Voltage) is 2V, and I is 20mA, then R is 150. So we can make the LED brighter by reducing the resistance of the resistor, but it is not recommended to go below 150 (this resistance may not be very accurate, because different suppliers provide LEDs have differences).
SunFounder ESP32 Starter Kit 5.11 RGB LED RGB LEDs emit light in various colors. An RGB LED packages three LEDs of red, green, and blue into a transparent or semitransparent plastic shell. It can display various colors by changing the input voltage of the three pins and superimpose them, which, according to statistics, can create 16,777,216 different colors.
Page 720
SunFounder ESP32 Starter Kit • In a common cathode RGB LED, all three LEDs share a negative connection (cathode). • In a common anode RGB LED, the three LEDs share a positive connection (anode). Note: We use the common cathode one.
Page 721
SunFounder ESP32 Starter Kit each pin. Mix colors To generate additional colors, you can combine the three colors at different intensities. To adjust the intensity of each LED, you can use a PWM signal. Because the LEDs are so close to each other, our eyes see the result of the color combination rather than the three colors individually.
SunFounder ESP32 Starter Kit Example • (Arduino Project) 2.3 Colorful Light • (Arduino Project) 6.5 Color Gradient • (MicroPython Project) 2.3 Colorful Light • (Scratch Project) 2.3 Colorful Balls 5.12 7-segment Display A 7-segment display is an 8-shaped component which packages 7 LEDs. Each LED is called a segment - when ener- gized, one segment forms part of a numeral to be displayed.
Page 723
SunFounder ESP32 Starter Kit • The other LED pins are connected together forming a common pin. • So by forward biasing the appropriate pins of the LED segments in a particular order, some segments will brighten and others stay dim, thus showing the corresponding character on the display.
Page 724
SunFounder ESP32 Starter Kit How to Know CC or CA? Usually there will be label on the side of the 7-segment display, xxxAx or xxxBx. Generally speaking xxxAx stands for common cathode and xxxBx stands for common anode. Chapter 5. Learn about the Components in Your Kit...
Page 725
SunFounder ESP32 Starter Kit You can also use a multimeter to check the 7-segment display if there is no label. Set the multimeter to diode test mode and connect the black lead to the middle pin of the 7-segment display, and the red lead to any other pin except the middle one.
Page 726
SunFounder ESP32 Starter Kit components/img/7_segment_test.JPG Display Codes To help you get to know how 7-segment displays(Common Cathode) display Numbers, we have drawn the following table. Numbers are the number 0-F displayed on the 7-segment display; (DP) GFEDCBA refers to the corresponding LED set to 0 or 1.
Page 727
SunFounder ESP32 Starter Kit For example, 01011011 means that DP, F and C are set to 0, while others are set to 1. Therefore, the number 2 is displayed on the 7-segment display. 5.12. 7-segment Display...
SunFounder ESP32 Starter Kit Example • (Arduino Project) 2.5 7 Segment Display • (Arduino Project) 6.4 Digital Dice • (MicroPython Project) 2.5 Number Display • (MicroPython Project) 6.6 Digital Dice 5.13 I2C LCD1602 • GND: Ground • VCC: Voltage supply, 5V.
Page 729
SunFounder ESP32 Starter Kit As we all know, though LCD and some other displays greatly enrich the man-machine interaction, they share a common weakness. When they are connected to a controller, multiple IOs will be occupied of the controller which has no so many outer ports.
SunFounder ESP32 Starter Kit • Shorting Cap: Backlight can be enabled by this capunplugg this cap to disable the backlight. • Potentiometer: It is used to adjust the contrast (the clarity of the displayed text), which is increased in the clockwise direction and decreased in the counterclockwise direction.
SunFounder ESP32 Starter Kit • Color: Full color RGB • RGB Type5050RGBBuilt-in IC WS2812B • Light Strip Thickness: 2mm • Each LED can be controlled individually WS2812B Introdction • WS2812B Datasheet WS2812B is a intelligent control LED light source that the control circuit and RGB chip are integrated in a package of 5050 components.
SunFounder ESP32 Starter Kit As a type of electronic buzzer with an integrated structure, buzzers, which are supplied by DC power, are widely used in computers, printers, photocopiers, alarms, electronic toys, automotive electronic devices, telephones, timers and other electronic products or voice devices.
Page 733
SunFounder ESP32 Starter Kit Audio Amplifier Module contains a HXJ8002 audio power amplifier chip. This chip is a power amplifier with low power supply, that can provide 3W average audio power for a 3 BTL load with low harmonic distortion (under 10% threshold distortion at 1KHz) from a 5V DC power supply.
Page 734
SunFounder ESP32 Starter Kit • Impedance8ohm • Rate Input Power: 1.5W • Max Input Power: 2.0W • Wire Length: 10cm The size chart is as follows • 2030 Speaker Datasheet Example • (Arduino Project) 7.5 MP3 Player with SD Card Support •...
SunFounder ESP32 Starter Kit 5.17 DC Motor This is a 3V DC motor. When you give a high level and a low level to each of the 2 terminals, it will rotate. • Length: 25mm • Diameter: 21mm • Shaft Diameter: 2mm •...
Page 736
SunFounder ESP32 Starter Kit Current flows from the positive terminal of the battery through the circuit, through the copper brushes to the commuta- tor, and then to the armature. But because of the two gaps in the commutator, this flow reverses halfway through each complete rotation.
SunFounder ESP32 Starter Kit 5.18 Servo A servo is generally composed of the following parts: case, shaft, gear system, potentiometer, DC motor, and embedded board. It works like this: The microcontroller sends out PWM signals to the servo, and then the embedded board in the servo receives the signals through the signal pin and controls the motor inside to turn.
Page 738
SunFounder ESP32 Starter Kit Example • (Arduino Project) 4.3 Swinging Servo • (MicroPython Project) 4.3 Swinging Servo Chapter 5. Learn about the Components in Your Kit...
SunFounder ESP32 Starter Kit 5.19 Centrifugal Pump The centrifugal pump converts rotational kinetic energy into hydrodynamic energy to transport fluid. The rotation energy comes from the electric motor. The fluid enters the pump impeller along or near the rotating shaft, is accelerated by the impeller, flows radially outward into the diffuser or volute chamber, and then flows out from there.
SunFounder ESP32 Starter Kit • It is a submersible pump and should be used that way. It tends to heat too much that there’s a risk of overheating if you turn it on unsubmerged. Example • (Arduino Project) 4.2 Pumping •...
Page 741
SunFounder ESP32 Starter Kit Example • (Arduino Project) 5.1 Reading Button Value • (MicroPython Project) 5.1 Reading Button Value • (Scratch Project) 2.5 Doorbell • (Scratch Project) 2.14 GAME - Eat Apple • (Scratch Project) 2.17 GAME - Fishing 5.20. Button...
SunFounder ESP32 Starter Kit 5.21 Tilt Switch The tilt switch used here is a ball one with a metal ball inside. It is used to detect inclinations of a small angle. The principle is very simple. When the switch is tilted in a certain angle, the ball inside rolls down and touches the two contacts connected to the pins outside, thus triggering circuits.
SunFounder ESP32 Starter Kit • (Arduino Project) 5.2 Tilt It • (MicroPython Project) 5.2 Tilt It 5.22 Potentiometer Potentiometer is also a resistance component with 3 terminals and its resistance value can be adjusted according to some regular variation. Potentiometers come in various shapes, sizes, and values, but they all have the following things in common: •...
SunFounder ESP32 Starter Kit Potentiometer is a continuously adjustable resistor. When you adjust the shaft or sliding handle of the potentiometer, the movable contact will slide on the resistor. At this point, a voltage can be output depending on the voltage applied onto the potentiometer and the angle the movable arm has rotated to or the travel it has made.
Page 745
SunFounder ESP32 Starter Kit In order to communicate a full range of motion to the computer, a joystick needs to measure the stick’s position on two axes - the X-axis (left to right) and the Y-axis (up and down). Just as in basic geometry, the X-Y coordinates pinpoint the stick’s position exactly.
SunFounder ESP32 Starter Kit 5.24 IR Receiver IR Receiver • OUT: Signal output • GND: GND • VCC: power supply, 3.3v~5V SL838 infrared-receiver is a component which receives infrared signals and can independently receive infrared rays and output signals compatible with TTL level. It is similar with a normal plastic-packaged transistor in size and is suitable for all kinds of infrared remote control and infrared transmission.
Page 747
SunFounder ESP32 Starter Kit This is a Mini thin infrared wireless remote control with 21 function buttons and a transmitting distance of up to 8 meters, which is suitable for operating a wide range of devices in a kid’s room.
SunFounder ESP32 Starter Kit 5.25 Photoresistor A photoresistor or photocell is a light-controlled variable resistor. The resistance of a photoresistor decreases with increasing incident light intensity; in other words, it exhibits photo conductivity. A photoresistor can be applied in light-sensitive detector circuits and light-activated and dark-activated switching cir- cuits acting as a resistance semiconductor.
SunFounder ESP32 Starter Kit 5.26 Thermistor A thermistor is a type of resistor whose resistance is strongly dependent on temperature, more so than in standard resistors. The word is a combination of thermal and resistor. Thermistors are widely used as inrush current limiters, temperature sensors (negative temperature coefficient or NTC type typically), self-resetting overcurrent protectors, and self-regulating heating elements (positive temperature coefficient or PTC type typically).
SunFounder ESP32 Starter Kit • RN is the resistance of the NTC thermistor under the rated temperature TN. Here, the numerical value of RN is 10k. • TK is a Kelvin temperature and the unit is K. Here, the numerical value of TK is 273.15 + degree Celsius.
Page 751
SunFounder ESP32 Starter Kit Features 1. Humidity measurement range: 20 - 90%RH 2. Temperature measurement range: 0 - 60℃ 3. Output digital signals indicating temperature and humidity 4. Working voltage:DC 5V; PCB size: 2.0 x 2.0 cm 5. Humidity measurement accuracy: 5%RH 6.
SunFounder ESP32 Starter Kit 5.28 PIR Motion Sensor Module The PIR sensor detects infrared heat radiation that can be used to detect the presence of organisms that emit infrared heat radiation. The PIR sensor is split into two slots that are connected to a differential amplifier. Whenever a stationary object is in front of the sensor, the two slots receive the same amount of radiation and the output is zero.
Page 753
SunFounder ESP32 Starter Kit Distance Adjustment Turning the knob of the distance adjustment potentiometer clockwise, the range of sensing distance increases, and the maximum sensing distance range is about 0-7 meters. If turn it anticlockwise, the range of sensing distance is reduced, and the minimum sensing distance range is about 0-3 meters.
SunFounder ESP32 Starter Kit 5.29 Line Tracking Module • S: Usually low level, high level when the black line is detected. • V+Power supply, 3.3v~5V • G: Ground This is a 1-channel Line Tracking module which, as the name suggests, tracks black lines on a white background or white lines against a black background.
SunFounder ESP32 Starter Kit • Operating voltage: 3.3V-5V • Digital output: 0 (white) and 1 (black) • Uses wide voltage LM393 comparator. • Size: 42mmx10mm Example • (Arduino Project) 5.4 Detect the Line • (MicroPython Project) 5.4 Detect the Line •...
Page 756
SunFounder ESP32 Starter Kit There is a fixed frequency oscillator, which is built with a 555 timer IC. The generated square wave is then fed to the sensor like a capacitor. However, for the square wave signal, the capacitor has a certain reactance or, for the sake of argument, a resistor with a pure ohmic resistor (10k resistor on pin 3) to form a voltage divider.
SunFounder ESP32 Starter Kit • (Arduino Project) 5.3 Detect the Obstacle • (MicroPython Project) 5.3 Detect the Obstacle • (Scratch Project) 2.11 GAME - Shooting • (Scratch Project) 2.18 GAME - Don’t Tap on The White Tile 5.32 Ultrasonic Module •...
Page 759
SunFounder ESP32 Starter Kit • Using IO trigger for at least 10us high level signal. • The module sends an 8 cycle burst of ultrasound at 40 kHz and detects whether a pulse signal is received. • Echo will output a high level if a signal is returned; the duration of the high level is the time from emission to return.
Page 760
SunFounder ESP32 Starter Kit Chapter 5. Learn about the Components in Your Kit...
CHAPTER 6.1 How to use Blynk on mobile device? Note: As datastreams can only be created in Blynk on the web, you will need to reference different projects to create datastreams on the web, then follow the tutorial below to create widgets in Blynk on your mobile device. 1.
Page 762
SunFounder ESP32 Starter Kit 7. Now you will see a Joystick widget appear in the blank area, click on it. 8. Joystick Settings will appear, select the Xvalue and Yvalue datastreams you just set in the web page. Note that each widget corresponds to a different datastream in each project.
SunFounder ESP32 Starter Kit 6.2 How to format the SD card? The steps to ensure your SD card is formatted correctly may vary depending on your operating system. Here are simple steps on how to format an SD card in Windows, MacOS, and Linux: Windows 1.
Page 764
SunFounder ESP32 Starter Kit MacOS 1. Insert your SD card into the computer. Open the “Disk Utility” application (can be found in the “Utilities” folder). 2. Select your SD card from the list on the left and then click “Erase”.
Page 765
SunFounder ESP32 Starter Kit 4. Finally, wait for the formatting to complete. Linux • First, insert your SD card and then open a terminal. • Type lsblk and find your SD card’s name in the device list (e.g., it may be sdb).
When plugging the ESP32 into the computer, the Arduino IDE often displays Unknown COMxx. Why does this happen? This is because the USB driver for ESP32 is different from the regular Arduino Boards. The Arduino IDE can’t automatically recognize this board.
Page 767
SunFounder ESP32 Starter Kit 3. Now, you should be able to see your board and port in this quick view window. 6.3. Always displaying “Unknown COMxx”?
CHAPTER SEVEN THANK YOU Thanks to the evaluators who evaluated our products, the veterans who provided suggestions for the tutorial, and the users who have been following and supporting us. Your valuable suggestions to us are our motivation to provide better products! Particular Thanks •...
EIGHT COPYRIGHT NOTICE All contents including but not limited to texts, images, and code in this manual are owned by the SunFounder Company. You should only use it for personal study, investigation, enjoyment, or other non-commercial or nonprofit purposes, under the related regulations and copyrights laws, without infringing the legal rights of the author and relevant right holders.
Need help?
Do you have a question about the ESP32 and is the answer not in the manual?
Questions and answers