loading

TSL45315 is a digital ambient light sensor. It approximates human eye response under a variety of lighting conditions. The devices have three selectable integration times and provide a direct 16-bit lux output via an I2C bus interface. The device contains a photodiode array, an integrating analog-to-digital converter (ADC), signal processing circuitry, lux calculation logic, and an I2C serial interface on a single CMOS integrated circuit to provide lux data. Here is its demonstrartion with raspberry pi using java code.

Step 1: What You Need..!!

1. Raspberry Pi

2. TSL45315

LINK : https://www.controleverything.com/content/Light?sku=TSL45315_I2CS

3. I²C Cable

LINK : https://www.controleverything.com/content/I2C-Cables?sku=I2CAFF3

4. I²C Shield for Raspberry Pi

LINK : https://www.controleverything.com/content/I2C-Master?sku=TOUTPI2

5. Ethernet Cable

Step 2: Connections:

Take an I2C shield for raspberry pi and gently push it over the gpio pins of raspberry pi.

Then connect the one end of I2C cable to TSL45315 sensor and the other end to the I2C shield.

Also connect the Ethernet cable to the pi or you can use a WiFi module.

Connections are shown in the picture above.

Step 3: Code:

The java code for TSL45315 can be downloaded from our github repository- ControlEverythingCommunity

Here is the link for the same :

https://github.com/ControlEverythingCommunity/TSL4...

The datasheet of TSL45315 can be found here:

https://s3.amazonaws.com/controleverything.media/c...

We have used pi4j library for java code, the steps to install pi4j on raspberry pi is described here:

http://pi4j.com/install.html

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.

// TSL45315

// This code is designed to work with the TSL45315_I2CS I2C Mini Module available from ControlEverything.com.

// https://www.controleverything.com/content/Light?s...

import com.pi4j.io.i2c.I2CBus;

import com.pi4j.io.i2c.I2CDevice;

import com.pi4j.io.i2c.I2CFactory;

import java.io.IOException;

public class TSL45315

{

public static void main(String args[]) throws Exception

{

// Create I2C bus

I2CBus bus = I2CFactory.getInstance(I2CBus.BUS_1);

// Get I2C device, TSL45315 I2C address is 0x29(41)

I2CDevice device = bus.getDevice(0x29);

// Send start command

device.write((byte)0x80);

// Send measurement command

device.write((byte)0x03);

Thread.sleep(800);

// Read 2 bytes of data from address 0x04(4), LSB first

byte[] data = new byte[2];

device.read(0x80 | 0x04, data, 0, 2);

// Convert the data to lux

int luminance = ((data[1] & 0xFF) * 256) + (data[0] & 0xFF);

// Output data to screen

System.out.printf("Total luminance is: %d lux %n", luminance);

}

}

Step 4: Applications:

The wide dynamic range of the ambient light sensor makes it particularly useful in outdoor applications where it is exposed to direct sunlight. The device is ideal for use in automatic control of street lights and security, billboard, and automotive lighting. The TSL45315 devices can also be used in solid state and general lighting for automatic control and daylight harvesting to maximize energy conservation. Other applications include display backlight control to extend battery life and optimize visibility in cell phones, tablets, and notebooks.