Thank you for your response. I don't fully understand the arguments - especially:
i2c = new I2C(I2C.list()[0]);
I am trying to get processing to read in an array of 9 bytes (processing will be running on a pi). I should point out that I'm a beginner when it comes to both processing and i2c. And the pi for that matter!
@The_Idiot Let me try to answer this: a system might have more than one I2C interface - there is thus a list() method to retrieve an array of available interface names.
Try:
printArray(I2C.list());
To start communicating with a "slave" device connected to any of those I2C busses, you construct a new I2C object by passing the interface name to it's constructor like e.g.:
i2c = new I2C("i2c-2");
And the snippet you posted will simply attempt to use the first I2C interface found...
Hello,
I have written some code to implement functionalities for the I2C devices in the Sense HAT. You can find them here:
https://github.com/PBernalPolo/RPiModules
I thought it might be interesting for someone looking for examples of I2C communication.
Thank you @pbp. Very timely! I've been messing about with I2C and your examples clarified a number of points for me. Who knows. Maybe I'll brave the humidity and pressure sensors too. Kudos. :)
Answers
Do you mean this example?
What about it don't you understand -- or what are you trying to do that it doesn't demonstrate?
Thank you for your response. I don't fully understand the arguments - especially:
i2c = new I2C(I2C.list()[0]);
I am trying to get processing to read in an array of 9 bytes (processing will be running on a pi). I should point out that I'm a beginner when it comes to both processing and i2c. And the pi for that matter!
@The_Idiot Let me try to answer this: a system might have more than one I2C interface - there is thus a
list()
method to retrieve an array of available interface names.Try:
To start communicating with a "slave" device connected to any of those I2C busses, you construct a new I2C object by passing the interface name to it's constructor like e.g.:
And the snippet you posted will simply attempt to use the first I2C interface found...
That makes sense, seems obvious now! Thank you!!
Hello, I have written some code to implement functionalities for the I2C devices in the Sense HAT. You can find them here: https://github.com/PBernalPolo/RPiModules
I thought it might be interesting for someone looking for examples of I2C communication.
@pbp Thxs for sharing.
Kf
That's awesome @pbp. Thank's a lot. I'll give this a shot in a couple days and will send pull-requests if anything catches my mind.
Thank you @pbp. Very timely! I've been messing about with I2C and your examples clarified a number of points for me. Who knows. Maybe I'll brave the humidity and pressure sensors too. Kudos. :)