Introduction: Arduino Nano - TSL45315 Ambient Light Sensor Tutorial

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 arduino nano.

Step 1: What You Need..!!

Step 2: Connection:

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 TSL45315 sensor and the other end to the I2C shield.

Connections are shown in the picture above.

Step 3: Code:

The arduino 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 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.

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

#include<Wire.h>

// TSL45315 I2C address is 0x29(41)

#define Addr 0x29

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);

// Select control register

Wire.write(0x80);

// Normal operation

Wire.write(0x03);

// Stop I2C transmission

Wire.endTransmission();

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Select configuration register

Wire.write(0x81);

// Multiplier 1x, Tint : 400ms

Wire.write(0x00);

// Stop I2C transmission

Wire.endTransmission();

delay(300);

}

void loop()

{

unsigned int data[2];

// Start I2C Transmission

Wire.beginTransmission(Addr);

// Select data register

Wire.write(0x84);

// Stop I2C transmission

Wire.endTransmission();

// Request 2 bytes of data

Wire.requestFrom(Addr, 2);

// Read 2 bytes of data

// luminance lsb, luminance msb

if(Wire.available() == 2)

{

data[0] = Wire.read();

data[1] = Wire.read();

}

// Convert the data

float luminance = data[1] * 256 + data[0];

// Output data to Serial Monitor

Serial.print("Ambient Light Luminance :");

Serial.print(luminance);

Serial.println(" lux");

delay(300);

}

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.

Comments