I2C 인터페이스를 사용하여 간단한 프로젝트를 만들려고합니다.Raspberry Pi : I2C를 통한 통신 문제
라즈베리 파이에#include <Wire.h>
void setup() {
Wire.begin(8);
Wire.onRequest(requestEvent);
}
void loop() {
delay(100);
}
void requestEvent() {
Wire.write(0x11);
}
이 파이썬 스크립트입니다 :
#!/usr/bin/env python3
import smbus
import time
bus = smbus.SMBus(1)
while True:
try:
data = bus.read_byte_data(0x8, 0)
print(data)
except Exception as e:
print(e)
time.sleep(1)
그리고 여기에 출력입니다 :
17
17
17
17
17
17
17
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
[Errno 5] Input/output error
17
17
17
17
17
[Errno 5] Input/output error
[Errno 5] Input/output error
17
17
이를 위해 나는 항상 단일 바이트를 전송 아두 이노에 스케치를 작성했습니다 내가 알아 내려고하는 것은 데이터를 반환하는 대신 I2C가 오류를 반환하는 임의의 시점에서 발생하는 이유입니다. 하드웨어 변경이 없으며 RPi에서 실행중인 것은 없습니다. 문자 그대로 아무것도 변경되지 않지만 I2C는 작동을 멈 춥니 다.
아이디어가 있으십니까?
I2C에는 일반적으로 단일 마스터가 있으며 주소 지정된 장치는 슬레이브입니다. 보통 프로그램하는 것은 마스터입니다. 노예들은 주인이 응답을 기대하는 명령을 주 (主)가 보내 줄 때까지 절대 보내지 않습니다. Arduino가 전송하는 경우 Pi는 기본값이 아닌지 노예로 작동해야합니다. – barny