Measure light Intensity with Arduino and LDR Photoresistor (GL55)

Introduction

In this Post, we will learn how to Measure light Intensity with Arduino and LDR Photoresistor (GL55), In the world of electronics and DIY projects, measuring light levels has never been easier, thanks to the incredible capabilities of Arduino and the highly sensitive LDR (Light Dependent Resistor) Photoresistor GL55. In this article, we’ll delve into the world of light sensing, understand how the LDR Photoresistor GL55 works in conjunction with Arduino, and explore the various practical applications it offers. So, let’s shine a light on this innovative combination and discover how it can illuminate your projects and ideas.

Hardware Required

You will require the following Hardware Components for interfacing the LDR Photoresistor GL55 with Arduino.

Components#Buy From Amazon
Arduino UNO1Buy Link
LDR Photoresistor GL551Buy Link
Resistor 10KΩ1Buy Link
37 in 1 Sensor kit (Optional)1Buy Link
9v DC Adapter (Optional)1Buy Link
Jumper Wires4Buy Link
Breadboard1Buy Link

What is an LDR Photoresistor?

A photoresistor or LDR (light-dependent resistor) is a device whose resistance varies depending on the light received. We can use this variation to measure, through analog inputs, an estimate of the light level.

A photoresistor is made up of a semiconductor, typically cadmium sulfide CdS. When the light falls on it, some of the photons are absorbed, causing electrons to pass into the conduction band and, therefore, decreasing the resistance of the component.

Thus, a photoresistor decreases in resistance as the light on it increases. Typical values ​​are 1 Mohm in total darkness, to 50-100 Ohm under bright light.

On the other hand, the resistance variation is relatively slow, from 20 to 100 ms depending on the model. This slowness means that it is not possible to record rapid variations, such as those produced by artificial light sources powered by alternating current. This behavior can be beneficial since it gives the sensor great stability.

Finally, photoresistors are not suitable to provide an illuminance measurement, that is, to serve as a lux meter. This is due to their low precision, their strong dependence on temperature, and, especially, their spectral distribution is not suitable for the illuminance measurement.

ldr-graphics

Therefore, an LDR is a sensor that is suitable to provide quantitative measurements on the level of light, both indoors and outdoors, and react, for example, by turning on a light, raising a blind, or guiding a robot.

How does an LDR photoresistor work?

Mathematically, the relationship between the illuminance and the resistance of an LDR follows a potential function.

LDR-Formula

Being R0 the resistance at an intensity I0, both known.

The gamma constant is the slope of the logarithmic plot or the loss of strength per decade. Its value is typically 0.5 to 0.8.

For this reason, frequently the graphs that relate both values ​​are represented in logarithmic scales for both axes. Under this representation, the relationship is shown as a line graph.

ldr-resistance

These values ​​can be obtained from the component’s datasheet. For example, for the GL55 family of photoresistors, they are as follows:

Model
Spectral Peak
(nm)

Bright light resistance
(KΩ)

Dark resistance
(KΩ)
gamma
Response time
(ms)
GL55165405-105000.530
GL552854010-2010000.625
GL5537-154020-3020000.625
GL5537-254030-5030000.725
GL553954050-10050000.825
GL5549540100-200100000.925

However, there will always be small variations between devices, even within the same family, due to component manufacturing.

The potential behavior means that these small differences mean large variations in the measurement, so it is not possible, in general, to use these values ​​in an absolute way without a calibration process

Circuit Diagram

The following circuit shows you the connection of the Measure light Intensity with Arduino and LDR Photoresistor (GL55) Please make the connection carefully

Measure-light-Intensity-with-Arduino-and-LDR-Photoresistor-GL55-circuit

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code Examples

Here are some code examples. In the next one, we use the digital inputs to blink the onboard LED while the LDR is getting enough light.

//For more Projects: www.arduinocircuit.com

const int LEDPin = 13;
const int LDRPin = 2;

void setup()
{
pinMode(LEDPin, OUTPUT); 
pinMode(LDRPin, INPUT);
} 

void loop()
{
  int value = digitalRead(LDRPin);
  if (value == HIGH)
  {
    digitalWrite(LEDPin, HIGH);
    delay(50);
    digitalWrite(LEDPin, LOW);
    delay(50);
  }
}

The following example uses an analog input to activate the onboard LED if it exceeds a certain threshold.

//For more Projects: www.arduinocircuit.com


const int LEDPin = 13;
const int LDRPin = A0;
const int threshold = 100;

void setup() {
  pinMode(LEDPin, OUTPUT);
  pinMode(LDRPin, INPUT);
}

void loop() {
  int input = analogRead(LDRPin);
  if (input > threshold) {
    digitalWrite(LEDPin, HIGH);
  }
  else {
    digitalWrite(LEDPin, LOW);
  }
}

The following code provides a reading of the received lighting level. Note that the calculations are made with integer arithmetic, avoiding using floating point numbers, since they slow down the execution of the code a lot.

//For more Projects: www.arduinocircuit.com

const long A = 1000;      // Dark resistance in KΩ
const int B = 15;         // Light resistance (10 Lux) in KΩ
const int Rc = 10;        // Calibration resistance in KΩ
const int LDRPin = A0;    // LDR Pin
int V;
int illuminance;
void setup() 
{
   Serial.begin(115200);
}
void loop()
{
   V = analogRead(LDRPin);         
   // For LDR connected between GND and A0, use the following equation
   // illuminance = ((long)(1024-V)*A*10)/((long)B*Rc*V);
   
   // For LDR connected between A0 and Vcc (as in the previous schematic), use the following equation
   illuminance = ((long)V*A*10)/((long)B*Rc*(1024-V)); 
  
   Serial.println(illuminance);  
   delay(1000);
}

Applications

  1. Smart Lighting Systems: By integrating LDR Photoresistor GL55 with Arduino, you can create smart lighting systems that adjust brightness automatically based on ambient light conditions. This ensures optimal lighting in indoor spaces, conserving energy during the day and providing adequate illumination at night.
  2. Garden Automation: In garden automation projects, LDR Photoresistors can be employed to detect daylight. Arduino can analyze this data and control watering systems, ensuring plants receive adequate sunlight and water, leading to healthier and more efficient gardening.
  3. Solar Tracking Systems: For solar-powered applications, such as solar panels or solar-powered devices, LDR Photoresistors combined with Arduino can be used to create solar tracking systems. These systems adjust the orientation of solar panels or devices to maximize sunlight exposure, optimizing energy generation.
  4. Security Systems: LDR Photoresistors are valuable components in security systems, where they can detect changes in light levels caused by movement or intrusion. When connected to Arduino, these sensors can trigger alarms or notifications, enhancing the security of homes or premises.

Leave a Comment


error: