[SOLVED] Why do I connect this to A3? About BH1750 Light Sensor.

Hello guys!
:slight_smile:

I’m working on a new code and seems that I stumbled upon a question ‘Why do I have to connect “Addr” to A3?’. The basis of this is from http://www.instructables.com/id/BH1750-Digital-Light-Sensor/ by Mohannad Rawashdeh, which is a very great help to me and to others with his great codes and tutorials.

Now I know this might be silly but I happen to notice that there is nothing in the code that says about A3. I really would appreciate if anybody can explain to me the code.

I got this working without any problem, by the way. Thank you.

#include <BH1750FVI.h> // Sensor Library
#include <Wire.h> // I2C Library

BH1750FVI LightSensor;


void setup() {   // put your setup code here, to run once:
   Serial.begin(9600);
  LightSensor.begin();
  /*
Set the address for this sensor
you can use 2 different address
Device_Address_H "0x5C"
Device_Address_L "0x23"
you must connect Addr pin to A3 .
*/
  LightSensor.SetAddress(Device_Address_H);//Address 0x5C
// To adjust the slave on other address , uncomment this line
// lightMeter.SetAddress(Device_Address_L); //Address 0x5C
//-----------------------------------------------
  /*
   set the Working Mode for this sensor
   Select the following Mode:
    Continuous_H_resolution_Mode
    Continuous_H_resolution_Mode2
    Continuous_L_resolution_Mode
    OneTime_H_resolution_Mode
    OneTime_H_resolution_Mode2
    OneTime_L_resolution_Mode
   
    The data sheet recommanded To use Continuous_H_resolution_Mode
  */

  LightSensor.SetMode(Continuous_H_resolution_Mode);
 
  Serial.println("Running...");
}


void loop() {
  // put your main code here, to run repeatedly:
  uint16_t lux = LightSensor.GetLightIntensity();// Get Lux value
  Serial.print("Light: ");
  Serial.print(lux);
  Serial.println(" lux");
  delay(1000);
}

There is the possibility of connecting two of those devices. Since each has the same default address, you would not be able to talk to them individually. So, you change the address of one by grounding, or setting HIGH, its ADD pin.

If you only have one device, you don't need to connect the ADD pin to A3.

If you have two of them, and don't use the supplied library, you can connect the ADD pin to any unused pin, and set that pin HIGH or LOW when you want to talk to the second device.

If you have two of them, and you use the supplied library, you have to use the pin(s) that the library expects you to use, or you have to change the library.

Oh so its all in the library. Never thought of that. Thank you for the guidance.