This is an old revision of the document!

Light Sensor

Fig. 1: SI1145 ambient light sensor and AVR connection schematic

We will use the Adafruit_SI1145 library to interface with the sensor. Unzip the content of this zip file into the Arduino\libraries or use Arduino IDE's Add ZIP Library command.

#include <Wire.h>
#include "Adafruit_SI1145.h"
int controlPin = 7;
Adafruit_SI1145 uv = Adafruit_SI1145();
void setup() {
  pinMode(controlPin, OUTPUT);  //sensor on/off control
  digitalWrite(controlPin, LOW);
  Serial.println("Adafruit SI1145 test");
  if (! uv.begin()) {
    Serial.println("Didn't find Si1145");
    while (1);
void loop() {
  Serial.print("Vis: "); Serial.println(uv.readVisible());
  Serial.print("IR: "); Serial.println(uv.readIR());
  // Uncomment if you have an IR LED attached to LED pin!
  //Serial.print("Prox: "); Serial.println(uv.readProx());
  float UVindex = uv.readUV();
  // the index is multiplied by 100 so to get the
  // integer index, divide by 100!
  UVindex /= 100.0;  
  Serial.print("UV: ");  Serial.println(UVindex);