Athar Rasul
Newbie level 4
Hi,
There are a lot of I2C libraries for Arduino on internet but there is one problem - none of them supports multiple I2C to communicate to devices simultaneously. I needed a library of I2C that could communicate to multiple sensors (having same address) using a single Arduino and much to my disappointment, I couldn't find one. I kept on searching and the best closest thing I could find is 'softi2c' library by fat16lib.
https://forums.adafruit.com/viewtopic.php?f=25&t=13722
I tweaked it a little bit to be able to handle multiple I2C buses at the same time. All buses have software selectable pins and they can either have a shared or independent SCL pins, depending on user requirement. The example code is for VCNL4000. In the example I haven't written different functions for read and write but of course it can be modified. I did it because the sensor is in proximity mode and the Command Register needs to be written each time prior to a valid read. The code is tested for Arduino 1.0. Hopefully this helps.
There are a lot of I2C libraries for Arduino on internet but there is one problem - none of them supports multiple I2C to communicate to devices simultaneously. I needed a library of I2C that could communicate to multiple sensors (having same address) using a single Arduino and much to my disappointment, I couldn't find one. I kept on searching and the best closest thing I could find is 'softi2c' library by fat16lib.
https://forums.adafruit.com/viewtopic.php?f=25&t=13722
I tweaked it a little bit to be able to handle multiple I2C buses at the same time. All buses have software selectable pins and they can either have a shared or independent SCL pins, depending on user requirement. The example code is for VCNL4000. In the example I haven't written different functions for read and write but of course it can be modified. I did it because the sensor is in proximity mode and the Command Register needs to be written each time prior to a valid read. The code is tested for Arduino 1.0. Hopefully this helps.