Skip to main content

A Simple USB to SPI Adapter that works.

The SPI Adapter allows python programs to connect to SPI devices using off the shelf low cost boards such the Raspberry Pico or SparkFun Pro Micro - RP2040. The SPI Adapter appears on the computer as a serial port (no device installation required) and acts as a USB to SPI bridge, with the spi_adapter Python package providing an easy to use API.

For example, the diagram below shows the wiring of the oled_demo.py example which drives an SPI OLED display using an SPI Adapter and the luma.oled python package.



Highlights

  • Provides USB to SPI bridge.
  • Supports Windows/Mac/Linux.
  • Uses low cost low cost off-the-shelf boards as adapters.
  • Does not require driver installation (it appears on the computer as standard a serial port).
  • Comes with an easy to use Python API.
  • Easy to modify/extend and to adapt to new hardware.
  • Permissive open source license. Comercial use OK, sharing and attribution not required.
  • Provides additional 8 general purpose auxilary input/output signals.

Python API Example

Package installation

pip install spi-adapter --upgrade

In the example below, we use an SPI Adapter that appears as serial port "COM7" to access an ADS1118 SPI ADC device.

import time
from spi_adapter import SpiAdapter

spi =  SpiAdapter(port = "COM18)

# Single shot, 2.046v FS, Input (A0, GND).
adc_cmd = bytes([0b11000101, 0b10001010, 0x00, 0x00])

while True:
  # Read previous value and start a the next conversion.
  response_bytes = spi.send(adc_cmd, mode=1)
  adc_value = int.from_bytes(response_bytes[0:2], byteorder='big', signed=True)
  print(f"ADC: {adc_value}", flush=True)
  time.sleep(0.5)

Documentation

Full documentation is available at https://spi-adapter.readthedocs.io/

Metadata

Release files for spi-adapter 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spi-adapter 0.0.6
File Size Uploaded
spi_adapter-0.0.6.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spi-adapter 0.0.6
File Interpreter ABI Platform
spi_adapter-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / spi_adapter-0.0.6.tar.gz

Download URL spi_adapter-0.0.6.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
24bf40131644dd9581b200ea47daaaa6971fc304c0e2b8d2b8b220479d92b648
BLAKE2b-256 checksum
How to use checksums
deb169385cb3884c5cc336649e437203cfed771402c76be728b8810742f78998
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / spi_adapter-0.0.6-py3-none-any.whl

Download URL spi_adapter-0.0.6-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b37fd35ec449d26691b8cbd3a80e5bb539f8070e281dca672ef2a5c8aa21804e
BLAKE2b-256 checksum
How to use checksums
a8b83a747b9f350fc21e5a370ead3fe6e8220f4e0dd35be5ecc6373beeea42ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page