Main Content

Add Custom ESP32 Arduino Compatible Boards to Support Package

This example shows how to add a customized ESP32 WROOM and ESP32 WROVER Arduino® compatible hardware board to the support package. You can customize their board-specific settings as well as pin configuration using the board datasheet and pin layout diagram. Using this example, you can add one or more ESP32 board(s) to the support package.

Follow these steps to add either a ESP32 WROOM or ESP32 WROVER Arduino compatible hardware board to the support package.

  1. Open a Simulink® model.

  2. In the Configuration Parameters dialog box, set Hardware board to ESP32-WROOM (Arduino Compatible) or ESP32-WROVER (Arduino Compatible).

  3. In the Hardware board settings section, go to Target hardware resources > ESP32 board properties and click Create Custom board. A new template file opens in a new editor window. For more information on how to access the location of the file, see Accessing ESP32 Template File. For more information on how to change the name of the file, see Naming ESP32 Template File.

  4. To configure the various ESP32 board-specific settings and GPIO pins in the template file, refer to the datasheet and the pin layout diagram of the target hardware board. You can also find the board-specific settings for your target hardware in the boards.txt file. This file is located in the Arduino IDE when you install the Arduino support package in MATLAB®.

  5. Save and close the template file. Close the Configuration Parameters dialog box.

  6. Open the Configuration Parameters dialog box and select the target Arduino board in the Hardware board parameter.

  7. In the Hardware board settings section, go to Target hardware resources > ESP32 board properties. In the Board drop-down menu, select the new customized ESP32 board.

    New custom ESP32 WROOM board added in the Board parameter

  8. Click Apply.

Accessing ESP32 Template File

Use any one of these methods to access the ESP32 template file.

  • In the MATLAB Editor window, right-click the name of the file and from the drop-down menu select Show in Explorer.ESP32 board new template location

  • In the MATLAB Command Window, execute this command and navigate to the location of the ESP32 template file.

    fullfile(matlabshared.supportpkg.getSupportPackageRoot,filesep,'toolbox','target','supportpackages','arduinobase','+codertarget','+arduinobase','+customESP32board')
    
    ans =
    
        'C:\ProgramData\MATLAB\SupportPackages\R2022b\toolbox\target\supportpackages\arduinobase\+codertarget\+arduinobase\+customESP32board'

Naming ESP32 Template File

The name of the ESP32 template file depends on the type of the hardware board you set in the Hardware board parameter in the Configuration Parameters dialog box. For example, if you set Hardware board to ESP32-WROOM (Arduino Compatible), the name of the template file is ESP32WROOMTemplateBoard and if you set Hardware board to ESP32-WROVER (Arduino Compatible), the name of the template file is ESP32WROVERTemplateBoard.

To rename the template file, ensure that the file name starts with ESP32 and ends with Board. For example, the default name of the template file for ESP32 WROOM board is ESP32WROOMTemplateBoard. You can replace WROOMTemplate with any alphanumeric characters. For example, ESP32Test123Board. In the template file, ensure to use the same file name in these locations:ESP32 board new template file name

See Also

| |