drive multiple DFRobot BH1750 light sensor with Arduino microcontroller

Hi,
I’m currently working on BH1750 light sensor, it’s worked fine in single device with I2C address 0x23, but I’ve a problem if I used it in series of multiple devices. The address can’t changes to 0x5C, even ADD pin connected to the GND or internal pull-up resistor (4.7K). Can DFRobot provide some examples of wiring and coding with it? Here my current wiring and coding.
Code :
[code]#include <Wire.h>
#include <math.h>
int Sen1 = 0x23;
int Sen2 = 0x5C;
byte buff[2];
void setup()
{
Wire.begin();
Serial.begin(57600);
}
void loop()
{
uint16_t val1=0, val2=0;
BH1750_Init(Sen1);
delay(200);
if(2==BH1750_Read(Sen1))
{
val1=((buff[0]<<8 )|buff[1])/1.2;
Serial.print(val1,DEC);
Serial.println("[lx]");
}
delay(200);
BH1750_Init(Sen2);
delay(200);
if(2==BH1750_Read(Sen2))
{
val2=((buff[0]<<8 )|buff[1])/1.2;
Serial.print(val2,DEC);
Serial.println("[lx]");
}
delay(200);
}
int BH1750_Read(int address)
{
int i=0;
Wire.beginTransmission(address);
Wire.requestFrom(address, 2);
while(Wire.available()) //
{
buff = Wire.read();
i++;
}
Wire.endTransmission();
return i;
}
void BH1750_Init(int address)
{
Wire.beginTransmission(address);
Wire.write(0x10);
Wire.endTransmission();
}[/code]
The link of the sensor: [url=http://www.dfrobot.com/index.php?route=product/product&filter_name=bh1750&product_id=531#.USHliaWePvN]http://www.dfrobot.com/index.php?route=product/product&filter_name=bh1750&product_id=531#.USHliaWePvN[/url]
I’m currently working on BH1750 light sensor, it’s worked fine in single device with I2C address 0x23, but I’ve a problem if I used it in series of multiple devices. The address can’t changes to 0x5C, even ADD pin connected to the GND or internal pull-up resistor (4.7K). Can DFRobot provide some examples of wiring and coding with it? Here my current wiring and coding.
Code :
[code]#include <Wire.h>
#include <math.h>
int Sen1 = 0x23;
int Sen2 = 0x5C;
byte buff[2];
void setup()
{
Wire.begin();
Serial.begin(57600);
}
void loop()
{
uint16_t val1=0, val2=0;
BH1750_Init(Sen1);
delay(200);
if(2==BH1750_Read(Sen1))
{
val1=((buff[0]<<8 )|buff[1])/1.2;
Serial.print(val1,DEC);
Serial.println("[lx]");
}
delay(200);
BH1750_Init(Sen2);
delay(200);
if(2==BH1750_Read(Sen2))
{
val2=((buff[0]<<8 )|buff[1])/1.2;
Serial.print(val2,DEC);
Serial.println("[lx]");
}
delay(200);
}
int BH1750_Read(int address)
{
int i=0;
Wire.beginTransmission(address);
Wire.requestFrom(address, 2);
while(Wire.available()) //
{
buff = Wire.read();
i++;
}
Wire.endTransmission();
return i;
}
void BH1750_Init(int address)
{
Wire.beginTransmission(address);
Wire.write(0x10);
Wire.endTransmission();
}[/code]
The link of the sensor: [url=http://www.dfrobot.com/index.php?route=product/product&filter_name=bh1750&product_id=531#.USHliaWePvN]http://www.dfrobot.com/index.php?route=product/product&filter_name=bh1750&product_id=531#.USHliaWePvN[/url]
2013-03-13 22:30:04 Hi,y45!
According to the datasheet of the Ambient Light Sensor IC Series[url=https://www.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf]https://www.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf[/url], there are only two types of Slave Address: 0x23 and 0x5c(in Page10 of the datasheet). So one Arduino board can only work with two BH1750 light sensors which use the two slave address respectively at one time. I've tried to connect four sensors to one Arduino board at the same time and this will cause a conflict of using the two address.
I hope my answer can do a little help for you. :)
leletkt
According to the datasheet of the Ambient Light Sensor IC Series[url=https://www.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf]https://www.dfrobot.com/image/data/SEN0097/BH1750FVI.pdf[/url], there are only two types of Slave Address: 0x23 and 0x5c(in Page10 of the datasheet). So one Arduino board can only work with two BH1750 light sensors which use the two slave address respectively at one time. I've tried to connect four sensors to one Arduino board at the same time and this will cause a conflict of using the two address.
I hope my answer can do a little help for you. :)

2013-02-19 02:03:19 :)Hi,
I think you should set the connection of the two ADD pins of the two BH1750 light sensors differently.
1) The one uses address 0x23 : connect its ADD pin to GND or unconnected;
2) The one uses address 0x5c : connect its ADD pin to 3V3
Then these two sensors can both work properly.
I hope that my answer can help you. ;)
leletkt
I think you should set the connection of the two ADD pins of the two BH1750 light sensors differently.
1) The one uses address 0x23 : connect its ADD pin to GND or unconnected;
2) The one uses address 0x5c : connect its ADD pin to 3V3
Then these two sensors can both work properly.
I hope that my answer can help you. ;)
