Skip to main content

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.

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 NameBoard Installation RequirementVersion Requirement
esp32 by Espressif Systems"Offline" installation / "Online" installation3.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 NameDescriptionVersionLibrary Installation Requirement
ArduinoJsonLightweight JSON libraryv6.21.4Online or offline installation
PubSubClientMQTT message publish/subscribe libraryv2.8.0Online or offline installation
NTPClientNetwork time synchronization client libraryv3.2.1Online or offline installation

Example​

Arduino example workflow

ESP32-S3-RS485-CAN Example

ExampleDescriptionNotes
01_MAIN_WIFI_APRS485 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_STARS485 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​

ESP32-S3-16MB-OPI-Parameters

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​

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.

    ESP32-S3-RS485-CAN-TO-WIKI-Web-1

    • 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)

    ESP32-S3-RS485-CAN-TO-WIKI-Web-2

  • STA Mode

    • Before flashing the program, open MAIN_WIFI_STA/WS_Information.h and change STASSID and STAPSK to 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)

    ESP32-S3-RS485-CAN STA Mode Web Control Page