Can i connect more than one BH1750?

Is it possible to use more than 1 BH1750(or whatever sensor) and how can i read data from it?

That sensor appears to have an I2C interface

From the datasheet it appears that one of 2 different I2C addresses can be assigned so 2 of the sensors could be connected to the Arduino and separate values read from them

Note that I have no special knowledge or experience of the sensor

Other sensors may have the ability to be addressed individually which could allow more of them to the attached and read

tob7:
Is it possible to use more than 1 BH1750(or whatever sensor) and how can i read data from it?

If you can only assign one address, then that would be difficult. Some micro controllers have multiple I²C buses, so it would be possible. As UKHeliBob mentioned, you can assign 2, so it is possible.
What I find easier, if you have more than one of the exact same sensor, is to use SPI. With SPI you have a slave select where you can tell the sensor to not listen when it is communicating with the other sensor.
Use the examples in this library.

Also, I don't know what this sensor is and what it does.

UKHeliBob:
That sensor appears to have an I2C interface

From the datasheet it appears that one of 2 different I2C addresses can be assigned so 2 of the sensors could be connected to the Arduino and separate values read from them

Note that I have no special knowledge or experience of the sensor

Other sensors may have the ability to be addressed individually which could allow more of them to the attached and read

so how can i separate them? honestly, im noob on this, im just hand on this arduino things for like 2 weeks?

tob7:
so how can i separate them? honestly, im noob on this, im just hand on this arduino things for like 2 weeks?

Please look at the link I sent you.

/*
BH1750 can be physically configured to use two I2C addresses:
- 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
- 0x5C (if ADD pin had > 0.7VCC voltage)
*/
BH1750 lightMeter(0x23);

The ADD pin is used to set the sensor I2C address. By default (if ADD voltage less than 0.7 * VCC) the sensor address will be 0x23. If it has voltage greater or equal to 0.7VCC voltage (e.g. you’ve connected it to VCC) the sensor address will be 0x5C.

reference: GitHub - claws/BH1750: An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC

Has also an example for 2

dyso:
Please look at the link I sent you.

/*

BH1750 can be physically configured to use two I2C addresses:

  • 0x23 (most common) (if ADD pin had < 0.7VCC voltage)
  • 0x5C (if ADD pin had > 0.7VCC voltage)
    */
    BH1750 lightMeter(0x23);



https://github.com/claws/BH1750/blob/master/examples/BH1750advanced/BH1750advanced.ino


*reference: https://github.com/claws/BH1750*

so that mean if i connect the ADD pin to another GND pin then the voltage will be greater than 0.7V, i can do something like
BH1750 A (0x23);
BH1750 B (0x5C);
but i need to connect up to 4 sensors and that mean its impossible to connect 4 of them but 2 is fine?

Well, if you have 2 I²C bus on your micro controller, then it is possible. If you dont then you would need this:

as far as I know, the Arduino UNO only has 1. For example the teensy 4 has 2. But I assume yours has one so you need to buy this.

I don't know of another way. Maybe someone else knows.

tob7:
so that mean if i connect the ADD pin to another GND pin then the voltage will be greater than 0.7V, i can do something like
BH1750 A (0x23);
BH1750 B (0x5C);
but i need to connect up to 4 sensors and that mean its impossible to connect 4 of them but 2 is fine?

oh wait...cant do that...can u suggest me how to set the voltage?

tob7:
oh wait...cant do that...can u suggest me how to set the voltage?

connect the pin to 3.3V

dyso:
Well, if you have 2 I²C bus on your micro controller, then it is possible. If you dont then you would need this:

Overview | Adafruit TCA9548A 1-to-8 I2C Multiplexer Breakout | Adafruit Learning System

as far as I know, the Arduino UNO only has 1. For example the teensy 4 has 2. But I assume yours has one so you need to buy this.

I don't know of another way. Maybe someone else knows.

hmm, i've connected 4 I2C modules on my arduino nano just using 1 I2C bus that it have so i guess its problely fine :^)
*dont ask me how can i have enough voltage for it, i dont even know how lol

