I am trying to read some values from a Arduino microcontroller by sending a read request from my PC, but instead of triggering the request callback it is triggering the receive, which does not make sense at all? I am running I2C hence SMBus seems to be significantly slower.
Arduino code:
void dataReceive() {
Serial.println("Receive");
}
void dataRequest() {
Serial.println("Request");
Wire.write(1);
}
void setup()
{
Wire.begin(4);
Wire.onReceive(dataReceive);
Wire.onRequest(dataRequest);
}
PC code:
import smbus
bus = smbus.SMBus(1)
data = bus.read_i2c_block_data(0x04, 0x09, 1)
print data
I get following error aswell:
Traceback (most recent call last):
File "./i2ctest.py", line 16, in <module>
data = bus.read_i2c_block_data(0x04, 0x09, 1)
IOError: [Errno 11] Resource temporarily unavailable
Although i am able to see in the Arduino serial monitor that the dataReceive callback is triggered.