Electrical – Simultaneous reading of multiple I2C devices with the same address

arduinogpioi2c

I'm a teacher of a secondary school in the Netherlands. My students are working on a sun sensor placed on a moving object, with which the attitude w.r.t the sun is determined. A couple of ambient light sensors (BH1730FVC) in different directions are used for this. The sensor data is processed by an Arduino. The ambient light sensor have a I2C interface and all have the same address.

The sun senor has 3 groups of 4 ambient light sensors. One group must take a measurement simultaneously. To work properly the sun sensor needs light intensity data from all sensors in a set measured at the same time. Time shift between measurements introduces an error in final output. To minimize this negative effect, conversion is triggered in all sensors exactly at the time. In order to do this, all four sensors in a set are connected in a special way.

The idea originates from a PW-Sat2 Cubesat project. See attached page from the CDR.
enter image description here
The SCL lines are connected and the SDA's are per sensor connected to a GPIO pin of the MCU. A procedure for Writing and reading is described.

Questions

  1. Has someone an Arduino example code for the type of I2C connections? I was thinking to use SoftWire, but my experience in this field is limited.
  2. Are there (better) alternatives to simultaneously read I2C sensors with the same address?

Best Answer

A 400 kHz I2C bus can transfer over 40 bytes per millisecond. So reading of result will be quite fast even if they are read sequentially instead of simultaneously.

1) It should be possible to use Software Wire by either using four Software Wire instances and using one of them at a time to access the sensor. Another option is to use single Software Wire instance to access one sensor at a time but reconfigure the data pin based on which sensor you want to access. There are other options as well, like writing your own Software I2C module to operate as you wish with the sensor quad.

2) Other options include hardware changes to add bus muxes to choose one sensor at a time. To allow accessing multiple sensors at the same time does require connecting them separately to microcontroller.