0
我想通過智能手機控制我的domotic房子,智能手機通過互聯網(Wi-Fi)發送3-4字節到樹莓和樹莓發送所有這些字節到相應的Arduino通過I2C總線(我有兩個Arduinos)。 當我發送命令給樹莓時,它顯示「無法寫入i2c總線」 任何人都可以幫助我嗎?樹莓錯誤寫在i2c插座
int i2csend(msg_t *pmsg)
{
int fd;
/* Open I2C device */
if ((fd = open(device, O_RDWR)) < 0) error ("Can't open I2C device");
if (ioctl(fd, I2C_SLAVE, arduino_addr) < 0) error ("Can't talk to slave");
if (write(fd, (char *)pmsg, n) < n) printf ("Failed to write to the i2c bus [1]\n");
else
{
read(fd, (char *)pmsg, n);
printf("Ricevuto il messaggio: %c%c %d %d\n", pmsg->tipo, pmsg->gruppo, pmsg->dato[0], pmsg->dato[1]);
}
close(fd);
return 0;
}
謝謝,但我已經解決了。我沒有連接銼刀和arduino地面。我沒有這樣做,因爲我第一次使用USB總線接地並且工作正常。這次我使用了分離的電源。 –