loading

Yesterday we were working on LCD displays, and while working over them we realized the importance of light intensity computation. Light intensity is not only important in the physical domain of this world but it has its well said role in the biological domain too. Accurate estimation of light intensity plays a pivotal role in our ecosystem, in growth of plants etc. So, for serving this purpose we studied this sensor BH1715, which is a 16-bit serial output type ambient light sensor.

In this tutorial, we are going to demonstrate the working of BH1715 with Particle Photon. Particle photon is that board which can actually facilitate the controlling of any device through internet.

Hardware that you are going to need for this purpose are as follows:

1. BH1715 - Ambient Light Sensor

2. Particle Photon

3. I2C Cable

4. I2C Shield For Particle Photon

Step 1: BH1715 Overview:

First of all we would like to familiarize you with the basic features of the sensor module that is BH1715 and the communication protocol on which it works.

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.

The communication protocol on which the sensor works is I2C. I2C stands for the inter-integrated circuit. It is a communication protocol in which the communication takes place through SDA(serial data) and SCL(serial clock) lines. It allows connecting multiple devices at the same time. It is one of the simplest and most efficient communication protocol.

Step 2: What You Need..!!

The materials that we need for accomplishing our goal includes the following hardware components:

1. BH1715 - Ambient Light Sensor

2. Particle Photon

3. I2C Cable

4. I2C Shield for Particle Photon

Step 3: Hardware Hookup:

The hardware hookup section basically explains the wiring connections required between the sensor and the raspberry pi. Ensuring correct connections is the basic necessity while working on any system for the desired output. So, the requisite connections are as follows:

The BH1715 will work over I2C . Here is the example wiring diagram, demonstrating how to wire up each interface of the sensor.

Out-of-the-box, the board is configured for an I2C interface, as such we recommend using this hookup if you’re otherwise agnostic. All you need is four wires!

Only four connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the help of I2C cable.

These connections are demonstrated in the pictures above.

Step 4: Light Intensity Measurement Particle Code:

Lets start with the particle code now.

While using the sensor module with the arduino, we include application.h and spark_wiring_i2c.h library. "application.h" and spark_wiring_i2c.h library contains the functions which facilitate the i2c communication between the sensor and the particle.

The entire particle code is given below for the convenience of the user:

#include<application.h>

#include<spark_wiring_i2c.h>

// 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 5: 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.

About This Instructable

209views

7favorites

More by Dcube Tech Ventures:
Add instructable to: