1
\$\begingroup\$

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?
\$\endgroup\$
4
  • 1
    \$\begingroup\$ By "synchronously", do you mean simultaneously? I2C has a clock so it's always synchronous regardless of how many devices there are. \$\endgroup\$ – DKNguyen Mar 31 '20 at 22:00
  • 2
    \$\begingroup\$ Do you really even need to read the sensors simultaneously? If there is a difference of a millisecond between when the readings are made, does that really matter in your situation? \$\endgroup\$ – Elliot Alderson Mar 31 '20 at 22:30
  • \$\begingroup\$ I mean simultaneously. I changed the description. Thanks for that. A millisecond between the readings won't matter, but the the light sensor BH1730FVC has an integration time (from 2.7 - 688.5 ms) so I expect the reading of one sensor wil take some time. Time shift between measurements introduces an error in final output. \$\endgroup\$ – Aernout Apr 1 '20 at 5:59
  • \$\begingroup\$ If I'm reading the data sheet correctly, you can kick off a measurement with just a two- or three-byte transfer. Then you poll the devices to see if they're done. So you use a fast bus speed, and kick off the transfers -- bim bam boom (well, four -- bim bam boom bong). Those will be nearly simultaneous. Then poll for done, and read them at your leisure. \$\endgroup\$ – TimWescott Mar 28 at 23:17
0
\$\begingroup\$

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.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.