我面临的问题是,在启动一个通过I2C从Arduino请求数据的脚本时,Pyton在我的raspberry Pi3上抛出了这个IOError
电气连接是完美的,所以这不是问题所在。
此外,在使用i2cget-y10x04时,我也没有收到任何错误
只有python脚本有时很糟糕,我不知道为什么。在
这是我的Arduino代码:
注册并接收请求。
onReceive回调将定义应该将什么类型的数据发送回raspberry。
onRequest回调执行响应。在#include
#include
#define I2C_ADDRESS 0x4
commonFunc GetCountsEverySecond;
int g_iOnRequestActionCode = 0;
unsigned long g_lSecondsSinceStart = 0;
void setup()
{
Wire.begin(I2C_ADDRESS);
Wire.onRequest(sendDataOverI2CGateway);
Wire.onReceive(defineOnRequestAction);
}
void loop()
{
tickSeconds();
}
void tickSeconds()
{
if (GetCountsEverySecond.TimeTriggerAt(1000))
{
g_lSecondsSinceStart++;