Light Intensity Measurement by Using BH1715 and Raspberry Pi : 5 Steps - vargoinscurs
Introduction: Candlepower Measuring by Victimization BH1715 and Raspberry Pi
Yesterday we were working along LCD displays, and while practical over them we realized the grandness of light intensity computation. Light intensity is not only when important in the physical domain of this planetary but information technology has its well-said role in the natural domain too. Accurate estimation of pale intensity plays a pivotal role in our ecosystem, in the growth of plants, etc. Then, for serving this purpose we studied this sensor BH1715, which is a 16-bit music turnout character close light sensing element.
In this tutorial, we are leaving to exhibit the working of BH1715 with Raspberry pi, using Java as the programming language.
Hardware that you are going to need for this purpose are as follows:
1. BH1715 - Close Lightly-armed Detector
2. Raspberryy Pi
3. I2C Cable
4. I2C Shield For Raspberry Private investigator
5. Ethernet Cable system
Step 1: BH1715 Overview:
First of all, we would like to familiarize you with the underlying features of the sensor module that is BH1715 and the communication communications protocol on which it works.
BH1715 is a appendage Ambient Light Sensor with an I²C bus interface. The BH1715 is normally accustomed obtain the close light data for adjusting LCD and Computer keyboard backlight might for mobile devices. This device offers a 16-routine resolution and an adjustable measurement range, allowing detection from .23 to 100,000 lx.
The communication protocol on which the detector works is I2C. I2C stands for the inhume-integrated tour. It is a communication protocol in which the communicating takes place through and through SDA(serial information) and SCL(serial clock) lines. It allows connecting multiple devices concurrently. IT is one of the simplest and most efficient communication communications protocol.
Step 2: What You Involve..!!
The materials that we need for accomplishing our goal includes the following hardware components:
1. BH1715 - Ambient Light Sensor
2. Hiss Pi
3. I2C Cable
4. I2C Shield For Raspberry Pi
5. Ethernet transmission line
Ill-trea 3: Hardware Hookup:
The computer hardware assemblage 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 beat I2C . Here is the case wiring diagram, demonstrating how to wire up to each one interface of the sensor.
Down-of-the-box, the board is configured for an I2C interface, as so much we commend victimisation this hookup if you're otherwise agnostic. Whol you need is Little Jo wires!
Only four connections are required Vcc, Gnd, SCL and SDA pins and these are connected with the help of I2C cable television.
These connections are demonstrated in the pictures above.
Footfall 4: Light Intensity Measuring Victimization Java Code:
The advantage of using raspberry pi is, that provides you the tractableness of the programing language in which you want to programme the board in order to interface the sensor with it. Harnessing this advantage of this board, we are demonstrating here it's programming in Java. The Coffee code for BH1715 can be downloaded from our GitHub community that is Dcube Store.
As well as for the ease of the users, we are explaining the code here also:
As the opening move of steganography, you need to download the pi4j library in case of java, because this library supports the functions used in the encode. So, to download the library you can visit the tailing nexus:
http://pi4j.com/instal.html
You crapper transcript the working java code for this sensor from here also:
<p>// Sparse with a clear-will license.</p><p>// Use IT whatsoever way you want, benefit or liberated, provided it fits in the licenses of its associated works.</p><p>// BH1715</p><p>// This code is designed to work with the BH1715_I2CS I2C Mini Module available from ControlEverything.com.</p><p>// <a href="https://www.controleverything.com/content/Palish?sku=BH1715_I2CS#tabs-0-product_tabset-2"> https://www.controleverything.com/content/Sunstruck?s...</a></p><p>import com.pi4j.io.i2c.I2CBus;</p><p>implication com.pi4j.io.i2c.I2CDevice;</p><p>import com.pi4j.io.i2c.I2CFactory;</p><p>import java.io.IOException;</p><p>public class BH1715</p><p>{</p><p>public atmospheric static nothingness main(String args[]) throws Elision </p><p>{ </p><p>// Make I2C bus </p><p>I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1); </p><p>// Get I2C device, BH1715 I2C address is 0x23(35) </p><p>I2CDevice device = bus.getDevice(0x23);</p><p>// Send out baron connected command </p><p>device.write((byte)0x01); </p><p>// Send continuous mensuration command</p><p>device.write out((byte)0x10); </p><p>Thread.slumber(500); // Read 2 bytes of information </p><p>// luminance msb, luminance lsb </p><p>byte[] data = novel byte[2]; </p><p>gimmick.read(data, 0, 2); // Convert data </p><p>double luminance = ((data[0] & 0xFF) * 256 + (data[1] & 0xFF)) / 1.20; // Output data to screen </p><p>System.out.printf("Ambient Light Luminance : %.2f lux %n", luminance); </p><p>}</p><p>}</p>
The program library which facilitates i2c communication between the sensor and the board is pi4j, its various packages I2CBus, I2CDevice and I2CFactory help to establish the connection.
<p>consequence com.pi4j.io.i2c.I2CBus;<br>moment com.pi4j.io.i2c.I2CDevice; import com.pi4j.Io.i2c.I2CFactory; moment java.io.IOException;</p>
This part of the code makes the sensing element function for light intensity measurement by writing the respective commands using the write() function and then the information is read using the read() function.
<p>device.spell((byte)0x01); // power happening dictation </p><p>device.indite((byte)0x10); // continuous measure command </p><p>byte[] information = spic-and-span byte[2]; // Record 2 bytes of data</p><p>device.read(data, 0, 2);</p>
The information accepted from the sensor is converted to the appropriate format away using the following:
<p>double luminance = ((data[0] &A; 0xFF) * 256 + (data[1] & 0xFF)) / 1.20;</p>
The output is printed using the Scheme.unstylish.println() serve, in the following format.
<p>System.out.printf("Ambient Light Luminance : %.2f lux %n", luminance);</p>
The turnout of the sensor is shown in the picture above.
Step 5: Applications:
BH1715 is a member output ambient light detector which can be united in Mobile speech sound, LCD TV, NOTE PC etc. Information technology can also be working in Movable game machine, Digital tv camera, Digital video camera, Personal organiser, LCD display and many more devices which postulate streamlined light sensing applications.
Be the First to Share
Recommendations
-
Anything Goes Contest 2022
Source: https://www.instructables.com/Quantifying-Light-Intensity-by-Using-BH1715-and-Ra/
Posted by: vargoinscurs.blogspot.com
0 Response to "Light Intensity Measurement by Using BH1715 and Raspberry Pi : 5 Steps - vargoinscurs"
Post a Comment