so that mean if i connect the ADD pin to another GND pin then the voltage will be greater than 0.7V,

By definition the voltage of the GND pin will not be greater than 0.7V because it will be 0V

In any case, you are confusing 0.7V with 0.7VCC
The former is an an actual voltage, the latter is 0.7 of the voltage of the Arduino

Either connect the ADD pin directly to GND (0V) or to 5V. It is good practice to use a 10K resistor when you do this

tob7:
hmm, i've connected 4 I2C modules on my arduino nano just using 1 I2C bus that it have so i guess its problely fine :^)
*dont ask me how can i have enough voltage for it, i dont even know how lol

That won't work. I think you are confusing me and I am confusing you.
Are you using 4 BH1750? If so, then it won't work. If you are using 2 then it will. If you want to use 4 with the nano, then you need to expand your bus. Every I²C sensor needs its own address.

tob7, the Arduino Nano is a 5V board and the BH1750 is a 3.3V sensor. That means you are in trouble.
You may not connect a digital output to the sensor ADDR pin and the sensor could be damaged by connecting it to the SDA and SCL of the Arduino Uno.

With the right pullup resistors for SDA and SCL and one ADDR pin to 3.3V and the other to GND, then it is possible to use two BH1750 on the same I2C bus. It will work, but it is not perfect and there is still a voltage mismatch on the I2C bus.

What about the address selection trick ? I have not tested that, see the paragraph with "Not tested yet" in my "BH1750.ino"
Suppose the Arduino board is a 3.3V board. Then four digital pins can be connected to the four ADDR pins and each time one of the sensors can get the scope by setting the lower address and the rest stays at the (unused) higher address.
tob7, don't try this with a 5V board.

Do you have a single BH1750 working ?

dyso:
That won't work. I think you are confusing me and I am confusing you.
Are you using 4 BH1750? If so, then it won't work. If you are using 2 then it will. If you want to use 4 with the nano, then you need to expand your bus. Every I²C sensor needs its own address.

well, actually 3, the temp sensor is not an I2C one, there's 1 BH1750, 1 LCD 1602 and 1 DS1307 module connected to 1 I2C bus and they work fine in 2 week so i think more of them will okay if im using a shield for it which is have 12v input?

Koepel:
tob7, don't try this with a 5V board.

Do you have a single BH1750 working ?

Oh dear! That is troubling.

tob7:
well, actually 3, the temp sensor is not an I2C one, there's 1 BH1750, 1 LCD 1602 and 1 DS1307 module connected to 1 I2C bus and they work fine in 2 week so i think more of them will okay if im using a shield for it which is have 12v input?

Oh man...
Next time, list what you have. :smiley:

You don't need to address the sensor and you can leave the address pin on gnd. However, read what @Koepel wrote. It is very important.

Also, read up on electronic basics. You will kill all your sensors like this.

Also, misleading title!!!

I came across the following which provides one solution to having multiple devices with the same address on an I2C bus:

dannable:
I came across the following which provides one solution to having multiple devices with the same address on an I2C bus:

https://electronics.stackexchange.com/a/392155

That's very smart! Thanks for that.

That circuit at stackexchange is not very smart :frowning: It is not stupid, but I don't like it.
According to the text the SDA for the unused I2C devices are set HIGH by the Arduino. If something is wrong, or during power down, then the sensor might pull the SDA low, getting 40 mA in its SDA pin from the Arduino Uno.
It is not possible to use INPUT_PULLUP for those 4 pins, because then they are influenced by the SDA signal.

The Schottky diodes make the SDA signal weaker, almost in the same way as a I2C-level-shifter. When a I2C-level-shifter is added to that circuit, then the double diode makes the bus unreliable.

If the devices are modules with pullup resistors to 3.3V or 5V, then everything falls apart because of the resistors R1 to R4. To make it work, those R1 to R4 must be low in value, but then the total pullup is too much.

It uses 6 pins for 4 sensors.

There is an other way without using a I2C-bus-multiplexer: By using a software I2C library and combining the SCL pin.
Then 5 pins are needed and the signals are not getting weaker by a diode.