Installing the ESP32 Board in Arduino IDE
安裝 Arduino IDE 到 ESP32 板子 中的步驟整理:
🛠️ 安裝 ESP32 附加元件到 Arduino IDE
要使用 Arduino IDE 程式設計 ESP32,您需要安裝一個附加元件。
步驟一:設定偏好設定 (Preferences)
在 Arduino IDE 中,前往 File > Preferences (檔案 > 偏好設定)。
在「Additional Board Manager URLs」(額外開發板管理員網址) 欄位中輸入以下網址:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json備註: 如果您已經有 ESP8266 板子的網址,可以使用逗號將其與 ESP32 的網址隔開。
點擊 OK (確定) 按鈕儲存設定。
步驟二:開啟開發板管理員 (Boards Manager)
前往 Tools > Board > Boards Manager... (工具 > 板子 > 開發板管理員...)。
步驟三:安裝 ESP32 平台
在開發板管理員中,搜尋 ESP32。
找到 "ESP32 by Espressif Systems",然後按下 Install (安裝) 按鈕。
等待幾秒鐘,直到安裝完成。
✅ 測試安裝
安裝完成後,您可以通過上傳一個範例程式來測試安裝是否成功:
將您的 ESP32 板子 連接到電腦。
在 Arduino IDE 中,選擇您的板子:前往 Tools > Board (工具 > 板子),並在列表中選擇您的 ESP32 板子 (例如:DOIT ESP32 DEVKIT V1)。
選擇正確的 Port (連接埠)。
注意: 如果看不到 COM Port,您可能需要安裝 CP210x USB to UART Bridge VCP Drivers。
開啟範例程式:前往 File > Examples > WiFi (ESP32) > WiFiScan。這會開啟一個新的程式草稿。
點擊 Arduino IDE 中的 Upload (上傳) 按鈕,將程式碼編譯並上傳到您的板子。
如果一切順利,您會看到 "Done uploading." (上傳完成。) 的訊息。
開啟 Serial Monitor (序列埠監控視窗),並將鮑率 (baud rate) 設定為 115200。
按下 ESP32 板子上的 Enable (啟用) 按鈕,您應該會在序列埠監控視窗中看到附近的 Wi-Fi 網路列表。
⚠️ 疑難排解:上傳超時錯誤
如果您上傳程式碼時遇到 "A fatal error occurred: Failed to connect to ESP32: Timed out... Connecting..." 的錯誤訊息,這表示您的 ESP32 沒有進入燒錄/上傳模式。
解決步驟:
確保您已選擇正確的板子名稱和 COM port。
按住 ESP32 板子上的 "BOOT" 按鈕。
在 Arduino IDE 中按下 "Upload" (上傳) 按鈕。
當您在 Arduino IDE 中看到 "Connecting...." 訊息出現後,鬆開您的手,釋放 "BOOT" 按鈕。
Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)
There’s an add-on for the Arduino IDE that allows you to program the ESP32 using the Arduino IDE and its programming language. In this tutorial we’ll show you how to install the ESP32 board in Arduino IDE whether you’re using Windows, Mac OS X or Linux.
Using Arduino 2.0? Follow this tutorial instead: Installing ESP32 Board in Arduino IDE 2.0
Watch the Video Tutorial
This tutorial is available in video format (watch below) and in written format (continue reading this page).
If you have any problems during the installation procedure, take a look at the ESP32 Troubleshooting Guide.
If you like the ESP32, enroll in our course: Learn ESP32 with Arduino IDE.
Prerequisites: Arduino IDE Installed
Before starting this installation procedure, you need to have Arduino IDE installed on your computer. There are two versions of the Arduino IDE you can install: version 1 and version 2.
You can download and install Arduino IDE by clicking on the following link: arduino.cc/en/Main/Software
Which Arduino IDE version do we recommend? At the moment, there are some plugins for the ESP32 (like the SPIFFS Filesystem Uploader Plugin) that are not yet supported on Arduino 2. So, if you intend to use the SPIFFS plugin in the future, we recommend installing the legacy version 1.8.X. You just need to scroll down on the Arduino software page to find it.
If you’ll use Arduino 2, you can follow this tutorial instead:
If later on, you need to install the SPIFFS plugin, you can install Arduino 1.8.X and have both versions installed on your computer.
Do you need an ESP32 board? You can buy it here.
Installing ESP32 Add-on in Arduino IDE
To install the ESP32 board in your Arduino IDE, follow these next instructions:
In your Arduino IDE, go to File> Preferences

Enter the following into the “Additional Board Manager URLs” field:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then, click the “OK” button:

Note: if you already have the ESP8266 boards URL, you can separate the URLs with a comma as follows:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
Open the Boards Manager. Go to Tools > Board > Boards Manager…

Search for ESP32 and press install button for the “ESP32 by Espressif Systems“:

That’s it. It should be installed after a few seconds.

Testing the Installation
Plug the ESP32 board to your computer. With your Arduino IDE open, follow these steps:
1. Select your Board in Tools > Board menu (in my case it’s the DOIT ESP32 DEVKIT V1)

2. Select the Port (if you don’t see the COM Port in your Arduino IDE, you need to install the CP210x USB to UART Bridge VCP Drivers):

3. Open the following example under File > Examples > WiFi (ESP32) > WiFiScan

4. A new sketch opens in your Arduino IDE:

5. Press the Upload button in the Arduino IDE. Wait a few seconds while the code compiles and uploads to your board.

6. If everything went as expected, you should see a “Done uploading.” message.

7. Open the Arduino IDE Serial Monitor at a baud rate of 115200:

8. Press the ESP32 on-board Enable button and you should see the networks available near your ESP32:

Troubleshooting
1) If you try to upload a new sketch to your ESP32 and you get this error message “A fatal error occurred: Failed to connect to ESP32: Timed out… Connecting…“. It means that your ESP32 is not in flashing/uploading mode.
Having the right board name and COM port selected, follow these steps:
- Hold-down the “BOOT” button in your ESP32 board

- Press the “Upload” button in the Arduino IDE to upload your sketch:

- After you see the “Connecting….” message in your Arduino IDE, release the finger from the “BOOT” button:

- After that, you should see the “Done uploading” message
That’s it. Your ESP32 should have the new sketch running. Press the “ENABLE” button to restart the ESP32 and run the new uploaded sketch.
You’ll also have to repeat that button sequence every time you want to upload a new sketch. But if you want to solve this issue once for all without the need to press the BOOT button, follow the suggestions in the next guide:
2) If you get the error “COM Port not found/not available”, you might need to install the CP210x Drivers:
- Install USB Drivers – CP210x USB to UART Bridge (Windows PC)
- Install USB Drivers – CP210x USB to UART Bridge (Mac OS X)
If you experience any problems or issues with your ESP32, take a look at our in-depth ESP32 Troubleshooting Guide.
Wrapping Up
This is a quick guide that illustrates how to prepare your Arduino IDE for the ESP32 on a Windows PC, Mac OS X, or Linux computer. If you encounter any issues during the installation procedure, take a look at the ESP32 troubleshooting guide.
沒有留言:
張貼留言