[英]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 我正在使用模块max31865和pt100传感器来测量温度,但是运行程序时出现问题,因为出现此错误
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. 亲切的问候。
Are you very sure that should not be board.SCLK
? 您确定不应该使用
board.SCLK
吗? Your code seems to be quite close to this example and that is how the constant is spelled there. 您的代码似乎与本示例非常接近, 这就是常量在此处拼写的方式。
您是否在raspi-config
启用了I2C接口?
这为我做到了
sudo pip3 install --force-reinstall adafruit-blinka
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.