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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: spi_adapter-0.0.6.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.6.tar.gz
Algorithm Hash digest
SHA256 24bf40131644dd9581b200ea47daaaa6971fc304c0e2b8d2b8b220479d92b648
MD5 10ad688e5410709d0b39792135d1f39f
BLAKE2b-256 deb169385cb3884c5cc336649e437203cfed771402c76be728b8810742f78998

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spi_adapter-0.0.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b37fd35ec449d26691b8cbd3a80e5bb539f8070e281dca672ef2a5c8aa21804e
MD5 09e1ba539e3ad5cd8349a1b6827d38e3
BLAKE2b-256 a8b83a747b9f350fc21e5a370ead3fe6e8220f4e0dd35be5ecc6373beeea42ac

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