Login

Register

Login

Register

Particle Photon – 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 particle photon.

Step 1: What You Need..!!

1. Particle Photon

2. BH1715

3. I²C Cable

4. I²C Shield for Particle Photon

Step 2: Connections:

The particle 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 have used two libraries for particle code, which are application.h and spark_wiring_i2c.h. Spark_wiring_i2c library is required to facilitate the I2C communication with the sensor.

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 from ControlEverything.com.
// https://www.controleverything.com/content/Light?sku=BH1715_I2CS#tabs-0-product_tabset-2

#include
#include

// BH1715 I2C address is 0x23(35)
#define Addr 0x23

int luminance = 0;
void setup()
{
    // Set variable
    Particle.variable("i2cdevice","BH1715");
    Particle.variable("luminance",luminance);
  
    // 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
    luminance = ((data[0] & 0xFF) * 256 + (data[1] & 0xFF)) / 1.20;
        
    // Output data to dashboard
    Particle.publish("Ambient Light Luminance   :", String(luminance));
}    

Step 4: Applications:

BH1715 is a digital output ambient light sensor that can be incorporated in Mobile phones, LCD TV, NOTE PC, etc. It can also be employed in a portable game machine, Digital camera, Digital video camera, PDA, LCD display and many more devices which require efficient light-sensing applications.



Be the first to comment “Particle Photon – BH1715 Digital Ambient Light Sensor Tutorial”

Select your currency
Our Shipping Partners