Advertisement

█ www.freenove.com
Important Information
Thank you for choosing Freenove products!
Getting Started
First, please read the Start Here.pdf document in the unzipped folder you created.
If you have not yet downloaded the zip file, associated with this kit, please do so now and unzip it.
Get Support and Offer Input
Freenove provides free and responsive product and technical support, including but not limited to:
Product quality issues
Product use and build issues
Questions regarding the technology employed in our products for learning and education
Your input and opinions are always welcome
We also encourage your ideas and suggestions for new products and product improvements
For any of the above, you may send us an email to:
support@freenove.com
Safety and Precautions
Please follow the following safety precautions when using or storing this product:
Keep this product out of the reach of children under 6 years old.
This product should be used only when there is adult supervision present as young children lack
necessary judgment regarding safety and the consequences of product misuse.
This product contains small parts and parts, which are sharp. This product contains electrically conductive
parts. Use caution with electrically conductive parts near or around power supplies, batteries and
powered (live) circuits.
When the product is turned ON, activated or tested, some parts will move or rotate. To avoid injuries
to hands and fingers keep them away from any moving parts!
It is possible that an improperly connected or shorted circuit may cause overheating. Should this happen,
immediately disconnect the power supply or remove the batteries and do not touch anything until
it cools down! When everything is safe and cool, review the product tutorial to identify the cause.
Only operate the product in accordance with the instructions and guidelines of this tutorial, otherwise
parts may be damaged or you could be injured.
Store the product in a cool dry place and avoid exposing the product to direct sunlight.
After use, always turn the power OFF and remove or unplug the batteries before storing.
 support@freenove.com
Any concerns?

Advertisement

Table of Contents
loading
Need help?

Need help?

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

Questions and answers

