Introduction: Arduino Nano - BH1715 Digital Ambient Light Sensor Tutorial
The BH1715 is a digital Ambient Light Sensor with an I²C bus interface. The BH1715 is commonly used to obtain the ambient light data for adjusting LCD and Keypad backlight power for mobile devices. This device offers a 16-bit resolution and an adjustable measurement range, allowing detection from .23 to 100,000 lux. Here is its demonstration with Arduino nano.
Step 1: What You Need..!!
Step 2: Connections:
Take an I2C shield for Arduino Nano and gently push it over the pins of Nano.
Then connect the one end of I2C cable to BH1715 sensor and the other end to the I2C shield.
Connections are shown in the picture above.
Step 3: Code:
The Arduino code for BH1715 can be downloaded from our GitHub repository-Dcube Store.
Here is the link for the same :
https://github.com/DcubeTechVentures/BH1715...
We include library Wire.h to facilitate the I2c communication of the sensor with the Arduino board.
You can also copy the code from here, it is given as follows:
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// BH1715
// This code is designed to work with the BH1715_I2CS I2C Mini Module available in Dcube Store.
#include
// BH1715 I2C address is 0x23(35)
#define Addr 0x23
void setup()
{
// Initialise I2C communication as MASTER
Wire.begin();
// Initialise Serial Communication, set baud rate = 9600
Serial.begin(9600);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send power on command
Wire.write(0x01);
// Stop I2C Transmission
Wire.endTransmission();
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Send continuous measurement command
Wire.write(0x10);
// Stop I2C Transmission
Wire.endTransmission();
delay(300);
}
void loop()
{
unsigned int data[2];
// Request 2 byte of data
Wire.requestFrom(Addr, 2);
// Read 2 bytes of data
// ALS msb, ALS lsb
if(Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}
delay(300);
//convert the data
float luminance = ((data[0] * 256) + data[1]) / 1.20;
// Output data to serial monitor
Serial.print("Ambient Light Luminance :");
Serial.print(luminance);
Serial.println(" lux");
}
Step 4: Applications:
BH1715 is a digital output ambient light sensor which can be incorporated in Mobile phone, LCD TV, NOTE PC etc. It can also be employed in Portable game machine, Digital camera, Digital video camera, PDA, LCD display and many more devices which require efficient light sensing applications.