Introduction: Measuring Light Using Light Sensor

This is an instructable on our class project about measuring light using a light sensor. At the end of this instructable you will be able to build a working circuit and program an LDR light sensor to be able to read sunlight and print it on your computer screen.

We are using the LDR to read the light inside a beehive to tell us how dark or bright it is inside the beehive and warn us when it is getting to bright inside the beehive as it is advised to keep a beehive as dark as possible around 1 lux.

Step 1: Equipment

This first step shows the equipment needed to begin your light measurement system.

It is also advised to find out the serial code of your LDR and get the datasheet for the LDR as the values on this sheet are needed to complete this task.

We also used a lux sensor to help calibrate our LDR its highly advised to use one to help calibrate the LDR.

  1. LED
  2. LDR light sensor
  3. Breadboard
  4. Arduino
  5. 2.2k ohm resistor
  6. NORPS-12 Datasheet

Step 2: Schematic

This is the schematic version of the circuit shown in step 1.

Step 3: Block Diagram

This block diagram shows the steps on how the LDR reads the lux and to help make the arduino read the values read from the LDR then print the lux on your screen.

Step 4: Arduino Code

The following is the code we used in arduino to program our LDR. Depending on your type of LDR you might want to change some aspects of the code but this code will work for most types.

#include

int LDR = 5; // select the input pin for the LDR

void setup() {

Serial.begin(9600);

pinMode(LDR, INPUT); // declare the LDR as an INPUT

}

void loop()

{

int vout1 = analogRead(A5); // Read the analogue pin

float vout = vout1/204.6;

Serial.print(vout1);

Serial.print("DU");

Serial.print(vout);

Serial.println(" vout");

float R = (11000-vout*2200)/vout; // calculate the resistance

//float R = pow( X, -1);

Serial.print(R); // light dependant resistance

Serial.println(" Resistance.");

float lux= (pow( R, (1/-0.8616)))/(pow( 10, (5.118/-0.8616))); //lux calculation

Serial.print(lux);

Serial.print(" Lux.");

Serial.println("");

delay(3000); //delay for a second

//lux2

float lux2 = 65.9 * (pow( vout1, 0.352));

Serial.print(lux2);

Serial.print(" lux form2\n");

}

Step 5: Results

After measuring values using the lux meter and having the LDR beside it we were able to get resistance values and use our equations to get a graph of lux versus resistance.

As you can see from the graph and the tables we were able to get within a very small percentage error of the ideal value. So, by looking at our results it can be seen that this has been a successful project and by following all of our steps hopefully you can also have a successful project.