Nicholas Warren
Nicholas Warren

Reputation: 1

Adafruit MAX 31856 communicating with raspberrypi

I have been trying to read a thermocouple temperature on my raspberrypi however cant get the raspi to communicate with the adafruit MAX 31856. I have downloaded necessary libraries and checked that all connections are secure and correct however keep running into this error when I try to execute this code.

Any help is greatly appreciated!!

CODE

   import board 
   import digitalio 
   import adafruit_max31856 
   spi = board.SPI() 
   cs = digitalio.DigitalInOut(board.D5) 
   cs.direction = digitalio.Direction.OTUPUT 
   thermocouple = adafruit_max31856.MAX31856(spi,cs) 
   print(thermocouple.temperature) 

ERROR:

Traceback (most recent call last): 

  File "/home/pi/test4.py", line 6, in <module> 

    spi = board.SPI() 

  File "/usr/local/lib/python3.7/dist-packages/board.py", line 299, in SPI 

    return busio.SPI(SCLK, MOSI, MISO) 

  File "/usr/local/lib/python3.7/dist-packages/busio.py", line 289, in __init__ 

    self._spi = _SPI(portId) 

  File "/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/generic_linux/spi.py", line 25, in __init__ 

    self._spi = spi.SPI(device=(portid, 0)) 

  File "/usr/local/lib/python3.7/dist-packages/Adafruit_PureIO/spi.py", line 167, in __init__ 

    raise IOError("{} does not exist".format(device)) 

OSError: /dev/spidev0.0 does not exist

Code Errors

Upvotes: 0

Views: 207

Answers (2)

Stackdump286
Stackdump286

Reputation: 1

I hit this exact error and resolved the issue by using "raspi-config" to enable the SPI interface.

The exact steps:

  1. Run "sudo raspi-config"
  2. Select "Interface Options"
  3. Select "SPI"
  4. It will ask "Would you like the SPI interface to be enabled"?
  5. Select "Yes", and "Ok"
  6. Once enabled you can exit the tool by using to select "Finished" then press

Once the SPI interface is enabled you should no longer receive the SPI errors from board.py

Note: No overlay or changes in config.txt should be required.

Upvotes: 0

AlexM
AlexM

Reputation: 1

Most probably there is a device driver loaded for spi0-0 and that removes /dev/spidev0.0 device. check your /boot/config.txt for overlays loading MAX 31856 driver module. if you want to use adafruit_max31856 lib you shouldn't be loading this driver. hope that helps

Upvotes: 0

Related Questions