Difference between revisions of "Template:ESP32 S2 Guide"
(Created page with "==Development Languages== ESP32-S2-Pico, ESP32-S2-LCD-0.96 can use CircuitPython, MicroPython, C/C++(Arduino, ESP-IDF) to develop products rapidly. The following are the brief...") |
|||
Line 46: | Line 46: | ||
:[[File:ESP32_One_006.jpg|400px]] | :[[File:ESP32_One_006.jpg|400px]] | ||
:[[File:ESP32_One_007.jpg|400px]] | :[[File:ESP32_One_007.jpg|400px]] | ||
+ | |||
+ | ===CircuitPython=== | ||
+ | #Install ESP-IDF by referring to the chapter on environment settings, and then start the esp-idf environment in cmd | ||
+ | #Press and hold the BOOT button on the board, and then connect the USB cable | ||
+ | #Find the COM port corresponding to the device manager | ||
+ | #Modify the COM port enumerated by the user's computer in the following command, and enter the following command to clear the flash | ||
+ | esptool.py --chip esp32-s2 --port COM96 erase_flash | ||
+ | #Put the following bootloader.bin and other files ([https://www.waveshare.net/w/upload/6/69/ESP32-S2-Pico_Code.zip sample demo]) into the directory where esp-idf is installed, and then enter the following command, pay attention to the COM port enumerated by the user's computer | ||
+ | esptool.py --chip esp32s2 -p COM96 -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partition-table.bin 0xe000 ota_data_initial.bin 0x1000 bootloader.bin 0x2d0000 tinyuf2.bin | ||
+ | #Then the disk will appear, and then drag CircuitPython's uf2 firmware to the disk | ||
+ | #Install and open Thonny[https://thonny.org/], select Tools->Options and set as shown below | ||
+ | [[File:thony.png]] | ||
+ | ===MicroPython=== | ||
+ | 1. Install ESP-IDF by referring to the chapter on environment settings, and then start the esp-idf environment in cmd | ||
+ | 2. Press and hold the BOOT button on the board, and then connect the USB cable | ||
+ | 3. Find the COM port corresponding to the device manager | ||
+ | 4. Modify the COM port enumerated by the user's computer in the following command, and enter the following command to clear the flash | ||
+ | esptool.py --chip esp32-s2 --port COM96 erase_flash | ||
+ | 5.Put the following bin file([https://www.waveshare.net/w/upload/6/69/ESP32-S2-Pico_Code.zip demo])into the directory where esp-idf is installed, then enter the following command, pay attention to the COM port in the computer | ||
+ | esptool.py --chip esp32s2 --port COM96 write_flash -z 0x1000 ESP32_S2_WROVER-20220117-v1.18.bin | ||
+ | 6.Install and open [https://thonny.org/ Thonny], select Tools->Options and set as shown below | ||
+ | |||
+ | [[File:Thonny.png]] | ||
+ | |||
+ | 7.Refer to [https://github.com/micropython/micropython/releases/tag/v1.18 MicroPython documentation]] [[https://github.com/micropython/micropython/releases/tag/v1.18 releases note]] | ||
==Hardware Connection== | ==Hardware Connection== |
Revision as of 07:39, 22 April 2022
Development Languages
ESP32-S2-Pico, ESP32-S2-LCD-0.96 can use CircuitPython, MicroPython, C/C++(Arduino, ESP-IDF) to develop products rapidly. The following are the brief introductions of three development manners.
CircuitPython
As a programming language,CircuitPython is designed to simplify coding experimentation and learning on low-cost microcontroller boards, is an open-source derivative of the MicroPython programming language that aimed at students and beginners, and developed and maintained by Adafruit Industries.
- Circuitpython's related application development reference Development Documentation
- Github library of Circuitpython can be recompiled for custom development.
- Related firmware of Circuitpython for different ESP32-S2 core boards.
MicroPython
Micropython is a lean and efficient implementation of the Python 3 programming language that includes a small portion of the Python standard library and is optimized to run on microcontrollers and constrained environments.
- Micropython related application development reference Development Documentation
- Github library of Micropython can be recompiled for custom development
- Related firmware of Micropython on different ESP32-S2 core boards
C/C++ (Arduino, ESP-IDF)
Espressif official C/C++ library is easy for quick installment, please check the links below:
- Arduino development manual of ESP32-S2
- ESP-IDF development manual of ESP32-S2
Setup Environment
The environment is set under the Windows 10 system, the users can develop by using Arduino or ESP-IDF and Visual Studio Code as IDE. For Mac/Linux operating system users, please refer to the official instruction.
Arduino
- 1. Downloading and installing Arduino IDE, please pay attention to the default configuration and the full English path.
- 2, Arduino install ESP32 library, detail install process is shown below, please refer to related information for more information.
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json https://www.arduino.cn/package_esp32_dev_index.json
- 3, Open the VSCode, install Arduino and C/C++plugin (Microsoft Publisher)
- 4, After installing plugin ,press F1 to enter Preferences Open Settings(UI),press Enter to find Arduino plugin setting.
- 5, Press F1 to enter Arduino Board Config, then press Enter.
ESP-IDF
1, Download and install the latest offline version of esp-idf-tools-setup, and place in the full English path and use the default configuration (automatic installation of ESP-IDF, Python, Git, and setting environment variables), place the path of ESP-IDF elsewhere.
2, Download and install VS Code, place in the full English path, and use the default configuration.
3, Open VS Code,press Ctrl+P,enter ext esp-idf-extension to install configuration plugin.
4, Press F1 in VSCode, enter Configure ESP-IDF extension to open the configure screen, and then choose USE EXISTING SETUP.
CircuitPython
- Install ESP-IDF by referring to the chapter on environment settings, and then start the esp-idf environment in cmd
- Press and hold the BOOT button on the board, and then connect the USB cable
- Find the COM port corresponding to the device manager
- Modify the COM port enumerated by the user's computer in the following command, and enter the following command to clear the flash
esptool.py --chip esp32-s2 --port COM96 erase_flash
- Put the following bootloader.bin and other files (sample demo) into the directory where esp-idf is installed, and then enter the following command, pay attention to the COM port enumerated by the user's computer
esptool.py --chip esp32s2 -p COM96 -b 460800 --before=default_reset --after=no_reset write_flash --flash_mode dio --flash_freq 80m --flash_size 4MB 0x8000 partition-table.bin 0xe000 ota_data_initial.bin 0x1000 bootloader.bin 0x2d0000 tinyuf2.bin
- Then the disk will appear, and then drag CircuitPython's uf2 firmware to the disk
- Install and open Thonny[1], select Tools->Options and set as shown below
MicroPython
1. Install ESP-IDF by referring to the chapter on environment settings, and then start the esp-idf environment in cmd 2. Press and hold the BOOT button on the board, and then connect the USB cable 3. Find the COM port corresponding to the device manager 4. Modify the COM port enumerated by the user's computer in the following command, and enter the following command to clear the flash
esptool.py --chip esp32-s2 --port COM96 erase_flash
5.Put the following bin file(demo)into the directory where esp-idf is installed, then enter the following command, pay attention to the COM port in the computer
esptool.py --chip esp32s2 --port COM96 write_flash -z 0x1000 ESP32_S2_WROVER-20220117-v1.18.bin
6.Install and open Thonny, select Tools->Options and set as shown below
7.Refer to MicroPython documentation] [releases note]
Hardware Connection
- Connect the Raspberry Pi Pico expansion board to ESP32-S2-Pico or ESP32-S2-LCD-0.96 in a stacked manner, be careful to avoid pin cross-use, such as serial expansion board of GPIO pins in the same position
- Do not block the antenna part of ESP32-S2-Pico or ESP32-S2-LCD-0.96, and it's necessary to adjust the board orientation if the Wifi signal is poor.
- To download the program, you need to press and hold the BOOT button and then press the RESET button to release, Or disconnect the USB, then press and hold the BOOT button to power on. At this time, the UART0 (GPIO43, GPIO44) and USB of ESP32-S2 can be used for flash programs
- ESP32-S2-Pico or ESP32-S2-LCD-0.96 will print the status information of ESP32-S2 when powered on by default. If you want to cancel, you need to write parameters to the register as shown in the figure below. Note that it cannot be restored after modifying.
Examples
This section combines Arduino, Raspberry Pi Pico expansion board, using AD/DA, SPI, I2C, WiFi, and other peripherals of ESP32-S2.
ADC/DAC
- Be careful to configure as shown in the following below, enable USB CDC, and select USB update mode
- If there is an error in the download as shown in the figure below, indicating that you need to manually reset the board to run the program after downloading.
- definite four AD, one DA macro, initialize the DA value of 127, and the USB serial output in the setup() function.
#define adc0 6 #define adc1 7 #define adc2 8 #define adc3 1 #define dac_pin 17 uint16_t adc_Value = 0; // variable to store the value coming from the sensor uint8_t dac_value = 127; //DA output value void setup() { // put your setup code here, to run once: HWSerial.begin(115200); HWSerial.setDebugOutput(true); USB.onEvent(usbEventCallback); USBSerial.onEvent(usbEventCallback); USBSerial.begin(); USB.begin(); delay(4000); // USBSerial.printf("Setup done"); }
- DA increases 1 every 5 seconds and loops from 0 until 255. Use one of the AD pins to connect DA to detect the operation of DA. Lines 28 to 30 are battery voltage detection.
UART
- Need to select configuration options as shown in AD_DA demo download, enable USB CDC, and select USB update mode
- If there is an error message in the download, as shown in the AD_DA demo download, and it needs to be reset manually after downloading to run the program.
- UART demo combined with Pico-GPS-L76B to read NMEA, parse and convert the coordinate system and output, etc.
- Codes
- Include NMEA0183 library, instantiate NMEA0183Msg, NMEA0183, specify the pin of serial 1
- Specify the NMEA0183 data stream serial and baud rate in the NMEA0183.Begin() function, initialize the USB serial function, The loop() function polls the NMEA0183 data stream and then receives it
SPI
- You need to select the configuration, as shown in the AD_DA routine download, enable USB CDC, and select update mode
- If there is an error message in the download, as shown in the AD_DA demo download, and it needs to be reset manually after downloading to run the program.
- This example tests the LCD of ESP32-S2-LCD-0.96 and scans WiFi hotspot information and then prints it
- Codes
Initiate USB serial and the STA mode of Wifi in setup(), turn on the LCD display in the loop() function, and print out the scanned WiFi information of the USB serial.