Skip to content

Serial Port

Mark Sherstan edited this page Dec 25, 2019 · 1 revision

Programs and dependencies that communicate near real time with a serial port.

Arduino Serial Source

Use the arduinoSerial.ino as a source for serial port data. The sketch simply reads an integer value from an Analog pin and writes it as bytes with a two byte header check.

C++

Using the MAVlink serial port library, a program was written to decode the serial data from the Arduino sketch. Update the parameters below and then make the program and run.

// Set up the serial port
serial_port.uart_name = "/dev/cu.usbmodem14101";
serial_port.baudrate = 9600;

Python

Inspired by this awesome blog post. A background thread is created for reading a serial port so that the main thread running a computationally intensive task (e.g. - real time plotting) will always have access to the most up to date information. Update the parameters and the custom class will take care of the rest:

# Connect to serial port
portName = '/dev/cu.usbmodem14101'
baudRate = 9600
dataNumBytes = 2
numSignals = 1

MATLAB

See the MATLAB folder two different methods of reading in serial data. The tutorial link can be found here.

Home

MATLAB Functions

Mint Automation

Misc Arduino Sensors

openCV

PoGo

PWM

Python Sleep

Serial Port

Soil Humidity

Stocks

Clone this wiki locally