Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix the error 'AttributeError: module 'board' has no attribute 'SCK'' I am using raspberry pi

I am using a modul max31865 and a pt100 sensor to measure the temperature but, I have a problem when i run the program,because appears this error

Traceback (most recent call last):
  File "/home/pi/eduardo/videos/temperature.py", line 5, in <module>
    spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
AttributeError: module 'board' has no attribute 'SCLK'

I don't know what the problem is.

import board
import busio
import digitalio
import adafruit_max31865

spi = busio.SPI(board.SCLK, MOSI=board.MOSI, MISO=board.MISO)
cs = digitalio.DigitalInOut(board.D5)  # Chip select of the MAX31865 board.
sensor = adafruit_max31865.MAX31865(spi, cs, wires=3)

print('Temperature: {0:0.3f}C'.format(sensor.temperature))
print('Resistance: {0:0.3f} Ohms'.format(sensor.resistance))`enter code here`

I expect to read the temperature

Kind regards.

like image 539
Eduardo Rafael Silva Avatar asked Oct 29 '25 06:10

Eduardo Rafael Silva


2 Answers

Are you very sure that should not be board.SCLK? Your code seems to be quite close to this example and that is how the constant is spelled there.

like image 98
BoarGules Avatar answered Oct 30 '25 20:10

BoarGules


This did it for me

sudo pip3 install --force-reinstall adafruit-blinka
like image 36
Mats Avatar answered Oct 30 '25 19:10

Mats



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!