Working with Arduino
This chapter includes the following sections. Please read as needed:
Arduino Getting Started
New to Arduino ESP32 development and looking for a quick start? We have prepared a comprehensive Getting Started Tutorial for you.
- Section 0: Getting to Know ESP32
- Section 1: Installing and Configuring Arduino IDE
- Section 2: Arduino Basics
- Section 3: Digital Output/Input
- Section 4: Analog Input
- Section 5: Pulse Width Modulation (PWM)
- Section 6: Serial Communication (UART)
- Section 7: I2C Communication
- Section 8: SPI Communication
- Section 9: Wi-Fi Basics
- Section 10: Web Server
- Section 11: Bluetooth
- Section 12: LVGL GUI Development
- Section 13: Comprehensive Project
Note: This tutorial uses the ESP32-S3-Zero as a reference example, and all hardware code is based on its pinout. Before you start, we recommend checking the pinout of your development board to ensure the pin configuration is correct.
Setting Up the Development Environment
1. Install and Configure the Arduino IDE
Install the ESP32 Board
- To use ESP32-related boards in Arduino IDE, you must first install the "esp32 by Espressif Systems" board support package.
- Follow the board installation requirements for installation. "Online installation" is generally recommended. If online installation fails, use "offline installation".
- For a detailed installation tutorial, see: Arduino Board Management Tutorial
ESP32-S3-RS485-CAN required development board installation description
| Board Name | Board Installation Requirement | Version Requirement |
|---|---|---|
| esp32 by Espressif Systems | "Offline" installation / "Online" installation | 3.0.x |
2. Install Libraries
- There are usually two ways to install Arduino libraries: online installation and offline installation. If the library installation requires offline installation, you must use the provided library files.
For most libraries, you can easily search for and install them through the Arduino online Library Manager. However, some open-source or custom libraries are not synchronized to the Arduino Library Manager, so they cannot be found through online search. In this case, you can only install these libraries manually offline. - For a detailed library installation tutorial, see: Arduino Library Manager Tutorial
- The ESP32-S3-RS485-CAN library files are stored in the example program. Click here to go to: ESP32-S3-RS485-CAN Example
Library installation instructions for ESP32-S3-RS485-CAN
| Library Name | Description | Version | Library Installation Requirement |
|---|---|---|---|
| ArduinoJson | Lightweight JSON library | v6.21.4 | Online or offline installation |
| PubSubClient | MQTT message publish/subscribe library | v2.8.0 | Online or offline installation |
| NTPClient | Network time synchronization client library | v3.2.1 | Online or offline installation |
Example
ESP32-S3-RS485-CAN Example
| Example | Description | Notes |
|---|---|---|
| 01_MAIN_WIFI_AP | RS485 interface control, CAN interface control, Bluetooth control, Bluetooth IP sending, Web page control (short range) | Can be flashed directly; the Web page is only available after connecting to the device Wi-Fi |
| 02_MAIN_WIFI_STA | RS485 interface control, CAN interface control, Bluetooth control, Bluetooth IP sending, Web page control (short range) | You need to modify the Wi-Fi to connect to; the Web page is only available within the local area network |
Arduino Project Settings

01_MAIN_WIFI_AP
Example Description
- This example implements control of the RS485 and CAN interfaces via Wi-Fi. This example enables the Wi-Fi AP mode
Notes
- Can be flashed directly
- The Web page is only available after connecting to the device Wi-Fi
Web Page Control
- See Web Page Control.
02_MAIN_WIFI_STA
Example Description
- This example implements control of the RS485 and CAN interfaces via Wi-Fi and Bluetooth. This example enables the Wi-Fi STA mode
Notes
- Requires modifying the Wi-Fi to connect to
- The Web page only supports controlling the device when it is on the same network as this product. If using a mobile phone for control, mobile data must be turned off.
Web Page Control
Use a mobile Bluetooth debug assistant to connect to the ESP32-S3-RS485-CAN device, obtain the IP after connecting to Wi-Fi, and open the Web page via the IP.
-
AP Mode
- Connect to the Wi-Fi of the ESP32-S3-RS485-CAN device. The Wi-Fi name is ESP32-S3-RS485-CAN, and the password is waveshare.

- Obtain the current IP through the Bluetooth debugging assistant
- Open the Web page to control the RS485 and CAN interfaces (the device needs a short period of time to configure after power-on; the first time the Web page is opened after each power-on may be relatively slow)

-
STA Mode
- Before flashing the program, open
MAIN_WIFI_STA/WS_Information.hand changeSTASSIDandSTAPSKto the Wi-Fi name and password you want to connect to, respectively. The device will automatically connect to the configured Wi-Fi after power-on. - Obtain the current IP through the Bluetooth debugging assistant
- Open the Web page to control the RS485 and CAN interfaces (the device needs a short period of time to configure after power-on; the first time the Web page is opened after each power-on may be relatively slow)

- Before flashing the program, open