LDR and KY-018 photo-resistive module with Arduino

What is LDR, how does LDR work, and how to use LDR with Arduino are some questions that may arise in your mind while working with Arduino and Light dependent resistors.

Hello guys! Welcome back to my blog. Today we are going to see what light dependent resistor is, KY 018 LDR module and how to read the analog voltage of the photoresistor with Arduino.

What is a light-dependent resistor (LDR) or photo-resistor??

LDR which is known as a light-dependent resistor or photoresistor or photoconductor is a light-sensitive semiconductor device. Light sensitive means variation in its resistance if light or photon falls on the sensitive part of this material then its resistance decreases and if LDR is placed under no light condition or in a dark area. Its resistance increases.

photoresistor

 LDRs or photo-resistors are often used in a system to detect the presence of light or darkness example in the auto-rotate solar trackers, and photographic light meters. LDR are easy to manufacture lost-cost semi-conductor devices.

LDR resistor

Types of Light Dependent Resistors (LDRs or Photo-resistors)

  • Intrinsic photo-resistors: These are made of pure semiconductor materials such as silicon or germanium. When light energy falls on the valence band then electrons get excited and jump from the valence band to the conduction band.
  • Extrinsic photo-resistors: These are semiconductor materials doped with impurities which are called dopants. These dopants create new energy bands above the valence band which is filled with electrons. Hence this reduces the bandgap and less energy is required in exciting them. Extrinsic photo resistors are generally used for long wavelengths.

How does LDR work??

           ldr light dependent resistor

The working of LDR depends upon the valence band and conduction band. The distance between the conduction band and valence band is called as energy gap. Valence bands are filled with electrons. When a photon of light of a certain amount falls on the valence band the electrons get excited to the conduction band. The light energy must be greater than the energy gap between the conduction band and the valence band. This light energy kicks out electrons from the valence band towards the conduction band. Electrons jump from the valence band to the conduction band. This flow of electrons from the valence band to the conduction band starts the flow of current and decreases the resistance.

When there is no light or in dark conditions electrons do not receive enough energy to cross the valence band and enter the conduction band. Since there is no flow of electrons current will not flow and resistance increases.

working of LDR

When this photon of light gets hidden the electron-Hole pair gets energy and is excited to jump from the valence band to the conduction band this flow of electron. When there is no light condition means in dark the resistance of LDR is high. Due to high resistance, there is no flow of current. When there is a light, the resistance of LDR is low and the current starts flowing which glows the LED.

                                     V=IR                 ………………… 1)

                                    I = V/R              …………………. .2)

From these equations current (I) is inversely proportional to resistance Means resistance increases & current decreases and when resistance decreases current increases.

Fig (a) here LDR is connected as first before 5k resistor in a circuit. When there is no light condition i.e. in darkness the resistance of LDR will assume around 1MΩ. So the voltage drop across the LDR will be high. As the voltage drop is high most of the 5v will drop at LDR and no voltage will flow further.

When light intensity falls on LDR the resistance of LDR decreases assuming around 1kΩ as LDR < R2 (5k). The current flow less resistance path and voltage will get at the reading pin.

Fig (b) in this circuit LDR is below the first resistor R1 so when there is no light. LDR resistance will increase up to 1MΩ. So voltage drop across the LDR will be greater. So we will get voltage at reading pin is high. When the light falls on LDR its resistance decrease assumes 1kΩ which is less than R1 LDR < R1 (5k). So voltage drop across resistor R1 will be higher. Most of the 5v get drop t 5k and the voltage we get at the reading pin will be very Low.

Why do we attach a fixed resistor with an LDR sensor??

LDR

We can connect LDR directly to supply and measure voltage with respect to any change in resistance but the problem is that Arduino pins A0-A5 reads only voltage not current so we have to build a circuit that can measure a current. Therefore we use a voltage divider circuit configuration. We can use one more resistor with LDR. I have to explain the voltage divider in the previous chapter you can visit there.

LDR is connected as a voltage divider with another fixed resistor and any change in resistance of LDR would cause a change in voltage.

Application of LDR

  • Dual-axis solar tracker
  • Photographic light meters
  • Lighting controls for street lamps
  • Light intensity meters
  • On conveyor belt for measuring objects
  • Automatic curtain opening and closing at day and night time
  • Automatic lights on and off from Sunset to Sunrise
  • Security System 

LDR or photoresistor with Arduino 


photoresistor Arduino
This image is created using fritzing

Connect the ground pin of the LDR sensor to the ground pin of Arduino, the VCC pin to 5v, and the Signal pin to A1. Also, connect the positive lead of LED to Arduino pin 6.

KY-018 LDR module with Arduino 

photoresistor module Arduino
This image is created using fritzing

Connect the ground pin of the ky-018 sensor to the ground pin of Arduino, the VCC pin to 5v, and the Signal pin to A1. Also, connect the positive lead of LED to Arduino pin 6. 

Code -

int LDR_pin = A1;
int Sensor_value;
int LED_pin = 6;

void setup() 
{
 pinMode(LDR_pin,INPUT);
 pinMode(LED_pin,OUTPUT);
 Serial.begin(115200);
}

void loop() 
{
 Sensor_value = analogRead(LDR_pin);
  Serial.println(Sensor_value);  
 if(Sensor_value<700)
 {
 digitalWrite(LED_pin,HIGH);
  }
  else{
     digitalWrite(LED_pin,LOW);
    }
  
   delay(500); 
}

OUTPUT -

LDR Arduino

ldr light

Conclusion - 

Today we learn about what is Light-dependent resistor, how to use a Light-dependent resistor with Arduino, the application of LDR & working principle of the Light-dependent resistor. LDR is a small, low-cost passive electronic semiconductor device whose resistances increase and decrease depending upon the light intensity present. LDR has a wide applications solar tracking, automatic street lights, other home automation applications, etc.

"I hope you find this IoT blog very helpful to you. In the upcoming lesson, we will see more about IoT sensors till then bye. See you all in my next blog."

Close Menu