I am new at I2C communication.
I am currently writing to the grovepi using the write() function in C, however,
sometimes I get an write error which I assume is when the grove pi is not ready (error doesn’t occur if a delay is added).
I took a look at the python library and saw that a 100 millisecond wait is required before reading from the device.
I am wondering is there are existing flow control methods or techniques with I2C I can use to tell if the device is ready for writing / reading
or if there are plans on adding them. Such as having a default read value when the device is busy?
There is no hardware flow control that we can use with the I2C. Basically when you send a command to the GrovePi you have to account for both the signal propagation time as well as the time the MCU will take to process a command and get the data ready which can be sent back. If you issue the commands instantaneously without any delay, you’ll most probably face problems. The GrovePi usually does all this is less than 10ms but it is usually good to put delays above 50ms to keep everything working properly. We have the C library for another product of ours, the GoPiGo: https://github.com/DexterInd/GoPiGo/blob/master/Software/C/gopigo.c which is very similar to the GrovePi so you should be able to looks for hints in that.