So I need to transfer a byte on the spi interface on raspberry pi. Here's my code in python

import spidev
import time
import binimp



spi = spidev.SpiDev() #create spi object
spi.open(0, 1) #open spi port 0, device (CS) 1
spi.max_speed_hz = 976000

 while True:
     for i in final:
         resp = spi.xfer2([ord(i)])
except KeyboardInterrupt: # Ctrl+C pressed, so…
    spi.close() # … close the port before exit

Basically I'm just sending a byte one by one to the SPI (ignore the newbinimp functions, they're basically generating a sequence of characters). The issue is that there is a lot of time in between each consecutive byte transfer as shown in the imageSPI on logic analayzer. I'm using a logic analyzer to see the bytes being transferred. As you can see there is a 61.4 micro second wait before each byte is transferred. Is there any way to reduce this time? Thank you so much**Python code made easier to read**

  • I thought you could send a long list of bytes by the spidev command writebytes2(list of values) - pypi.org/project/spidev
    – tlfong01
    Jun 13, 2019 at 13:02

1 Answer 1


Why don't you send multiple bytes in one transfer?

If you have to send byte by byte I suggest you use C instead of Python.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.