Analysing multiple BH1750 at one time

Hi arduino fams, I wish to retrieve light intensity datas (kinetic) from 15 different BH1750 sensors at the same time, can anyone suggest feasible ways to perform this? Currently here is what I have on my hand:

BH1750 x 15 pcs
Arduino Nano x 5 pcs (hopefully can use lesser to achieve the goal)

and a series of codes that works for single BH1750 sensor:

#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

void setup(){
  Serial.begin(9600);

  // Initialize the I2C bus (BH1750 library doesn't do this automatically)
  Wire.begin();
  // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);
  // For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use Wire.begin(D2, D1);

  lightMeter.begin();

  Serial.println(F("BH1750 Test begin"));
}

void loop() {
  float lux = lightMeter.readLightLevel();
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.println(" lx");
  delay(1000);
}

Thanks in advance for any solutions!

Sorry but that will take a lot of hardware to accomplish. I did not see anything to sync conversions so at the same time (This is a few nanoseconds at most to me) is out of the question.If you can spread the reading timing out that will help. I

Hey mate, thanks for the suggestion, minimum how much of reading timing will you suggest? and besides i have came across a forum talking about multiplexer (TCA9548A I2C Multiplexer), do you think that will help?

Yes, you will need a I2C multiplexer to read all 15 sensors. I looked at the BH1750 available from Adafruit and they have an address pin on their board so you can change the I2C address from 0x23 to 0x5C. That would mean two groups of sensors. The TCA9548A I2C Multiplexer is a 1:8 multiplexer so you would need 2 of those. They are also I2C devices so one of them would have to be changed from the default address of 0x70. That will get all your hardware connected successfully, but it will not allow simultaneous reading of all the sensors. You will have to cycle through each one which means it will take milliseconds (10s of milliseconds?) to read them all. I do not know if that is good enough for your design

1 Like

The BH1750 supports continuous measurement mode, you could have all of them running and just simply read when you need results but they would not be in sync.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.