0

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.

2
  • Could you post a schematic of how it is wired. You can put many devices on a single SPI bus but each device needs a chip select that selects it only when the RP is communicating with it.
    – Gil
    Feb 24 at 0:34
  • I'm ripping the project off I think the nRF24 module do not like when I even plug the MAX31865 on spi bus. When I plug the MAX module transmission is recieving wrong data and when I unplug it it get correct data and I have no idea why so I think I'm going come up with different solution. Or maybe you know why this is the case that when I connect MAX module transmission is off? Like when I plug in MAX the nRF24 transimssion is of and I recieve weird data like \x17\x17 when sending static 2 as uint_16 value Feb 24 at 14:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.