Serial communication is the most common low-level protocol for communicating between two or
more devices. Normally, one device is a computer, while the other device can be a modem, a
printer, Arduino® hardware, another computer, or a scientific instrument such as an oscilloscope
or a function generator. For many serial port applications, you can communicate with your
instrument without detailed knowledge of how the serial port works. Communication through a
serial port is established with a
serialport object, which you create in
the MATLAB® workspace. For information about creating a
object, see Create Serial Port Object.
Before you can write or read data, the
serialport object and the instrument
must have identical communication settings. For information, see Configure Serial Port Communication Settings.
|Read data from serial port|
|Read line of ASCII string data from serial port|
|Read one binblock of data from serial port|
|Write data to serial port|
|Write line of ASCII data to serial port|
|Write one binblock of data to serial port|
|Write command to serial port and read response|
Basic features of serial port communication.
Establish a connection between MATLAB and the device using the serial port.
Set properties associated with the device baud rate and serial data format.
Write and read both text and binary data with a serial port device.
Enhance instrument communication by executing a callback function when a specified event occurs on the device.
Signal the presence of connected devices and control the flow of data using control pins.
Connect to serial port devices using
serialport instead of
Try these tips if you have problems using the toolbox with the Serial Port interface. Includes information about Serial Port supported platforms, adaptor requirements, configuration and connection, and other interface-specific tips.