Blogroll

Powered by Blogger.

Saturday 9 August 2014

A Simple Technique to Measure the Light Intensity using Arduino and LDR

by realfinetime  |  in transistor at  10:34

          We have already seen the Circuit to Turn On an LED During Day and Turn Off the Same at Night Using LDR and BC 547. Here we will measure the light intensity around light sensor using an arduino mega. Circuit is simple and is done as shown in the following diagram.


          Connections are done as shown in the circuit diagram. Collector pin of transistor is given to the analog pin ( A0 ) of arduino to get an analog value for light intensity. 5V for the working of transistor is supplied from 5V pin of arduino. Ground for the circuit is given from the Gnd pin of Arduino. Pinout diagram of BC547 is given at the left side top in the diagram.

Transistor - BC 547 is the transistor used here. It is an NPN transistor and is suitable for small operations.

5V - Normally supplied from Arduino.

R1 -  This is a current limiting resistor. It helps to switch the transistor between ON and OFF states by controlling the current through R1 and hence through the base of transistor. If that resistor is not connected, there is a possibility that, base current will always remain high because, LDR alone cannot resist the current considerably to turn off the transistor.

R2 -  It is a pull down resistor. It will ground the base, if there is no external signals to the base of transistor. When an external signal is connected, beginners confuse whether this signal get grounded through R2. But this signal will not get grounded because of high resistance of R2 ( 10K ).

R3 -  If R3 is not connected, when transistor turns on, power supply get shorted through A,C,B,E and F due to the low resistance of transistor. This will increase current abruptly which will damage the transistor as well as power supply.

Working of circuit

          Current that flows through the transistor ( collector to emitter ) is directly proportional to the base current of the transistor. During night, resistance of the LDR is maximum. Then minimum current will flow to the base of transistor and hence current through the transistor ( collector to emitter ) will be minimum. Current at the collector point of transistor has two options, either it can flow to the analog pin of arduino or it can flow through the transistor to ground. When the base current is small, current will flow to the arduino because of the large impedance of transistor. Then analog pin of arduino will read a high value. During the day time, resistance of LDR is minimum. Hence base current will be maximum. Collector current will flow through the transistor to ground. Then arduino will get a small current and the reading will be minimum. Value will be maximum at night ( 1023 ) and minimum at day ( 0 ). This value will be in between minimum and maximum values, if the light intensity is between the light intensity of day and night.

         Now upload the following program to your arduino board. This program will read the collector current through the analog pin 0 ( A0 ) and will display it in serial monitor in 100ms delay.

int sensorPin = A0;    // select the input pin for the LDR sensor
int sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  Serial.begin(9600);
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);
  delay(100);                
}

          If uploading is successfull, open your serial monitor. Don't forget to change the baud rate to 9600. Change the light intensity around LDR by some methods. Serial monitor will print the value of varying light intensity. 

2 comments:

  1. Is BC547, R1, R3 really necessary? What is the disadvantage of using only R2 and LDR?

    ReplyDelete
  2. how could i connect the output of the arduino to led strip! the more light the environment is then more light comes out of the led strip

    ReplyDelete

IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.

For More Electronic Tips



Blog Archive

Proudly Powered by Blogger.