Hi
As I experienced, Raspberry pi has some problems during reading data from Alphasense sensor. If you manually test a connected sensor using terminal and see that alphasense.ping() returns a value, but running your code returns a reading error, firstly check your wiring, After that just simply add one second delay (using sleep command) before calling alphasense.histogram() function. As an example, see following code:
import spidev
import opc
from time import sleep
spi = spidev.SpiDev()
spi.open(0, 0)
spi.mode = 1
spi.max_speed_hz = 500000
alphasense = opc.OPCN2(spi)
# Turn the opc ON
alphasense.on()
# Add one second delay before reading histogram values
sleep(1.0)
# Read the histogram
print (alphasense.histogram())
# Turn the opc OFF
alphasense.off()
Hi As I experienced, Raspberry pi has some problems during reading data from Alphasense sensor. If you manually test a connected sensor using terminal and see that alphasense.ping() returns a value, but running your code returns a reading error, firstly check your wiring, After that just simply add one second delay (using sleep command) before calling alphasense.histogram() function. As an example, see following code: