I have the following problem: Since the BH1750 Sensor only supports two different I2C adresses, but i need to use 6 of those sensors, i wanna use 3 arduinos, 2 nanos, 1 uno and send the data from the nanos to the uno. Problem is that the I2C bus is already in use and while trying to send data, it does not work properly. Is this even possible? When trying it out, i can't get anything correctenter image description here


That's what i tried now:

Results i get are still not correct

enter image description here

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

// This code will feature the use of 6 gy 30 light sensors

BH1750 active_sensor(0x23); // We will use this adress for stating the active sensor
BH1750 inactive_sensor(0x5C);

void setup(){


  // Setting the input pins for controling the addr pins of the modules
    pinMode(8, OUTPUT); 
    pinMode(9, OUTPUT); 
    pinMode(10, OUTPUT); 
    pinMode(11, OUTPUT); 
    pinMode(12, OUTPUT); 
    pinMode(13, OUTPUT);

    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);

  // Initialize the i2c bus

 // Here we will set the mode of the module
  if (active_sensor.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
    Serial.println(F("BH1750 Advanced begin"));
  else {
    Serial.println(F("Error initialising BH1750"));
    Serial.println("Problem on 1");

void loop() {  


void get_values(){
  int i;
  for(i = 8; i<=13;i++){
    int lux = 0;
    lux = active_sensor.readLightLevel();    
  • the Question update is based on CrossRoads's answer
    – Juraj
    Sep 25, 2018 at 5:53
  • comment to question update. with ADDR HIGH address is 5C. change the address of active device to 5C.
    – Juraj
    Sep 25, 2018 at 5:53
  • you should accept CrossRoads's answer to mark this question solved
    – Juraj
    Sep 25, 2018 at 9:31

2 Answers 2


Use the ADDR pin as a chip select. Pull both pins high normally. When you want to talk to one, pull the ADDR pin low and use the ADDR = 0 address to talk to the selected device. Then you can have all 6 connected to one Arduino.

  • I actually tried this before, it did not work properly. Do you have any evidence that this really works?
    – Th3Fi3nD
    Sep 24, 2018 at 14:30
  • Post the code of what you tried with all 6 devices connected as suggested. Make sure the devices are all getting power.
    – CrossRoads
    Sep 24, 2018 at 14:34
  • There is a simple sketch here you can try for 1 device, then easily modify to cycle thru all 6. Be sure to add 4.7K or even 3.3K pullup resistors to SDA and SCK. The internal pullups in a '328P are not enough.
    – CrossRoads
    Sep 24, 2018 at 14:38
  • Ok, i just posted the code i am using, i did not use any resistors by now. So only 1 resistor or one for each sensor?
    – Th3Fi3nD
    Sep 24, 2018 at 14:40
  • media.digikey.com/pdf/Data%20Sheets/DFRobot%20PDFs/… Yes, one resistor each on SCL & SDA, at the end of the wiring chain preferably. Not at each device, just at one device.
    – CrossRoads
    Sep 24, 2018 at 14:44

You can make the nanos use software I2C to isolate those I2C buses from the UNO's I2C bus. Then have the UNO be the master on it's own bus, requesting the data when needed.

Though if you go for software I2C you can make the UNO do all the I2C work, assuming you have enough free pins for that.

Another option is to get a proper I2C multiplexer like the TCA9548A.

  • Six software i2c busses requires 7 pins. That is 6 sda lines and just 1 scl line. The ADDR selection to bring one sensor in focus is easier, but requires 8 pins. The tca9548a still requires 5 pins (two i2c plus three address for 6 busses).
    – Jot
    Sep 24, 2018 at 17:30
  • 1
    @Jot But you only need 3 buses because a pair of sensors can share a bus. Also the address pins of the tca9548a can be statically tied, the actual multiplexing is done internally. You write to the tca9548a itself through I2C (that is what the address pins are for) to select which channels should be open and then it passes through the I2C bus signals to those open channels. You can then close the channel when you are done. Sep 25, 2018 at 8:08
  • Thanks, I didn't think about that. So it will be 4 pins for a software i2c, 8 pins for ADDR selection, and 2 pins for the tca9548a.
    – Jot
    Sep 25, 2018 at 13:14

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.