I'm trying to read 2 devices from SPI bus nRF24 module and MAX31865. I read the MAX module constantly every second and need to read the nRF24 module from time to time in other binary, but when I just do it simultaneously MAX is working just fine but nRF24 module sending wrong data ex. 1024 instead of 988. I modified
/boot/config.txt and added the
dtoverlay=spi1-3cs line and got the
/dev/spidev1.* show up, but when I try to read from that I got an error
Traceback (most recent call last): File "testpt.py", line 9, in <module> sensor = adafruit_max31865.MAX31865(spi, cs, wires=4) File "/usr/local/lib/python3.7/dist-packages/adafruit_max31865.py", line 136, in __init__ config = self._read_u8(_MAX31865_CONFIG_REG) File "/usr/local/lib/python3.7/dist-packages/adafruit_max31865.py", line 160, in _read_u8 device.write(self._BUFFER, end=1) File "/usr/local/lib/python3.7/dist-packages/busio.py", line 349, in write return self._spi.write(buf, start, end) File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 81, in write self._spi.mode = self.mode File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 344, in mode self._ioctl(SPI._IOC_WR_MODE, mode) File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 224, in _ioctl ioctl(self.handle, ioctl_bytes, arg) OSError: [Errno 22] Invalid argument
My code is
from time import sleep import board import busio import digitalio import adafruit_max31865 spi = busio.SPI(board.D21, MOSI=board.D20, MISO=board.D19) cs = digitalio.DigitalInOut(board.D16) sensor = adafruit_max31865.MAX31865(spi, cs, wires=4) while(1): temp = sensor.temperature print(temp) sleep(2)
For now (testing this new SPI bus) I just trying to read MAX31865 output via SPI the nRF module is connected but never called.