Getting Started
You will need an IDE to write your code. We recommend beginners use the Arduino IDE. While it may not be the best IDE, it gets the job done and is straightforward and easy for beginners to use. Once you become familiar with the Arduino IDE and progress to more complex projects, you may find it more convenient to use VS Code with the Platformio plugin as a replacement.
How to Program the ESP32?
You can program the ESP32 using different firmware and programming languages. You can use:
-
Arduino C/C++, using the Arduino core for ESP32.
-
Espressif IDF (IoT Development Framework)
-
Micropython
-
JavaScript
-
LUA
-
…
In this section, we will see how to program the ESP32 using the Arduino core for the ESP32 board.
Arduino Integrated Development Environment
The Arduino Integrated Development Environment (IDE) is a software application that allows you to write, upload, and debug code for Arduino boards. It is the primary software tool for developing and uploading code to Arduino boards. The Arduino IDE has a simple, user-friendly interface that allows you to write, edit, and upload your code to the Arduino board. It includes features such as syntax highlighting, auto-indentation, and a built-in serial monitor for debugging your code.
To use the Arduino IDE, you need to install it on your computer and connect your Arduino board to your computer using a USB cable. The Arduino IDE supports a wide range of programming languages, including C++ and Python, and it is compatible with various Arduino boards, including Arduino Uno, Arduino Mega, and Arduino Nano.
Installing the Arduino IDE
To use the Arduino IDE, you must have Java installed on your computer. If you do not have it, go to http://java.com/download, download and install the latest version.
Visit the following URL to get the Arduino IDE: https://www.arduino.cc/en/Main/Software
Unzip the folder you just downloaded to make it usable. Start the Arduino software by running the arduino.exe executable.
-
Switch the language to Chinese
Adding Support for ESP32 Boards
You need to add support for the ESP32 board in the Arduino IDE to be able to program the ESP32. Note that a VPN is required for the following steps. Please follow these steps:
-
Go to File > Preferences.
Arduino IDE File > Preferences
-
In the “Additional Board Manager URLs” section, enter the following information. This will also add support for the ESP32 and ESP8266 boards.
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json http://arduino.esp8266.com/stable/package_esp8266com_index.json
-
See the image below. Then click “OK”.
-
Next, go to “Tools” > “Board” > “Board Manager…”
-
In the search bar, type “esp32” and press Enter
-
Click on the “esp32 by Espressif Systems” option, then click the “Install” button.
-
Wait for the installation to complete, then close the board manager window.
-
Now, go to “Tools” > “Board”, and select the “ESP32 Development Module” option from the list of available boards.
-
Once installed, you should be able to write and upload code to your ESP32 board.
It is worth noting that if your ESP32 board is not recognized by the computer, you may need to install the appropriate drivers for it. You can find more detailed instructions on how to install the ESP32 in the Arduino IDE in the ESP32 Arduino Core documentation:
https://github.com/espressif/arduino-esp32/blob/master/docs/arduino-ide/windows.md
Arduino Board Manager:
The Arduino Board Manager is a feature of the Arduino Integrated Development Environment (IDE) that allows you to easily install support for additional boards (like the ESP32 or Arduino Nano 33 BLE) without manually installing libraries and drivers. From there, you can search for and install support for various Arduino boards. The board manager will download and install the necessary libraries and drivers for the selected board, making it easy to start programming and using that board.
The Arduino Board Manager is a convenient way to add support for new boards to the Arduino IDE, as it eliminates the need to manually install libraries and drivers and ensures you have the latest versions of the necessary software.
ESP32 Examples
Uploading Code to ESP32 Using Arduino IDE
To demonstrate how to upload code to the ESP32 board, we will try a simple example: making LED1 blink on for 3 seconds and off for 10 seconds.
Create a new file main.ino
#define LED1 15
void setup() {
pinMode(LED1, OUTPUT);
}
void loop() {
digitalWrite(LED1, HIGH);
delay(3000);
digitalWrite(LED1, LOW);
delay(10000);
}
References
-
Software testing quality books documentation download continuously updated https://github.com/china-testing/python-testing-examples Please like, thank you!
-
The Python testing development libraries involved in this article Thank you for liking! https://github.com/china-testing/python_cn_resouce
-
Python quality book downloads https://github.com/china-testing/python_cn_resouce/blob/main/python_good_books.md
Arduino IDE Example
Connect your ESP32 development board to your computer using a USB cable.
It is important: You will need to use a USB cable that has data capabilities. Some USB cables from chargers or power banks only provide power and do not allow data transmission; these cables will not work.
Now, to upload the code, please follow the steps listed below.
1) Select the name of your ESP32 board by going to Tools > Board, and scrolling down to the ESP32 section to select the name of the board there.
2) Select the COM port from the list by going to the Tools menu and selecting the Port option. If the COM port you want to use is grayed out, it indicates that you have not installed the necessary USB drivers. Arduino IDE for ESP32 select COM port
-
Press the upload (right arrow) button.
Connect pin 15 on the P3 terminal with the D1 pin of the LED module using a DuPont wire, and you will see the D1 indicator light on the development board light up, as shown below:
The functional code is saved in the FLASH of the development board and is not lost after power off.
You can also view the serial port at a baud rate of 115200.
Note that you need to close the serial port when uploading the file.
Using a breadboard:
Leave a Comment
Your email address will not be published. Required fields are marked *