Summary of Contents for Freenove ESP32-S3

  • Page 1 If you have not yet downloaded the zip file, associated with this kit, please do so now and unzip it. Get Support and Offer Input Freenove provides free and responsive product and technical support, including but not limited to: ...
  • Page 2 This means you can use these resource in your own derived works, in part or completely but NOT for the intent or purpose of commercial use. Freenove brand and logo are copyright of Freenove Creative Technology Co., Ltd. and cannot be used without written permission.
  • Page 3: Table Of Contents

    Preface █ www.freenove.com Contents Important Information ............1 Contents ................. 1 Preface ..................3 ESP32-S3 WROOM .................................. 4 CH343 (Importance) ................................. 6 Programming Software ................................. 18 Environment Configuration ..............................21 Notes for GPIO ..................................24 Chapter 1 LED ..............27 Project 1.1 Blink ..................................
  • Page 4 Preface www.freenove.com █ What’s next? ..............140 End of the Tutorial ............140  support@freenove.com Any concerns?
  • Page 5: Preface

    Internet and used as an Internet of Things device. ESP32-S3 can be developed using the Arduino platform, which will definitely make it easier for people who have learned arduino to master. Moreover, the code of ESP32-S3 is completely open-source, so beginners can quickly learn how to develop and design IOT smart household products including smart curtains, fans, lamps and clocks.
  • Page 6: Esp32-S3 Wroom

    PCB on-board antenna IPEX antenna In this tutorial, the ESP32-S3 WROOM is designed based on the PCB on-board antenna-packaged ESP32- S3-WROOM-1 module. ESP32-S3 WROOM  support@freenove.com...
  • Page 7 █ www.freenove.com The hardware interfaces of ESP32-S3 WROOM are distributed as follows: Compare the left and right images. We've boxed off the resources on the ESP32-S3 WROOM in different colors to facilitate your understanding of the ESP32-S3 WROOM. Box color...
  • Page 8: Ch343 (Importance)

    Preface www.freenove.com █ CH343 (Importance) ESP32-S3 WROOM uses CH343 to download codes. So before using it, we need to install CH343 driver in our computers. Windows Check whether CH343 has been installed Connect your computer and ESP32-S3 WROOM with a USB cable.
  • Page 9 Preface █ www.freenove.com Click “Device Manager”. If your computer has installed CH343, you can see“USB-Enhances-SERIAL CH343 (COMx)”. And you can click here to move to the next step. CH343 Port Installing CH343 First, download CH343 driver, click http://www.wch-ic.com/search?t=all&q=ch343 to download the appropriate one based on your operating system.
  • Page 10 Preface www.freenove.com █ Windows If you would not like to download the installation package, you can open “Freenove_ESP32_S3_WROVER_Board/CH343”, we have prepared the installation package.  support@freenove.com Any concerns?
  • Page 11 Preface █ www.freenove.com Open the folder “Freenove_ESP32_S3_WROVER_Board/CH343/Windows/” Double click “CH343SER.EXE”.  support@freenove.com Any concerns?
  • Page 12 Preface www.freenove.com █ Click “INSTALL” and wait for the installation to complete. Install successfully. Close all interfaces.  support@freenove.com Any concerns?
  • Page 13 Preface █ www.freenove.com When ESP32-S3 WROOM is connected to computer, select “This PC”, right-click to select “Manage” and click “Device Manager” in the newly pop-up dialog box, and you can see the following interface. So far, CH343 has been installed successfully. Close all dialog boxes.
  • Page 14 Preface www.freenove.com █ First, download CH343 driver, click http://www.wch-ic.com/search?t=all&q=ch343 to download the appropriate one based on your operating system. Windows If you would not like to download the installation package, you can open “Freenove_ESP32_S3_WROVER_Board/CH343”, we have prepared the installation package.
  • Page 15 Preface █ www.freenove.com Run it. Third, click Continue. Fourth, click Install.  support@freenove.com Any concerns?
  • Page 16 Preface www.freenove.com █  support@freenove.com Any concerns?
  • Page 17 Preface █ www.freenove.com Then, waiting Finsh. Finally, restart your PC.  support@freenove.com Any concerns?
  • Page 18 Preface www.freenove.com █  support@freenove.com Any concerns?
  • Page 19 Preface █ www.freenove.com If you still haven't installed the CH340 by following the steps above, you can view readme.pdf to install it. ReadMe  support@freenove.com Any concerns?
  • Page 20: Programming Software

    Preface www.freenove.com █ Programming Software Arduino Software (IDE) is used to write and upload the code for Arduino Board. First, install Arduino Software (IDE): visit https://www.arduino.cc, click "Download" to enter the download page. Select and download corresponding installer according to your operating system. If you are a windows user, please select the "Windows Installer"...
  • Page 21 Preface █ www.freenove.com The interface of Arduino Software is as follows: Menus Toolbar Text editor Message area Console Configured board and serial port  support@freenove.com Any concerns?
  • Page 22 Preface www.freenove.com █ Programs written with Arduino Software (IDE) are called sketches. These sketches are written in the text editor and saved with the file extension.ino. The editor has features for cutting/pasting and searching/replacing text. The message area gives feedback while saving and exporting and also displays errors.
  • Page 23: Environment Configuration

    Preface █ www.freenove.com Environment Configuration First, open the software platform arduino, and then click File in Menus and select Preferences. Second, click on the symbol behind "Additional Boards Manager URLs"  support@freenove.com Any concerns?
  • Page 24 Preface www.freenove.com █ Third, fill in https://raw.githubusercontent.com/espressif/arduino-esp32/gh- pages/package_esp32_index.json in the new window, click OK, and click OK on the Preferences window again. Fourth, click "Boards Manager". Enter “esp32” in Boards manager and select 2.0.5,Then click “INSTALL”.  support@freenove.com Any concerns?
  • Page 25 Arduinowill download these files automaticly. Wait for the installation to complete. When finishing installation, click Tools in the Menus again and select Board: "Arduino Uno", and then you can see information of ESP32. click "ESP32-S3 Dev Module" so that the ESP32-S3 programming development environment is configured.
  • Page 26: Notes For Gpio

    Notes for GPIO Strapping Pin There are four Strapping pins for ESP32-S3:GPIO0、GPIO45、GPIO46、GPIO3。 With the release of the chip's system reset (power-on reset, RTC watchdog reset, undervoltage reset), the strapping pins sample the level and store it in the latch as "0" or "1" ", and keep it until the chip is powered off or turned off.
  • Page 27 The module on the ESP32-S3-WROOM board uses the ESP32-S3R8 chip with 8MB of external Flash. When we use the OPI PSRAM, please note that the GPIO35-GPIO37 on the ESP32-S3-WROOM board will not be available for other purposes. When OPI PSRAM is not used, GPIO35-GPIO37 on the board can be used as normal GPIO.
  • Page 28 █ Cam Pin When using the camera of our ESP32-S3 WROOM, please check the pins of it. Pins with underlined numbers are used by the camera function, if you want to use other functions besides it, please avoid using them.
  • Page 29: Chapter 1 Led

    In the whole tutorial, we don’t use T extension to power ESP32-S3 WROOM. So 5V and 3.3V (includeing EXT 3.3V) on the extension board are provided by ESP32-S3 WROOM. We can also use DC jack of extension board to power ESP32-S3 WROOM. In this way, 5v and EXT 3.3v on extension board are provided by external power resource.
  • Page 30 █ Sketch According to the circuit, when the GPIO2 of ESP32-S3 WROOM output level is high, the LED turns ON. Conversely, when the GPIO2 ESP32-S3 WROOM output level is low, the LED turns OFF. Therefore, we can let GPIO2 circularly output high and low level to make the LED blink.
  • Page 31 Note that the computer port number of each user may be different. Please select the correct serial port according to your computer. Taking the window system as an example, my computer recognizes that the communication interface of the ESP32-S3-WROOM is COM3, so I select COM3.  support@freenove.com...
  • Page 32 Chapter 1 LED www.freenove.com █ Note: For macOS users, if the uploading fails, please set the baud rate to 115200 before clicking “Upload Using Programmer”.  support@freenove.com Any concerns?
  • Page 33 █ www.freenove.com Click the Upload button and it will compile and upload the Sketch to the ESP32-S3-WROOM. Wait for the Sketch upload to complete, and observe the ESP32-S3-WROOM. You can see that the blue LED (IO2) on the board flashes cyclically.
  • Page 34 Chapter 1 LED www.freenove.com █ Option 2: Connect ESP32-S3 WROOM to computer. Open Arduino IDE 2.0.0. Click Tools->Upload Mode. Select USB-OTG CDC(TinyUSB).  support@freenove.com Any concerns?
  • Page 35 ESP32-S3-WROOM is COM25, so I select COM25. Click the Upload button and it will compile and upload the Sketch to the ESP32-S3-WROOM. Wait for the Sketch upload to complete, and observe the ESP32-S3-WROOM. You can see that the blue  support@freenove.com Any concerns?
  • Page 36 Chapter 1 LED www.freenove.com █ LED (IO2) on the board flashes cyclically. Sketch_01.1_Blink The following is the program code: #define LED_BUILTIN 2 // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin LED_BUILTIN as an output.
  • Page 37 Reset operation will lead the code to be executed from the beginning. Switching on the power, finishing uploading the code and pressing the reset button will trigger reset operation. In the circuit, ESP32-S3 WROOM's GPIO2 is connected to the LED, so the LED pin is defined as 2. #define...
  • Page 38: Chapter 2 Serial Communication

    Serial Communication is a means of communication between different devices/devices. This section describes ESP32-S3’s Serial Communication. Project 2.1 Serial Print This project uses ESP32-S3’s serial communicator to send data to the computer and print it on the serial monitor. Component List...
  • Page 39 USB cable, choose the correct device, and then click the Serial Monitor icon to open the Serial Monitor window. Interface of serial monitor window is as follows. If you can't open it, make sure Freenove ESP32-S3 has been connected to the computer, and choose the right serial port in the menu bar "Tools".
  • Page 40 Connect Freenove ESP32-S3 to the computer with USB cable. Sketch Sketch_02.1_SerialPrinter Download the code to ESP32-S3 WROOM, open the serial port monitor, set the baud rate to 115200, and press the reset button. As shown in the following figure:  support@freenove.com...
  • Page 41 Chapter 2 Serial Communication █ www.freenove.com As shown in the image above, "ESP32-S3 initialization completed! " The previous is the printing message when the system is started. The user program is then printed at a baud rate of 115200. The following is the program code:...
  • Page 42: Project 2.2 Serial Read And Write

    █ Project 2.2 Serial Read and Write From last section, we use serial port on Freenove ESP32-S3 to send data to a computer, now we will use that to receive data from computer. Component and circuit are the same as in the previous project.
  • Page 43 Chapter 2 Serial Communication █ www.freenove.com The following is the program code: String inputString = ""; //a String to hold incoming data bool stringComplete = false; // whether the string is complete void setup() { Serial.begin(115200); Serial.println(String("\nESP32S3 initialization completed! \r\n") String("Please input some...
  • Page 44: Chapter 3 Bluetooth

    When they are making data interaction, the Bluetooth device in master mode searches and selects devices nearby to connect to. When establishing connection, they can exchange data. When mobile phones exchange data with ESP32-S3, they are usually in master mode and ESP32-S3 in slave mode.  support@freenove.com...
  • Page 45 Chapter 3 Bluetooth █ www.freenove.com Circuit Connect Freenove ESP32-S3 to the computer using the USB cable.  support@freenove.com Any concerns?
  • Page 46 Chapter 3 Bluetooth www.freenove.com █ Sketch Lightblue If you can't install Serial Bluetooth on your phone, try LightBlue.If you do not have this software installed on your phone, you can refer to this link: https://apps.apple.com/us/app/lightblue/id557428110#?platform=iphone.  support@freenove.com Any concerns?
  • Page 47 Chapter 3 Bluetooth █ www.freenove.com Step1. Upload the code of Project 3.1 to ESP32-S3. Step2. Click on serial monitor. Step3. Set baud rate to 115200.  support@freenove.com Any concerns?
  • Page 48 Chapter 3 Bluetooth www.freenove.com █ Turn ON Bluetooth on your phone, and open the Lightblue APP. In the Scan page, swipe down to refresh the name of Bluetooth that the phone searches for. Click ESP32S3_Bluetooth. Receive Click “Receive”. Select the appropriate Data format in the box to the right of Data Format. For example, HEX for hexadecimal, utf-string for character, Binary for Binary, etc.
  • Page 49 Chapter 3 Bluetooth █ www.freenove.com Back to the serial monitor on your computer. You can type anything in the left border of Send, and then click Send. And then you can see the mobile Bluetooth has received the message.  support@freenove.com...
  • Page 50 Chapter 3 Bluetooth www.freenove.com █ Similarly, you can select “Send” on your phone. Set Data format, and then enter anything in the sending box and click Write to send. Send And the computer will receive the message from the mobile Bluetooth.
  • Page 51 Chapter 3 Bluetooth █ www.freenove.com  support@freenove.com Any concerns?
  • Page 52 Chapter 3 Bluetooth www.freenove.com █ And now data can be transferred between your mobile phone and computer via ESP32-S3 WROOM. The following is the program code: #include <BLEDevice.h> #include <BLEServer.h> #include <BLEUtils.h> #include <BLE2902.h> #include <String.h> BLECharacteristic *pCharacteristic; bool deviceConnected = false;...
  • Page 53 Chapter 3 Bluetooth █ www.freenove.com BLEService *pService = pServer->createService(SERVICE_UUID); pCharacteristic= pService->createCharacteristic(CHARACTERISTIC_UUID_TX,BLECharacteristic::PROPERTY_NOTIFY); pCharacteristic->addDescriptor(new BLE2902()); BLECharacteristic *pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX,BLECharacteristic::PROPERTY_WRITE); pCharacteristic->setCallbacks(new MyCallbacks()); pService->start(); pServer->getAdvertising()->start(); Serial.println("Waiting a client connection to notify..."); void setup() { Serial.begin(9600); setupBLE("ESP32S3_Bluetooth"); void loop() { long now = millis(); (now - lastMsg > 1000) { (deviceConnected&&rxload.length()>0) {...
  • Page 54 { deviceConnected = true; void onDisconnect(BLEServer* pServer) { deviceConnected = false; Write Callback function with BLE features. When it is called, as the mobile terminal send data to ESP32-S3, it will store them into reload. class MyCallbacks: public...
  • Page 55 Chapter 3 Bluetooth █ www.freenove.com The design for creating the BLE server is: 1. Create a BLE Server 2. Create a BLE Service 3. Create a BLE Characteristic on the Service 4. Create a BLE Descriptor on the characteristic 5. Start the service.
  • Page 56: Chapter 4 Read And Write The Sdcard

    SD card read and write method ESP32-S3 has two ways to use SD card, one is to use the SPI interface to access the SD card, and the other is to use the SDMMC interface to access the SD card. SPI mode uses 4 IOs to access SD card. The SDMMC has one-bit bus mode and four-bit bus mode.
  • Page 57 Chapter 4 Read and Write the SDcard █ www.freenove.com Format SD card Before starting the tutorial, we need to create a drive letter for the blank SD card and format it. This step requires a card reader and SD card. Please prepare them in advance. Below we will guide you to do it on different computer systems.
  • Page 58 Chapter 4 Read and Write the SDcard www.freenove.com █ In the new pop-up window, find an unallocated volume close to 1G in size. Click to select the volume, right-click and select "New Simple Volume". Click Next.  support@freenove.com Any concerns?
  • Page 59 Chapter 4 Read and Write the SDcard █ www.freenove.com You can choose the drive letter on the right, or you can choose the default. By default, just click Next. File system is FAT(or FAT32). The Allocation unit size is 16K, and the Volume label can be set to any name.
  • Page 60 Chapter 4 Read and Write the SDcard www.freenove.com █ Click Finish. Wait for the SD card initialization to complete. At this point, you can see the SD card in This PC. Insert the SD card into the card reader, then insert the card reader into the computer. Some computers will prompt the following information, please click to ignore it.
  • Page 61 Chapter 4 Read and Write the SDcard █ www.freenove.com Select "Generic MassStorageClass Media", note that its size is about 1G. Please do not choose wrong item. Click "Erase". Select the configuration as shown in the figure below, and then click "Erase".
  • Page 62 "SD". Circuit Before connecting the USB cable, insert the SD card into the SD card slot on the back of the ESP32-S3. Connect Freenove ESP32-S3 to the computer using the USB cable.
  • Page 63 Chapter 4 Read and Write the SDcard █ www.freenove.com Sketch Sketch_04.1_SDMMC_Test Compile and upload the code to ESP32-S3-WROOM, open the serial monitor, and press the RST button on the board.  support@freenove.com Any concerns?
  • Page 64 Chapter 4 Read and Write the SDcard www.freenove.com █ You can see the printout as shown below.  support@freenove.com Any concerns?
  • Page 65 Chapter 4 Read and Write the SDcard █ www.freenove.com The following is the program code: #include "sd_read_write.h" #include "SD_MMC.h" #define SD_MMC_CMD //Please do not modify it. #define SD_MMC_CLK //Please do not modify it. #define SD_MMC_D0 //Please do not modify it.
  • Page 66 Chapter 4 Read and Write the SDcard www.freenove.com █ readFile(SD_MMC, "/hello.txt"); deleteFile(SD_MMC, "/foo.txt"); renameFile(SD_MMC, "/hello.txt", "/foo.txt"); readFile(SD_MMC, "/foo.txt"); testFileIO(SD_MMC, "/test.txt"); Serial.printf("Total space: %lluMB\r\n", SD_MMC.totalBytes() / (1024 * 1024)); Serial.printf("Used space: %lluMB\r\n", SD_MMC.usedBytes() / (1024 * 1024)); void loop(){ delay(10000); Add the SD card drive header file.
  • Page 67 Chapter 4 Read and Write the SDcard █ www.freenove.com else Serial.println("UNKNOWN"); Call the listDir() function to read the folder and file names in the SD card, and print them out through the serial port. This function can be found in "sd_read_write.cpp".
  • Page 68: Chapter 5 Wifi Working Modes

    Component knowledge Station mode When ESP32-S3 selects Station mode, it acts as a WiFi client. It can connect to the router network and communicate with other devices on the router via WiFi connection. As shown below, the PC is connected to the router, and if ESP32-S3 wants to communicate with the PC, it needs to be connected to the router.
  • Page 69 Chapter 5 WiFi Working Modes █ www.freenove.com Circuit Connect Freenove ESP32-S3 to the computer using the USB cable.  support@freenove.com Any concerns?
  • Page 70 Chapter 5 WiFi Working Modes www.freenove.com █ Sketch Sketch_05.1_Station_mode Enter the correct Router name and password. Because the names and passwords of routers in various places are different, before the Sketch runs, users need to enter the correct router’s name and password in the box as shown in the illustration above.
  • Page 71 Chapter 5 WiFi Working Modes █ www.freenove.com When ESP32-S3 WROOM successfully connects to “ssid_Router”, serial monitor will print out the IP address assigned to ESP32-S3 WROOM by the router. The following is the program code: #include <WiFi.h> const char *ssid_Router = "********";...
  • Page 72 WiFi hotspot channel number; communicating through specified channel; optional parameter bssid: mac address of WiFi hotspot, optional parameter connect: blloean optional parameter, defaulting to true. If set as false, then ESP32-S3 won't connect WiFi. config(local_ip, gateway, subnet, dns1, dns2): set static local IP address.
  • Page 73: Project 5.2 Ap Mode

    When ESP32-S3 selects AP mode, it creates a hotspot network that is separate from the Internet and waits for other WiFi devices to connect. As shown in the figure below, ESP32-S3 is used as a hotspot. If a mobile phone or PC wants to communicate with ESP32-S3, it must be connected to the hotspot of ESP32-S3. Only after a connection is established with ESP32-S3 can they communicate.
  • Page 74 Set a name and a password for ESP32S3 AP. Before the Sketch runs, you can make any changes to the AP name and password for ESP32-S3 in the box as shown in the illustration above. Of course, you can leave it alone by default.
  • Page 75 When observing the print information of the serial monitor, turn on the WiFi scanning function of your phone, and you can see the ssid_AP on ESP32-S3, which is called "WiFi_Name" in this Sketch. You can enter the password "12345678" to connect it or change its AP name and password by modifying Sketch.
  • Page 76 Set ESP32-S3 in AP mode. WiFi.mode(WIFI_AP); Configure IP address, gateway and subnet mask for ESP32-S3. WiFi.softAPConfig(local_IP, gateway, subnet) Turn on an AP in ESP32-S3, whose name is set by ssid_AP and password is set by password_AP. WiFi.softAP(ssid_AP, password_AP);  support@freenove.com Any concerns?
  • Page 77 Chapter 5 WiFi Working Modes █ www.freenove.com Check whether the AP is turned on successfully. If yes, print out IP and MAC address of AP established by ESP32-S3. If no, print out the failure prompt. if(result){ Serial.println("Ready"); Serial.println(String("Soft-AP IP address = ")
  • Page 78: Project 5.3 Ap+Station Mode

    Component knowledge AP+Station mode In addition to AP mode and station mode, ESP32-S3 can also use AP mode and station mode at the same time. This mode contains the functions of the previous two modes. Turn on ESP32-S3's station mode, connect it to the router network, and it can communicate with the Internet via the router.
  • Page 79 Chapter 5 WiFi Working Modes █ www.freenove.com Circuit Connect Freenove ESP32-S3 to the computer using the USB cable. Sketch Sketch_05.3_AP_Station_mode Please enter the correct names and passwords of Router and AP. It is analogous to Project 5.1 and Project 5.2. Before running the Sketch, you need to modify ssid_Router, password_Router, ssid_AP and password_AP shown in the box of the illustration above.
  • Page 80 After making sure that Sketch is modified correctly, compile and upload codes to ESP32-S3 WROOM, open serial monitor and set baud rate to 115200. And then it will display as follows: When observing the print information of the serial monitor, turn on the WiFi scanning function of your phone, and you can see the ssid_AP on ESP32-S3.
  • Page 81 Chapter 5 WiFi Working Modes █ www.freenove.com WiFi.disconnect(); WiFi.mode(WIFI_AP); Serial.println("Setting soft-AP ... "); boolean result = WiFi.softAP(ssid_AP, password_AP); if(result){ Serial.println("Ready"); Serial.println(String("Soft-AP IP address = ") WiFi.softAPIP().toString()); Serial.println(String("MAC address = ") WiFi.softAPmacAddress().c_str()); }else{ Serial.println("Failed!"); Serial.println("\nSetting Station configuration ... "); WiFi.begin(ssid_Router, password_Router);...
  • Page 82: Chapter 6 Tcp/Ip

    There are two roles in TCP/IP communication, namely Server and Client, which will be implemented respectively with two projects in this chapter. Project 6.1 As Client In this section, ESP32-S3 is used as Client to connect Server on the same LAN and communicate with it. Component List ESP32-S3 WROOM x1...
  • Page 83 Chapter 6 TCP/IP █ www.freenove.com the first handshake the second handshake the third handshake TCP is a connection-oriented, low-level transmission control protocol. After TCP establishes a connection, the client and server can send and receive messages to each other, and the connection will always exist as long as the client or server does not initiate disconnection.
  • Page 84 Chapter 6 TCP/IP www.freenove.com █ Install Processing In this tutorial, we use Processing to build a simple TCP/IP communication platform. If you've not installed Processing, you can download it by clicking https://processing.org/download/. You can choose an appropriate version to download according to your PC system.
  • Page 85 Chapter 6 TCP/IP █ www.freenove.com Use Server mode for communication Install ControlP5.  support@freenove.com Any concerns?
  • Page 86 Chapter 6 TCP/IP www.freenove.com █ Open the “Freenove_ESP32_S3_WROVER_Board\Sketches\Sketches\Sketch_06.1_WiFiClient\ sketchWiFi\sketchWiFi.pde”, and click "Run". Stop The new pop-up interface is as follows. If ESP32-S3 is used as client, select TCP SERVER mode for sketchWiFi. Server mode Receiving Local IP address Local port...
  • Page 87 Chapter 6 TCP/IP █ www.freenove.com If ESP32-S3 serves as server, select TCP CLIENT mode for sketchWiFi. Client mode Remote IP address Remote port number When sketchWiFi selects TCP CLIENT mode, the LOCAL IP and LOCAL PORT of sketchWiFi need to be changed according to the IP address and port number printed by the serial monitor.
  • Page 88 Chapter 6 TCP/IP www.freenove.com █ Circuit Connect Freenove ESP32-S3 to the computer using the USB cable. Sketch Before running the Sketch, please open “sketchWiFi.pde.” first, and click “Run”. The newly pop up window will use the computer’s IP address by default and open a data monitor port.
  • Page 89 Click LISTENING, turn on TCP SERVER's data listening function and wait for ESP32-S3 to connect. Click it Compile and upload code to ESP32-S3 WROOM, open the serial monitor and set the baud rate to 115200. ESP32-S3 connects router, obtains IP address and sends access request to server IP address on the same LAN till the connection is successful.
  • Page 90 Chapter 6 TCP/IP www.freenove.com █ ESP32-S3 connects with TCP SERVER, and TCP SERVER receives messages from ESP32-S3, as shown in the figure below.  support@freenove.com Any concerns?
  • Page 91 Chapter 6 TCP/IP █ www.freenove.com Sketch_06.1_As_Client The following is the program code: #include <WiFi.h> const char *ssid_Router = "********"; //Enter the router name const char *password_Router = "********"; //Enter the router password #define REMOTE_IP "********" //input the remote server which is you want to connect...
  • Page 92 Serial.println("Waiting a moment before retrying..."); Serial.println("Connected"); client.print("Hello\n"); When ESP32-S3 receive messages from servers, it will print them out via serial port; Users can also send messages to servers from serial port. (client.available() > 0) { delay(20); //read back one line from the server String line = client.readString();...
  • Page 93 █ www.freenove.com (Serial.available() > 0) { delay(20); String line = Serial.readString(); client.print(line); If the server is disconnected, turn off WiFi of ESP32-S3. (client.connected () == false) { client.stop(); WiFi.disconnect(); Reference Class Client Every time when using Client, you need to include header file "WiFi.h."...
  • Page 94: Project 6.2 As Server

    Chapter 6 TCP/IP www.freenove.com █ Project 6.2 As Server In this section, ESP32-S3 is used as a server to wait for the connection and communication of client on the same LAN. Component List ESP32-S3 WROOM x1 USB cable x1 Circuit Connect Freenove ESP32-S3 to the computer using a USB cable.
  • Page 95 115200. Turn on server mode for ESP32-S3, waiting for the connection of other devices on the same LAN. Once a device connects to server successfully, they can send messages to each other. If the ESP32-S3 fails to connect to router, press the reset button as shown below and wait for ESP32-S3 to run again.
  • Page 96 Chapter 6 TCP/IP www.freenove.com █ Serial Monitor IP address and serial port Processing: Open the “Freenove_ESP32_S3_WROVER_Board\Sketches\Sketches\Sketch_06.2_WiFiServer\ sketchWiFi\sketchWiFi.pde”. Based on the messages printed by the serial monitor, enter correct IP address and serial port in Processing to establish connection and make communication.
  • Page 97 Chapter 6 TCP/IP █ www.freenove.com The following is the program code: #include <WiFi.h> #define port const char *ssid_Router = "********"; //input your wifi name const char *password_Router = "********"; //input your wifi passwords WiFiServer server(port); void setup() Serial.begin(115200); Serial.printf("\nConnecting to ");...
  • Page 98 //Turn ON ESP32-S3 as Server mode WiFi.setAutoConnect(true); WiFi.setAutoReconnect(true); When ESP32-S3 receive messages from servers, it will print them out via serial port; Users can also send messages to servers from serial port. (client.available()) { // if there's bytes to read from the client Serial.println(client.readStringUntil('\n'));...
  • Page 99 Chapter 6 TCP/IP █ www.freenove.com Reference Class Server Every time use Server functionality, we need to include header file"WiFi.h". WiFiServer(uint16_t port=80, uint8_t max_clients=4): create a TCP Server. port: ports of Server; range from 0 to 65535 with the default number as 80.
  • Page 100: Chapter 7 Camera Web Server

    In this section, we'll use ESP32-S3's video function as an example to study. Project 7.1 Camera Web Server Connect ESP32-S3 using USB and check its IP address through serial monitor. Use web page to access IP address to obtain video and image data.
  • Page 101 Sketch can compile and work successfully. Compile and upload codes to ESP32-S3, open the serial monitor and set the baud rate to 115200, and the serial monitor will print out a network link address.
  • Page 102 Chapter 7 Camera Web Server www.freenove.com █ Open a web browser, enter the IP address printed by the serial monitor in the address bar, and access it. Taking the Google browser as an example, here's what the browser prints out after successful access to ESP32- S3's IP.
  • Page 103 Click on Start Stream. The effect is shown in the image below. Note: If sketch compilation fails due to ESP32-S3 support package, follow the steps of the image to open the CameraWebServer. This sketch is the same as described in the tutorial above.
  • Page 104 Chapter 7 Camera Web Server www.freenove.com █ The following is the main program code. You need include other code files in the same folder when write your own code. #include "esp_camera.h" #include <WiFi.h> // =================== // Select camera model // ===================...
  • Page 105 Chapter 7 Camera Web Server █ www.freenove.com config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM; config.pin_d6 = Y8_GPIO_NUM; config.pin_d7 = Y9_GPIO_NUM; config.pin_xclk = XCLK_GPIO_NUM; config.pin_pclk = PCLK_GPIO_NUM; config.pin_vsync = VSYNC_GPIO_NUM; config.pin_href = HREF_GPIO_NUM; config.pin_sscb_sda = SIOD_GPIO_NUM; config.pin_sscb_scl = SIOC_GPIO_NUM;...
  • Page 106 Chapter 7 Camera Web Server www.freenove.com █ s->set_saturation(s, -1); // lower the saturation WiFi.begin(ssid, password); WiFi.setSleep(false); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); Serial.println(""); Serial.println("WiFi connected"); startCameraServer(); Serial.print("Camera Ready! Use 'http://"); Serial.print(WiFi.localIP()); Serial.println("' to connect"); void loop() { // Do nothing. Everything is done in another task by the web server delay(10000);...
  • Page 107 Chapter 7 Camera Web Server █ www.freenove.com Add procedure files and API interface files related to ESP32-S3 camera. #include "esp_camera.h" #include <WiFi.h> … #define CAMERA_MODEL_ESP32S3_EYE // Has PSRAM … #include "camera_pins.h" Enter the name and password of the router const char *ssid = "********";...
  • Page 108 Chapter 7 Camera Web Server www.freenove.com █ ESP32-S3 connects to the router and prints a successful connection prompt. If it has not been successfully connected, press the reset key on the ESP32-S3 WROOM. WiFi.begin(ssid, password); WiFi.setSleep(false); while (WiFi.status() != WL_CONNECTED) { delay(500);...
  • Page 109: Project 7.2 Video Web Server

    Chapter 7 Camera Web Server █ www.freenove.com Project 7.2 Video Web Server Connect to ESP32-S3 using USB and view its IP address through a serial monitor. Access IP addresses through web pages to obtain real-time video data. Component List ESP32-S3 WROOM x1...
  • Page 110 Sketch can compile and work successfully. Compile and upload codes to ESP32-S3, open the serial monitor and set the baud rate to 115200, and the serial monitor will print out a network link address.
  • Page 111 Chapter 7 Camera Web Server █ www.freenove.com Open a web browser, enter the IP address printed by the serial monitor in the address bar, and access it. Taking the Google browser as an example, here's what the browser prints out after successful access to ESP32- S3's IP.
  • Page 112 Chapter 7 Camera Web Server www.freenove.com █ const char* ssid = "********"; //input your wifi name const char* password = "********"; //input your wifi passwords void startCameraServer(); void setup() { Serial.begin(115200); Serial.setDebugOutput(true); Serial.println(); camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0;...
  • Page 113 Chapter 7 Camera Web Server █ www.freenove.com config.frame_size = FRAMESIZE_SVGA; config.fb_location = CAMERA_FB_IN_DRAM; // camera init esp_err_t = esp_camera_init(&config); (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err); return; sensor_t * s = esp_camera_sensor_get(); // initial sensors are flipped vertically and colors are a bit saturated s->set_vflip(s, 1);...
  • Page 114 = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 12; config.fb_count = 1; ESP32-S3 connects to the router and prints a successful connection prompt. If it has not been successfully connected, press the reset key on the ESP32-S3 WROOM. WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500);...
  • Page 115: Project 7.3 Camera And Sdcard

    In this chapter, we continue to use the camera and SD card. We will use the onboard button as the shutter. When the button is pressed, the ESP32-S3 takes a photo and stores the photo in the SD folder. Component List...
  • Page 116 There are two ways to add libraries. The first way, open the Arduino IDE, click Sketch  Include Library  Manager Libraries. In the pop-up window, Library Manager, search for the name of the Library, “Freenove WS2812 Lib for ESP32”. Then click Install.
  • Page 117 If your camera is not installed properly, causing the camera to fail to initialize, or you have not inserted the SD card into the ESP32-S3 in advance, the on-board colored lights will turn on red as a reminder. If all is well, the onboard colored light will light up green.
  • Page 118 When we press the RST button to reset the ESP32-S3, we can see that there are some photo files in the SD card folder. These photos you can read directly through the card reader.
  • Page 119 Chapter 7 Camera Web Server █ www.freenove.com The following is the main program code. You need include other code files in the same folder when write your own code. #include "esp_camera.h" #define CAMERA_MODEL_ESP32S3_EYE #include "camera_pins.h" #include "ws2812.h" #include "sd_read_write.h" #define...
  • Page 120 Chapter 7 Camera Web Server www.freenove.com █ esp_camera_fb_return(fb); else Serial.println("Camera capture failed."); ws2812SetColor(2); cameraSetup(void) { camera_config_t config; config.ledc_channel = LEDC_CHANNEL_0; config.ledc_timer = LEDC_TIMER_0; config.pin_d0 = Y2_GPIO_NUM; config.pin_d1 = Y3_GPIO_NUM; config.pin_d2 = Y4_GPIO_NUM; config.pin_d3 = Y5_GPIO_NUM; config.pin_d4 = Y6_GPIO_NUM; config.pin_d5 = Y7_GPIO_NUM;...
  • Page 121 Chapter 7 Camera Web Server █ www.freenove.com else // Limit the frame size when PSRAM is not available config.frame_size = FRAMESIZE_SVGA; config.fb_location = CAMERA_FB_IN_DRAM; // camera init esp_err_t err = esp_camera_init(&config); (err != ESP_OK) { Serial.printf("Camera init failed with error 0x%x", err);...
  • Page 122 Chapter 7 Camera Web Server www.freenove.com █ config.xclk_freq_hz = 20000000; config.frame_size = FRAMESIZE_UXGA; config.pixel_format = PIXFORMAT_JPEG; // for streaming config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; config.fb_location = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 12; config.fb_count = 1; // if PSRAM IC present, init with UXGA resolution and higher JPEG quality // for larger pre-allocated frame buffer.
  • Page 123 Chapter 7 Camera Web Server █ www.freenove.com Initialize the serial port, buttons, lights and SD card. Serial.begin(115200); Serial.setDebugOutput(false); Serial.println(); pinMode(BUTTON_PIN, INPUT_PULLUP); ws2812Init(); sdmmcInit(); Call ws2812SetColor() to set the color of the LED. When the parameter is 0, the LED is turned off, when the parameter is 1, the red light is displayed, when the parameter is 2, the green light is displayed, and when the parameter is 3, the blue light is displayed.
  • Page 124: Chapter 8 Camera Tcp Server

    █ Chapter 8 Camera Tcp Server In the previous section, we used web page to display the video data captured by ESP32-S3, and in this section, we will use a mobile phone to display it. Project 8.1 Camera Tcp Server Connect ESP32-S3 using USB and check its IP address through serial monitor.
  • Page 125 Chapter 8 Camera Tcp Server █ www.freenove.com  support@freenove.com Any concerns?
  • Page 126 Chapter 8 Camera Tcp Server www.freenove.com █ Method 2 Visit https://play.google.com/store/apps/details?id=com.freenove.suhayl.Freenove, and click install.  support@freenove.com Any concerns?
  • Page 127 Chapter 8 Camera Tcp Server █ www.freenove.com Method 3 Visit https://github.com/Freenove/Freenove_app_for_Android, download the files in this library, and install freenove.apk to your Android phone manually. Click here to download.  support@freenove.com Any concerns?
  • Page 128 Chapter 8 Camera Tcp Server www.freenove.com █ Menu Open application “Freenove”, as shown below: MENU Device Selection Area Home Page Store  support@freenove.com Any concerns?
  • Page 129 Chapter 8 Camera Tcp Server █ www.freenove.com Freenove 4WD Car for Raspberry Pi In this chapter, we use Freenove 4WD Car for Raspberry Pi, so it is necessary to understand the interface of this mode. RGB led IP address Take photos...
  • Page 130 AP created by ESP32-S3, and they are freely set by the user. When all settings are correct, compile and upload the code to ESP32-S3, turn on the serial port monitor, and set the baud rate to 115200.
  • Page 131 Chapter 8 Camera Tcp Server █ www.freenove.com There are two methods for you to check camera data of ESP32-S3 via mobile phone APP. Method 1: Using your phone's WiFi function, select the WiFi name represented by ssid_AP in Sketch and enter the password “password_AP”...
  • Page 132 Chapter 8 Camera Tcp Server www.freenove.com █ Next, open Freenove app and select 4WD Car for Raspberry Pi mode. Enter the IP address printed by serial port in the new interface, which generally is “192.168.4.1”  support@freenove.com Any concerns?
  • Page 133 Method 2: Using your phone's WiFi function, select the router named ssid_Router and enter the password “ssid_password” to connect. And then open Freenove app and select 4WD Car for Raspberry Pi mode. The operation is similar to Method 1. Enter the IP address printed by serial port in the new interface, which generally is not “192.168.4.1” but another one.
  • Page 134 ///////////////////////////////////////////////////// WiFi.begin(ssid_Router, password_Router); Serial.print("Connecting "); Serial.print(ssid_Router); while (WiFi.isConnected() != true) { delay(500); Serial.print("."); //WiFi.begin(ssid_Router, password_Router); Serial.println(""); Serial.println("WiFi connected"); ///////////////////////////////////////////////////// Serial.print("Camera Ready! Use '"); Serial.print(WiFi.softAPIP()); Serial.print(" or "); Serial.print(WiFi.localIP()); Serial.println("' to connect in Freenove app."); disableCore0WDT();  support@freenove.com Any concerns?
  • Page 135 Chapter 8 Camera Tcp Server █ www.freenove.com xTaskCreateUniversal(loopTask_Cmd, "loopTask_Cmd", 8192, NULL, 1, &loopTaskHandle, 0);//loopTask_Cmd uses core 0. xTaskCreateUniversal(loopTask_Blink, "loopTask_Blink", 8192, NULL, 1, &loopTaskHandle, 0);//loopTask_Blink uses core 0. //task loop uses core 1. void loop() { WiFiClient client = server_Camera.available(); // listen for incoming clients...
  • Page 136 Chapter 8 Camera Tcp Server www.freenove.com █ String currentLine = ""; // make a String to hold incoming data from the client while (client.connected()) { // loop while the client's connected (client.available()) { // if there's bytes to read from the client, char c = client.read();...
  • Page 137 Chapter 8 Camera Tcp Server █ www.freenove.com config.pin_sscb_sda = SIOD_GPIO_NUM; 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.frame_size = FRAMESIZE_UXGA; config.pixel_format = PIXFORMAT_JPEG; // for streaming config.grab_mode = CAMERA_GRAB_WHEN_EMPTY; config.fb_location = CAMERA_FB_IN_PSRAM; config.jpeg_quality = 12;...
  • Page 138 Chapter 8 Camera Tcp Server www.freenove.com █ #define CAMERA_MODEL_ESP32S3_EYE #include "camera_pins.h" Set name and password for router that ESP32-S3 needs to connect to. And set ESP32-S3 to open two servers, whose port are 8000 and 5000 respectively. const char *ssid_Router "********"; const char *password_Router = "********";...
  • Page 139 Chapter 8 Camera Tcp Server █ www.freenove.com config.jpeg_quality = 12; config.fb_count = 1; // if PSRAM IC present, init with UXGA resolution and higher JPEG quality // for larger pre-allocated frame buffer. if(psramFound()){ config.jpeg_quality = 10; config.fb_count = 2; config.grab_mode = CAMERA_GRAB_LATEST;...
  • Page 140 Chapter 8 Camera Tcp Server www.freenove.com █ Serial.println("Camera Error"); The loopTask_Cmd() function sends the received instruction back to the phone app and prints it out through a serial port. void loopTask_Cmd(void *pvParameters) { Serial.println("Task Cmd_Server is starting ... "); while (1) { WiFiClient client = server_Cmd.available();...
  • Page 141 If you do not have a router near you, or if you are outdoors, you can annotate the following code, and then compile and upload it to ESP32-S3. And you can display the video images on your phone by Method 1.
  • Page 142 We will check and correct it as soon as possible. If you want learn more about ESP32-S3, you view our ultimate tutorial: https://github.com/Freenove/Freenove_Ultimate_Starter_Kit_for_ESP32_S3/archive/master.zip If you want to learn more about Arduino, Raspberry Pi, smart cars, robots and other interesting products in science and technology, please continue to focus on our website.

Table of Contents

Save PDF