Creates custom Arduino add-on libraries in MATLAB to interface with unsupported sensors and peripherals (DHT11, OLED, NeoPixels, etc.) via LibraryBase, I2C/SPI/GPIO wrappers.
Ships in test-and-measurement. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Help the user interface with Arduino sensors or peripherals from MATLAB by creating a custom arduino library that bridges MATLAB and Arduino C++ code.
LibraryBase, arduinoioaddons, or custom addon creationlistArduinoLibraries to check)matlab-connect-arduino)MANDATORY GATE — do not skip, but keep it fast:
Before creating a custom addon, you MUST run Steps 0 and 1 below. These are quick checks (one MATLAB command + one sentence about File Exchange), not deep research. Report findings in 1-2 lines and move on. If native support or a community addon exists, stop. Otherwise proceed to Step 2 immediately.
listArduinoLibraries
If the peripheral is in the list, tell the user and STOP. Do NOT proceed to Step 2
or beyond. Do NOT generate custom library code. Common built-in:
I2C, SPI, Serial, Servo, RotaryEncoder, Ultrasonic, ShiftRegister
Search for existing add-ons contributed by the MathWorks MATLAB Hardware Team:
site:mathworks.com/matlabcentral/fileexchange Arduino <peripheral>+arduinoioaddons folder structureIf a MathWorks-contributed add-on is found, guide the user through installation:
addpath the folder containing +arduinoioaddonsarduinoio.customLibrary.downloadLibrarylistArduinoLibrariesSTOP here if a MathWorks add-on is found — do NOT proceed to Step 2 or beyond.
Before creating a custom library, the user MUST provide:
MyDHT22)DHT22, U8g2)Do NOT proceed to any further steps until all required inputs are provided. If any are missing, ask the user explicitly and wait for their response.
% R2025a+ — use downloadLibrary (preferred)
arduinoio.customLibrary.downloadLibrary("<ArduinoLibraryName>")
% Accepts: library name, name@version, GitHub URL, or local .zip path
% Examples:
arduinoio.customLibrary.downloadLibrary("DHT22")
arduinoio.customLibrary.downloadLibrary("U8g2")
arduinoio.customLibrary.downloadLibrary("https://github.com/olikraus/u8g2")
Verify installation:
dir(fullfile(arduinoio.CLIRoot, 'user', 'libraries'))
For R2024a-R2024b (no downloadLibrary): manually extract the library zip into
fullfile(arduinoio.CLIRoot, 'user', 'libraries', '<LibName>').
For pre-R2024a (no CLIRoot): use arduinoio.IDERoot instead of arduinoio.CLIRoot.
% R2025a+ — use createLibraryTemplate (preferred)
arduinoio.customLibrary.createLibraryTemplate("<CustomLibraryName>")
This creates the folder structure in the current working directory (pwd) and adds the path automatically. After calling it, the generated files are at:
<pwd>/+arduinoioaddons/+<CustomLibraryName>Folder/<CustomLibraryName>.m
<pwd>/+arduinoioaddons/+<CustomLibraryName>Folder/src/<CustomLibraryName>.h
Do NOT search other locations — the files are always in pwd.
Naming: createLibraryTemplate("X") creates +XFolder/X.m — it appends "Folder"
to the package name automatically. The generated setup() has placeholder comments —
clear the body (no .begin() calls). The generated loop() is unused and can be deleted.
For pre-R2025a: create the folder structure manually:
<targetDir>/+arduinoioaddons/+<FolderName>/<ClassName>.m
<targetDir>/+arduinoioaddons/+<FolderName>/src/<HeaderName>.h
Then register:
addpath('<targetDir>');
savepath;
Update the generated .m file. See "MATLAB Class Property Rules" below for exact values.
Add minimal comments to the generated .m file for user understanding:
DependentLibraries is empty)Update the generated .h file. See "C++ Header Rules" below and read
references/cpp-patterns.md for templates.
Add minimal comments to the generated .h file for user understanding:
#define explaining the commandcommandHandler for each case describing what it doeslistArduinoLibraries % Must show your library name
a = arduino("<port>", "<board>", "Libraries", "<FolderName>/<ClassName>");
obj = addon(a, "<FolderName>/<ClassName>", <args>);
| Property | Format | Example | Notes |
|---|---|---|---|
LibraryName | 'FolderName/ClassName' | 'Adafruit/DHT22' | Must match namespace |
DependentLibraries | Cell of MATLAB addon names | {} or {'I2C'} | See decision table below |
LibraryHeaderFiles | '<ArduinoLibFolder>/<header.h>' | 'DHT/DHT.h' | Folder name in CLIRoot + header filename |
CppHeaderFile | fullfile(arduinoio.FilePath(mfilename('fullpath')), 'src', '<Name>.h') | — | Always this pattern |
CppClassName | Must match C++ class name | 'DHT22Base' | Exact match required |
| Scenario | Value | Reason |
|---|---|---|
| GPIO-only peripheral (DHT, NeoPixel) | {} | No MATLAB bus dependency |
| I2C device using SW_I2C (displays, most sensors) | {} | Software I2C bypasses MATLAB's bus |
| I2C device delegating to MATLAB's I2C infrastructure | {'I2C'} | MATLAB manages Wire init and pins |
| SPI device | {} | MATLAB does not own SPI bus |
| Uses another custom addon | {'OtherAddon/Name'} | Chain dependency |
Format: '<FolderNameInCLIRoot>/<HeaderFilename>'
% GOOD — folder name matches what's in CLIRoot/user/libraries/
LibraryHeaderFiles = {'DHT/DHT.h'}
LibraryHeaderFiles = {'U8g2/U8g2lib.h'}
LibraryHeaderFiles = {'Adafruit_Motor_Shield_V2_Library/Adafruit_MotorShield.h'}
% BAD — just filename without folder
LibraryHeaderFiles = {'DHT.h'}
% BAD — subdirectory path (NEVER include src/ even if the file physically lives there)
LibraryHeaderFiles = {'U8g2/src/U8g2lib.h'}
% BAD — Arduino library name (Wire is not in CLIRoot/user/libraries)
LibraryHeaderFiles = {'Wire/Wire.h'}
The Arduino build system automatically searches the src/ subdirectory within
the library folder, so NEVER include src/ in this path. This is the most
common mistake — even though headers like U8g2lib.h physically reside in
<LibFolder>/src/, you must write 'U8g2/U8g2lib.h' NOT 'U8g2/src/U8g2lib.h'.
Read references/cpp-patterns.md for full templates. Critical rules:
setup() MUST NOT initialize hardware — calling .begin(), Wire.begin(),
SPI.begin() etc. in setup() causes "Internal error: The initialization of the
server code is incorrect." Simple variable assignments (e.g., cursorRow = 0) are safe.sendResponseMsg must send >= 1 byte — sendResponseMsg(cmdID, 0, 0) crashes ARM boards (UNO R4, ESP32)#include <Wire.h> in your addon header — causes I2C bus conflict with MATLAB.
Your code must never contain this line. Third-party libraries may include it internally
(that is fine — you don't control their code), but YOUR .h file must not.#include <SPI.h> is safe — MATLAB does not own SPI#include <U8g2lib.h>references/bus-conflicts.mdMATLAB owns the hardware I2C bus (Wire). If your peripheral uses I2C:
U8G2_..._SW_I2C) with DependentLibraries = {}Wire.begin() directly#include <Wire.h> in your own addon headerIf the third-party library requires hardware I2C (e.g., SGP30, motor shields): set
DependentLibraries = {'I2C'} and let MATLAB manage the bus. The third-party library
may include Wire.h internally — this is safe because MATLAB has already initialized Wire.
Your C++ code must NOT call Wire.begin() since MATLAB already did.
| Mistake | Why It's Wrong | Correct Approach |
|---|---|---|
DependentLibraries = {'Wire'} | Wire is not in listArduinoLibraries | Use {} or {'I2C'} |
Third-party lib in +arduinoioaddons/src/ | Wrong location; build can't find it | arduinoio.CLIRoot/user/libraries/ |
LibraryHeaderFiles = {'U8g2lib.h'} | Missing folder prefix | {'U8g2/U8g2lib.h'} |
U8G2_..._HW_I2C constructor | Conflicts with MATLAB's Wire management | Use _SW_I2C constructor |
.begin() calls in setup() | Server handshake fails | Init hardware via command; variable assignments are OK |
sendResponseMsg(cmdID, 0, 0) | Crashes ARM boards (nullptr) | Send >= 1 byte always |
#include <Wire.h> in your addon header | Conflicts with MATLAB I2C server | Omit; use SW_I2C or DependentLibraries = {'I2C'} |
| Installing via Arduino IDE Library Manager | MATLAB uses its own CLIRoot path | Use downloadLibrary() |
Not calling addpath after creating addon | listArduinoLibraries won't find it | addpath + savepath |
downloadLibrary (R2025a+) or manual copy to CLIRoot for third-party libslistArduinoLibraries after registration.begin() or hardware init in setup() — use lazy init via dedicated commandsendResponseMsg<Wire.h> in your own code — use software I2C or depend on {'I2C'}+arduinoioaddonscreateLibraryTemplate (R2025a+) over manual folder creationIf listArduinoLibraries hangs, File Exchange search takes too long, downloadLibrary
fails, or createLibraryTemplate fails — fall back to the pre-R2025a manual approach:
fullfile(arduinoio.CLIRoot, 'user', 'libraries', '<LibName>').<targetDir>/+arduinoioaddons/+<FolderName>/<ClassName>.m
<targetDir>/+arduinoioaddons/+<FolderName>/src/<HeaderName>.h
addpath('<targetDir>'); savepath;Do not retry failing commands repeatedly. Switch to manual creation and proceed.
When errors occur during deployment or usage, read the appropriate reference:
references/common-errors.mdreferences/common-errors.mdreferences/bus-conflicts.mdreferences/cpp-patterns.mdCopyright 2026 The MathWorks, Inc.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
arduino-library, matlab-arduino, custom-addon, sensor-wrapper
/test-and-measurement:matlab-create-custom-arduino-libraryfrom test-and-measurement
npx claudepluginhub matlab/matlab-agentic-toolkit --plugin test-and-measurement13 skills in this plugin
/matlab-build-industrial-hmiBuild industrial-grade SCADA/HMI dashboards in MATLAB following industrial-HMI conventions (ISA-101-aligned): gray-field philosophy, alarms at source, write safeguards, fixed-range trends, drill-down layout. Produces a real App Designer app (.mlapp, or plain-text .m+.xml on R2026b+) by handing serialization to the matlab-build-app skill when available, and falls back to a programmatic .m app otherwise. Use when wrapping OPC UA / Modbus / MQTT / OSI PI / PI AF monitoring scripts into a live operator app, building plant overviews, designing operator dashboards, or any time a user asks for a "SCADA dashboard", "HMI", "plant dashboard", "operator screen", or "industrial monitoring app" in MATLAB. Trigger on: SCADA, HMI, industrial dashboard, plant overview, operator screen, uigauge, uilamp, alarm banner, gray-field, ISA-101, OPC UA dashboard, setpoint, write safeguards, alarm visualization, OSIsoft PI, AVEVA PI, PI Server, PI Data Archive, PI AF, PI Asset Framework, piclient, afclient.
/matlab-call-nidaqmxTranslate NI-DAQmx C function signatures into correct calldaqlib MATLAB calls. Use when the user mentions calldaqlib, any DAQmx* C function name (DAQmxCfgSampClkTiming, DAQmxExportSignal, DAQmxSetStartTrigRetriggerable, DAQmxGetSampClkRate, etc.), or needs NI-DAQmx functionality not exposed by the daq object. Covers: projection rules (taskHandle implicit, output pointers become return values, buffer-size args, enum-as-string), multi-task semantics, start() clobber, device-level empty-daq workaround, dictionary returns, string getter placeholder, array getter placeholder. Trigger contexts: low-level DAQ, escape hatch, retriggerable acquisition, shared timebase, export signal, connect terminals, external sample clock, trigger configuration, NI driver, C function translation.
Other plugins' skills for the same job