Я пытаюсь создать простой проект с интерфейсом I2C. Для этого я создал скетч в Arduino, который всегда отправляет один байт:
#include <Wire.h>
void setup() {
Wire.begin(8);
Wire.onRequest(requestEvent);
}
void loop() {
delay(100);
}
void requestEvent() {
Wire.write(0x11);
}
На Raspberry Pi есть скрипт Python:
#!/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 перестает работать.
Любые идеи?