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.4.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

spi_adapter-0.0.4-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for spi_adapter-0.0.4.tar.gz
Algorithm Hash digest
SHA256 25e061c1cda837ed5c6ad3aa618b868f9015b63b5cfc25df993eab82459ef54d
MD5 69314ad00080157e1279bf75cb6d97d3
BLAKE2b-256 33569e035518bd2e11dc19d62f913ad15dab9adce933e0523eb49a19293118ea

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for spi_adapter-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a9c30a71d875d9c95f0bd0390e365a5147e724a64b28f3ee976cbc463e92cfd6
MD5 17c3aba3b00109a932e19fdd16198a5b
BLAKE2b-256 30a48d0a73c95941ee5f4ded52a1d73a1350b5b03feeef66671c1f89ea3a18a7

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