2
\$\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 sensors have an I2C interface and all have the same address.

The sun sensor 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 the final output. To minimize this negative effect, conversion is triggered in all sensors at exactly the same 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 SDAs of each sensor are connected to a GPIO pin of the MCU. A procedure for writing and reading is described.

Questions

  1. Does anyone have Arduino example code for this 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
    Commented Mar 31, 2020 at 22:00
  • 3
    \$\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\$ Commented Mar 31, 2020 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
    Commented Apr 1, 2020 at 5:59
  • 1
    \$\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
    Commented Mar 28, 2021 at 23:17

2 Answers 2

1
\$\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\$
1
\$\begingroup\$

What you want to do is called bitbanging. There is an Arduino library called "Multi-BitBang." I have not used it, but it appears to be exactly what you want.

\$\endgroup\$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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