Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Not sure if I'm following MAX31865 for python installation c
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Not sure if I'm following MAX31865 for python installation c

by juliusau93 on Sun Mar 01, 2020 4:39 pm

Question: Why am I getting the errors and how do I get the results to print on Thonny Python IDE not using REPL?


I typed sudo pip3 install adafruit-circuitpython-max31865 in the terminal and it says downloads complete.
I have connected the MAX to the right pins with power and grounded it and copied the code below.
I am using a 3 wire PT100 RTD and I'm new to python.

Code: Select all | TOGGLE FULL SIZE
import time
import board
import busio
import digitalio
import adafruit_max31865
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D5)  # Chip select of the MAX31865 board.
sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100, ref_resistor=430.0, wires=3) #changed the 2 to 3
 

while True:
    temp = sensor.temperature
    print('Temperature: {0:0.3f}C'.format(temp))
    time.sleep(1.0)


The error its giving me is
Code: Select all | TOGGLE FULL SIZE
Could not open SPI device - check if SPI is enabled in kernel!
Traceback (most recent call last):
  File "/home/pi/Desktop/Test.py", line 14, in <module>
    sensor = adafruit_max31865.MAX31865(spi, cs, rtd_nominal=100.0, ref_resistor=430.0, wires=3)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_max31865.py", line 107, in __init__
    config = self._read_u8(_MAX31865_CONFIG_REG)
  File "/usr/local/lib/python3.7/dist-packages/adafruit_max31865.py", line 123, in _read_u8
    device.write(self._BUFFER, end=1)
  File "/usr/local/lib/python3.7/dist-packages/busio.py", line 207, 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 49, in write
    self._spi.open(self._port, 0)
FileNotFoundError: [Errno 2] No such file or directory

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: Not sure if I'm following MAX31865 for python installati

by tannewt on Mon Mar 02, 2020 8:36 pm

What type of computer are you running on?

tannewt
 
Posts: 1727
Joined: Thu Oct 06, 2016 8:48 pm

Re: Not sure if I'm following MAX31865 for python installati

by juliusau93 on Mon Mar 02, 2020 11:15 pm

RP4 raspbian OS

juliusau93
 
Posts: 22
Joined: Tue Dec 17, 2019 12:33 am

Re: Not sure if I'm following MAX31865 for python installati

by MakerMelissa on Tue Mar 03, 2020 1:49 pm

Hi,

Make sure you have SPI enabled. You can check if it's enabled by typing:
Code: Select all | TOGGLE FULL SIZE
ls /dev/spi*

You should see a response like:
Code: Select all | TOGGLE FULL SIZE
/dev/spidev0.0 /dev/spidev0.1

If it's not enabled, you can follow this guide to enable it:
https://learn.adafruit.com/adafruits-ra ... guring-spi

Thanks,
Melissa

MakerMelissa
 
Posts: 155
Joined: Wed Jun 05, 2013 2:10 am

Please be positive and constructive with your questions and comments.