Skip to main content

A simple USB to SPI adapter that works.

Project description

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/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spi_adapter-0.0.5.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

spi_adapter-0.0.5-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file spi_adapter-0.0.5.tar.gz.

File metadata

  • Download URL: spi_adapter-0.0.5.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for spi_adapter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 cf138f493bffd37be944d12e01cdb7d7670225dc8cd8df5f4b6e4bde266cda3e
MD5 9fbab8d1d9a6fc86198105e3edc5f54b
BLAKE2b-256 6a867dcb468e268e3fedcb5708f53964ca03c93f1815f01a2f508c595c235985

See more details on using hashes here.

File details

Details for the file spi_adapter-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: spi_adapter-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for spi_adapter-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 343ef27002c35fe38ecc5b972268619fcb92e6d9252a5523c490eeb33777e94d
MD5 35e09cb58862474835282a262dda3e38
BLAKE2b-256 8afa3c356a6278ea56679bea219665393c5444a2293cc00a2e2969da700e06f9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page