Hardware

Libraries for programming with hardware.

Serial ports open with pySerial. Past those, pick a Python hardware library by the device you talk to, like Bleak for Bluetooth LE sensors.

How to choose:

  • Serial ports on Windows, macOS, Linux, or BSD: pySerial
  • Bluetooth Low Energy devices, like sensors: Bleak
  • Controlling or monitoring the keyboard and mouse: pynput
  • Global hotkeys: pynput
  • Automated tests on real or virtual hardware, shared across a team or CI: Jumpstarter

Listed in editorial order. Click a column to re-sort the whole list.

Press / to search. Tap a tag to filter. Click any row for details.

Search and filter

Results

Row number Tags
Python serial port access library for Windows, macOS, Linux, and BSD.
pyserial/github.com/pyserial/pyserial / /13,044,930 downloads/month
A library to control and monitor input devices.
moses-palmer/github.com/moses-palmer/pynput / /1,726,505 downloads/month
A cross platform Bluetooth Low Energy Client for Python using asyncio.
hbldh/github.com/hbldh/bleak / /1,633,381 downloads/month
A hardware-in-the-loop testing framework with a Python client library for automated testing on real and virtual hardware.
jumpstarter-dev/github.com/jumpstarter-dev/jumpstarter / /3,799 downloads/month

Hardware guide

pySerial is imported as serial, and serial.Serial opens a port as a context manager. Set a timeout when you open it, or readline() can block forever when no newline arrives. The docs also suggest serial_for_url() over creating Serial directly, so the same code takes a local port, a remote one, or a loop:// loopback for your tests.

pynput sends input through a Controller and watches it through a Listener, for the keyboard and the mouse alike. A listener is a thread that runs your callbacks. On some platforms, notably Windows, a slow callback risks freezing input for every process, so keep callbacks short: hand events to a queue, and let another thread work through it.

Bleak is async, so call asyncio.run() once and do all your Bluetooth work in one async main function. Scan with BleakScanner and connect with BleakClient, each in an async with block, so the device disconnects when the block exits.

Jumpstarter puts your device behind an exporter, which manages its interfaces, and your tests reach it through a client. Local mode needs no Kubernetes or other infrastructure: run jmp shell --exporter <name>, then pytest inside it. When teams share hardware, especially in CI, distributed mode adds a Kubernetes-based controller that leases devices out. Write tests as subclasses of JumpstarterTest, whose client fixture handles the connection.

Jumpstarter builds on the other picks: its serial driver runs on pySerial and takes the port in pySerial's format, and its Bluetooth LE driver runs on Bleak.

Know a project that belongs here?

Tell us what it does and why it stands out.