简体   繁体   English

如何修复错误'AttributeError:模块'board'没有属性'SCK'我正在使用树莓派

[英]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.

相关问题 AttributeError: 模块“chess”没有属性“Board”棋盘错误 - AttributeError: module 'chess' has no attribute 'Board' chess board error Raspberry pi 脚本 AttributeError:模块 'datetime' 没有属性 'now' - Raspberry pi script AttributeError: module 'datetime' has no attribute 'now' 如何修复 AttributeError:模块“tensorflow”没有属性“ConfigProto” - How can I fix AttributeError: module 'tensorflow' has no attribute 'ConfigProto' 如何修复此错误“AttributeError:模块‘socket’没有属性‘gethostname’” - How to fix this error "AttributeError: module 'socket' has no attribute 'gethostname'" 树莓派上的 pyvisa-py AttributeError: &#39;module&#39; 对象没有属性 &#39;ResourceManager&#39; - pyvisa-py on raspberry pi AttributeError: 'module' object has no attribute 'ResourceManager' 在树莓派上使用 curses.nodelay(True) 会出现以下错误: AttribureError: 'module' object has no attribute 'nodelay' - using curses.nodelay(True) on raspberry pi gives the following error: AttribureError: 'module' object has no attribute 'nodelay' 在python模块对流层中,我得到一个错误“ AttributeError:&#39;模块&#39;对象没有属性&#39;EBSBlockDeviceMapping&#39;” - In python module troposphere I am getting an error “AttributeError: 'module' object has no attribute 'EBSBlockDeviceMapping'” 为什么我收到此错误(AttributeError:&#39;module&#39;对象没有属性&#39;openssl_md_meth_names&#39;)? - Why I am getting this error(AttributeError: 'module' object has no attribute 'openssl_md_meth_names')? 为什么我会收到此错误? AttributeError: &#39;module&#39; 对象没有属性 &#39;periodogram&#39; - Why am I geting this error? AttributeError: 'module' object has no attribute 'periodogram' AttributeError: 'NoneType' object 没有属性 'attrs',我在尝试从 url 抓取图像时遇到此错误。 我该如何解决? - AttributeError: 'NoneType' object has no attribute 'attrs', I am getting this error while I am trying to scrape images from the url. How can I fix it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM