Automatic Night Lamp using LDR

Automatic Night Lamp using LDR

Automatic night lamp as the name suggests is for turning ON and OFF the lamp automatically without the need of human interventions. It senses the light intensity from surroundings and find whether its day or night. And it automatically turns ON when the surrounding is dark and it turns OFF when it receives light from surroundings. A sensor called LDR is used to detect the light intensity. This project finds wide outdoor applications in streets, gardens and public places where it finds difficulty to appoint a person to operate the lights.

Components Required

  • Light Dependent Resistor (LDR)
  • LM358 Op-Amp
  • Resistor 22KΩ
  • Resistor 10KΩ
  • Preset 10KΩ
  • BC547 transistor
  • 1N4148 diode
  • 12V Relay

Circuit Diagram

Automatic Night Lamp - Circuit Diagram

Automatic Night Lamp – Circuit Diagram


The main part of this circuit is the light dependent resistor (LDR). It is a sensor which is a particular kind of resistor whose resistance decreases when exposed to light. Likewise it offers high resistance in dark. The resistance value changes from few 100 ohms to mega ohm range. The LDR is placed in a potential divider network. So voltage across LDR changes with intensity of light. Voltage across the LDR is given to the positive terminal of a comparator. Now a reference voltage is required to compare with the voltage across LDR. That reference voltage is made by using the pot or preset. So this preset can be used to adjust the sensitivity of the circuit. Next is the comparator made using LM358 op-amp which compares the voltage levels at its two inputs and gives output accordingly. If the voltage at positive terminal is greater, the output will be high and if the voltage at negative terminal is greater, the output will be low. That is if it is dark, resistance across LDR is high, so voltage drop across the LDR is high and voltage at positive terminal will be greater than the reference voltage. Therefore output of comparator will be high. The output of comparator is given to a transistor wired as a switch. Since enough voltage appears across the base emitter junction, the transistor conducts and current passes through the relay coils. So relay switches its contact and the bulb glows. Bulb is connected to the NO (Normally Open) pin of relay as it should be off when the relay coils are not energized. If the output of comparator is low, then transistor will be in OFF stage. So no current flows through the relay and bulb remains in OFF stage.

Automatic Night Lamp Working Animation

Automatic Night Lamp Working Animation

You can choose a voltage between 3 to 32V for powering this circuit depending of the relay coil voltage. I choose 12V since 12V relays are very common in the market.

Note : You should keep the LDR in such a way that light from lamp L1 (connected to this circuit) will not fall on it.

Power Supply

I prefer to use a capacitor dropper power supply. I used the following circuit for that, it is a 12V, 40mA supply. Please read the article, Transformerless Capacitor Power Supply for more details about it.

Transformerless Capacitor Power Supply 12V 40mA

Transformerless Capacitor Power Supply 12V 40mA


Share this post

  • Golam Rasul Chowdhury

    In the evening during the conducting time light is blinking. How can I reduce this?

  • Try changing the value of R1, such that it will reduce the effect of LDR resistance.

  • Mark

    Can i use 12v led in series with this.instead of a normal 230 bulb.and what will i change from the power supply?

  • Sowmya Dhumale

    i have connected the circuit on the bread board.
    but, bulb is glowing always irrespective of the darkness around.
    suggest some solution for this.

  • Kai Kai

    Where to connect the com of the relay?

  • MarkSH

    The circuit needs a high value resistor between the output and the non-inverting input of the LM358 to create some amount of hysteresis otherwise the relay will chatter at the threshold of switching. Try putting a resistor value of between 100k and 1M. The higher the resistor value will reduce the the hysteresis.

  • MarkSH

    The common of the relay is connected to the live of the mains. The neutral of the mains is connected to the bulb then to the Normally Open (NO) side of the relay. The relay and this side of the circuit MUST BE isolated from from the rest of the circuit to avoid electrocution.

  • MarkSH

    Add a high value resistor (between 100k and 1M) between the output (pin 1) and the non-inverting input (pin 3) of the LM358. This will create some hysteresis in the circuit and the switching then should not flicker. Try experimenting with different values of resistors. The higher the resistor value, the reduction in hysteresis.

  • MarkSH

    Yes, but you do not need R2, Q1, D1 or RL1. Use a 1k and LED in series between the output (pin 1) of the LM358 and the Ground rail.

  • shawon

    i am using 684 pf , 400v capacitor instead of 680 nf, 400v capacitor, have to change anaything of circuit??

  • shawon

    i am using 684 pf , 400 v capacitor..and i got 9.54 output voltage in multimeter.. for that i m using 6v relay bt my circuit is not working.. relay is not working and bulb is not glowing… what i have to do now? pls ans asap .. 🙂