PySerial Docs
Cross-platform Python library for serial port communication. Works with Arduino, Raspberry Pi, and industrial devices on Windows, Linux, and macOS.
PySerial lets Python talk to anything connected over a serial port: Arduino boards, GPS modules, industrial sensors, barcode scanners, CNC controllers, Modbus devices. It works on Windows, Linux, macOS, and Raspberry Pi with the same API.
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1)
ser.write(b'Hello\n')
print(ser.readline().decode().strip())
ser.close()Get Started
Installation
pip install, conda, virtual environments
Getting Started
Open a port, send and receive data
Configuration
Baud rate, parity, flow control, timeouts
API Reference
Every method, property, and constant
Platforms & Devices
Arduino
Read sensors, control actuators from Python
Raspberry Pi
UART setup, GPIO serial, USB devices
GPS & NMEA
Parse position data from GPS modules
Modbus RTU
Communicate with industrial PLCs and meters
Go Deeper
Examples
Working code for real hardware projects
Data Logging
Log serial data to CSV and SQLite
High-Speed Serial
Optimize throughput at high baud rates
Common Errors
Fix PermissionError, timeouts, and port not found
Community & Support
Join the Discord community for help, discussions, and to connect with other developers using PySerial.