Discover and connect to Bluetooth Low Energy (BLE) peripherals from MATLAB. Covers scanning, connecting, reading/writing characteristics, and subscribing to notifications for sensor and IoT data.
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; scripts run unread.
Guides the agent through discovering, connecting to, and accessing characteristics on BLE peripheral devices, ensuring efficient use of filtering APIs and correct function signatures.
BLE functions are part of MATLAB — no additional toolbox is required. Do not reference the Bluetooth Toolbox for BLE functionality — it is not needed.
bluetooth() object — different API)matlab-connect-arduino)Follow these steps in order. Do not skip steps or guess values.
Always check first — a connected BLE device stops advertising, so scanning will never find it:
% Check for existing ble objects in workspace
bleVars = whos;
bleVars = bleVars(strcmp({bleVars.class}, 'ble'));
If a ble object exists and its Connected property is 1:
If a ble object exists but Connected is 0, it is stale — proceed
to Step 1.
Use filtered scanning when possible. Do not scan all devices and then search through results manually.
| User provides | Use this call |
|---|---|
| Device name | blelist("Name", "<name>") |
| Service UUID | blelist("Services", "<uuid>") |
| Nothing specific | blelist("Timeout", 10) |
% Filter by name (prefix match)
devices = blelist("Name", "HeartSensor");
% Filter by advertised service UUID
devices = blelist("Services", "180D");
% General scan with extended timeout
devices = blelist("Timeout", 10);
Filters can be combined:
devices = blelist("Name", "Sensor", "Timeout", 15);
blelist returns a table with columns: Name, Address, RSSI, Advertisement.
Results are sorted by signal strength (strongest first).
Present results to the user.
If blelist returns an empty table:
blelist("Timeout", 20)Present the discovered devices and ask which to connect to. Never auto-select a device.
If only one device matches a filtered scan (e.g., blelist("Name","MyDevice")
returned exactly one row), confirm with the user: "Found [Name] at
[Address]. Shall I connect?"
% Connect by name (substitute the user's actual device name)
b = ble("HeartSensor");
% Connect by address (use when name is empty or ambiguous)
b = ble("A1B2C3D4E5F6");
After connecting, confirm to the user:
If the connection succeeds but a service shows "Access denied":
clear b
in the other session, or close it), then reconnect from this session.If the connection fails entirely:
Inspect available services and characteristics:
% View all services
b.Services
% View all characteristics (includes service, name, UUID, attributes)
b.Characteristics
To access a specific characteristic, use the two-UUID signature:
% Access by service UUID + characteristic UUID
c = characteristic(b, "<serviceUUID>", "<characteristicUUID>");
% Access by service name + characteristic name (standard services only)
c = characteristic(b, "Battery Service", "Battery Level");
Important: characteristic() always requires both a service
identifier and a characteristic identifier. Never call it with just
one UUID.
Never invent or assume device names, addresses, service UUIDs, or
characteristic UUIDs. Use only values provided by the user or
discovered from blelist / b.Characteristics.
If characteristic access fails:
b.Characteristics
to find the correct service and characteristic UUIDs.% Read raw bytes from a characteristic (returns numeric array)
data = read(c);
% Read with timestamp
[data, timestamp] = read(c);
% Read oldest buffered notification (use in DataAvailableFcn callbacks)
data = read(c, "oldest");
% Write data to a characteristic
write(c, [1 0 1 0]);
% Write without response (faster, no confirmation)
write(c, [1 0 1 0], "WithoutResponse");
% Subscribe to notifications
subscribe(c);
c.DataAvailableFcn = @(src, evt) disp(read(src));
% Unsubscribe
unsubscribe(c);
read and write operate on characteristic objects, not on the ble
object directly. Never use read(b, uuid) — this will error.
| Function | Purpose |
|---|---|
blelist | Scan for BLE peripherals (with optional Name/Services/Timeout filters) |
ble(name) | Connect to a BLE device by advertised name |
ble(address) | Connect to a BLE device by MAC address |
characteristic(b, svcID, charID) | Access a characteristic (requires both service and characteristic identifiers) |
read(c) | Read data from a characteristic object |
write(c, data) | Write data to a characteristic object |
subscribe(c) | Subscribe to notifications/indications |
unsubscribe(c) | Unsubscribe from notifications/indications |
All functions are part of MATLAB — no toolbox required.
% TEMPLATE — not executable without hardware
% Step 0: Check workspace
bleVars = whos;
bleVars = bleVars(strcmp({bleVars.class}, 'ble'));
% Step 1: Filtered discovery
devices = blelist("Name", "TempLogger");
% Step 3: Connect
b = ble("TempLogger");
% Step 4-5: Access and read custom characteristic
c = characteristic(b, "181A", "2A6E");
data = read(c);
% TEMPLATE — not executable without hardware
% Find devices advertising a specific service
devices = blelist("Services", "180D");
% Connect to the first match (after user confirms)
b = ble(devices.Name(1));
% List characteristics under that service
b.Characteristics
% TEMPLATE — not executable without hardware
% Check if 'b' already exists and is connected
if exist('b', 'var') && isa(b, 'ble') && b.Connected
disp("Reusing existing connection to " + b.Name);
else
b = ble("MyDevice");
end
% Access characteristic on existing connection
c = characteristic(b, "180F", "2A19");
batteryLevel = read(c);
% TEMPLATE — not executable without hardware
c = characteristic(b, "180D", "2A37");
subscribe(c);
c.DataAvailableFcn = @(src, evt) processHeartRate(read(src));
% Later: clean up
unsubscribe(c);
When the user wants to log or collect BLE data over a time period,
use DataAvailableFcn with subscribe/unsubscribe — do not poll with
read(c) in a loop (polling misses data between reads and may flush the
buffer).
Deploy scripts/bleDataCollector.m to the user's working directory and run:
% TEMPLATE — not executable without hardware
% Log notifications to a tab-separated text file for 10 seconds:
bleDataCollector(b, "<serviceUUID>", "<charUUID>", 10, "sensorLog.txt")
Output file format (one row per notification):
2026-06-25 10:30:01.0529 3 12 255
2026-06-25 10:30:01.2478 4 13 0
Key points for notification-based logging:
DataAvailableFcn to a callback that calls read(src, "oldest") —
using "oldest" reads buffered notification data in order; "latest" may
flush and lose earlier packetssubscribe(c) to start receiving notifications, unsubscribe(c) to
stoppause(duration) keeps MATLAB alive while callbacks fire — this is NOT
polling, it is the idle loop that allows notifications to be deliveredunsubscribe, clear DataAvailableFcn, and fclose when done.txt with tab separation — BLE packets vary in length, so
fixed-column CSV is impracticalScript: scripts/bleDataCollector.m (bundled with this skill — deploy to the user's working directory before use)
| Mistake | Why It's Wrong | Correct Approach |
|---|---|---|
Using unfiltered blelist when name/service is known | Scans all devices unnecessarily; slower and noisier | Use blelist("Name","...") or blelist("Services","...") |
Calling read(b, uuid) on the ble object | read works on characteristic objects, not ble objects — will error | Create characteristic first: c = characteristic(b, svc, char), then read(c) |
Using blescanner | This function does not exist in MATLAB | Use blelist (with optional name-value filters) |
| Saying BLE requires "Bluetooth Toolbox" | BLE functions are part of MATLAB — no toolbox needed | Do not check for or reference the Bluetooth Toolbox |
| Scanning for a device that is already connected | Connected devices stop advertising — scan will never find them | Check workspace for existing ble objects first (Step 0) |
Calling characteristic(b, uuid) with one UUID | Requires both service and characteristic identifiers | Use characteristic(b, serviceUUID, characteristicUUID) |
| Auto-selecting a device without user confirmation | User may have multiple devices; wrong choice wastes time | Always present options and ask which device to connect to |
| Diagnosing "Access denied" as a pairing issue | Usually caused by another session holding the connection, not missing pairing | Ask user to disconnect from other MATLAB sessions first |
ble connections before scanning — connected devices stop advertisingblelist when name or service UUID is known — never scan all and search manuallyread/write/subscribe operate on characteristic objects, not ble objectscharacteristic() requires two identifiers: service + characteristicCopyright 2026 The MathWorks, Inc.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/test-and-measurement:matlab-connect-bluetooth-low-energy-devicefrom 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.
/matlab-connect-arduinoDiscover, configure, and connect to Arduino boards from MATLAB using the Arduino Support Package. Use this skill when the user wants to set up an Arduino board, connect to Arduino hardware, find connected boards, scan serial ports, configure Arduino libraries, or any task that requires an Arduino connection as a prerequisite (e.g., blink LED, read sensor, read digital pin, read analog pin, write pin, plot sensor data, scan I2C, use ultrasonic sensor, control servo, read temperature, read voltage, data logging from hardware). Triggers on: arduino, board setup, COM port, serial port, hardware connection, Arduino Nano, Arduino Uno, Arduino Mega, Arduino Micro, Grove, sensor setup, I2C scan, ultrasonic, servo, readDigitalPin, writeDigitalPin, readVoltage, writePWMVoltage, temperature sensor, air pressure, pin read, pin write, analog input.
/matlab-create-custom-arduino-libraryUse when the user wants to use Arduino sensors or peripherals from MATLAB that are not directly supported by the MATLAB Support Package for Arduino Hardware. Triggers on requests to create, wrap, or expose a custom Arduino library to MATLAB. Also triggers on indirect questions like "How do I read humidity in MATLAB?" or "How do I display text on an LCD from MATLAB?" where the answer requires a custom Arduino add-on library. Covers: custom addon creation, third-party Arduino library integration, LibraryBase class, C++ header files, DependentLibraries, arduinoioaddons namespace, I2C/SPI/GPIO peripheral wrappers.
/matlab-discover-hardwareDiscovers connected MATLAB-supported hardware devices, searches by capability, and checks required support packages and add-ons. Use when the user asks what hardware is connected, finds a device that supports a capability (e.g., CAN, analog input), or checks if required support packages or add-ons are installed. Does NOT connect to, configure, or acquire data from devices — defers to device-specific skills for usage workflows./matlab-enhance-camera-imageRead BEFORE troubleshooting or enhancing camera image quality. Diagnoses and enhances image quality from cameras connected via Image Acquisition Toolbox or USB Webcams support package. Discovers camera capabilities at runtime, analyzes captured images for quality issues (brightness, contrast, sharpness, noise, color balance, backlighting), suggests hardware setting adjustments tailored to the specific camera, and applies Image Processing Toolbox enhancement functions. Use when a user wants to improve camera image quality, troubleshoot dark/blurry/noisy/grainy/ overexposed/washed out/color cast images, or optimize camera settings.
Other plugins' skills for the same job