Main Content

Working with Arduino Libraries in IO Device Builder

Perform these steps to integrate Arduino libraries into the IO Device Builder.

Identify the Required Libraries

The necessary libraries depend on the functionality you need, such as communication or data processing. For example, for communication, based on the requirement, you might need I2C, SPI, or Modbus.

Find and Download the Libraries

Library Manager: Use the Library Manager available in Arduino IDE to download the libraries. It automatically manages all library dependencies for you. For information on installing Arduino libraries, see Installing Libraries.

  • Navigate to Library Manager in the Arduino IDE.

  • Search for the required libraries. For example, Modbus.

  • Look for libraries with keywords such as by Arduino or from known communities.

    Note

    The Arduino IDE detects and lists all the dependencies. Click Install All to install them.

Click More Info to get more information on library and its compatibility information.

To find where libraries are installed on your computer, see the Libraries section in Find sketches, libraries, board cores, and other files on your computer page.

Identify the Libraries Used by an Example Sketch

Perform these steps to identify the libraries used in an example sketch.

  1. From the Arduino IDE menu, navigate to File > Preferences. If you are using macOS, navigate to Settings> Preferences from Arduino IDE menu.

  2. In the Preference dialog box, select Show verbose output during: ☐ compilation and then click OK.

  3. Navigate to Sketch > Verify/Compile from the Arduino IDE menus and wait for the compilation to finish.

    Check the Output, for lines similar to these:

    Using library ArduinoModbus at version 1.0.9 in folder: D:\OneDrive - MathWorks\Documents\Arduino\libraries\ArduinoModbus
    Using library ArduinoRS485 at version 1.1.0 in folder: D:\OneDrive - MathWorks\Documents\Arduino\libraries\ArduinoRS485

    Using this information, you can:

    • Identify which libraries were selected by the build system.

    • View the path of each library on your computer.

Verify Availability of Libraries as Part of Simulink Support Package for Arduino Hardware

Before adding a library to the IO Device Builder app, verify if it already exists as part of the Simulink Support Package for Arduino Hardware. Use the following command to find the directory path where these libraries are located:

[~,PathToLibraries] = codertarget.arduinobase.internal.getArduinoIDERoot('libraries')

This command outputs the path, for example:

PathToLibraries =

    'L:\W25a\aCLI\user\libraries'

Add the Library to IO Device Builder

  • Open IO Device Builder: After downloading the required libraries, launch IO Device Builder app.

  • Add Library Path and Files: Follow the app workflow, which allows you to add the library path and source files. Ensure that all necessary paths and files are included in the Source files location and Source files screens to guarantee proper library integration and functionality.

See Also

| | | |