Automatic Night Lamp Circuit Diagram With LDR Sensor and Simple Relay Control

automatic night lamp circuit diagram

Use a photoresistor (LDR rated 5–20 kΩ in moderate illumination) paired with an NPN transistor such as BC547 or 2N2222 to switch a household light source after sunset. Place the light-sensitive resistor in a voltage divider with a fixed resistor between 10 kΩ and 47 kΩ. Connect the midpoint of this pair to the transistor base through a 1 kΩ–4.7 kΩ resistor. As ambient illumination drops below roughly 30–50 lux, the resistance of the LDR rises sharply, biasing the transistor and activating the load through a relay module.

Choose a 12 V relay with coil current below 70 mA so the transistor can drive it without overheating. Add a flyback diode (1N4007 or similar) across the relay coil to block reverse voltage spikes. Power the sensing stage from a regulated 9–12 V DC supply; unstable voltage shifts the switching threshold and causes flickering near dusk. Mount the LDR away from the controlled light source to prevent feedback that could trigger rapid on-off cycling.

For stable behavior, include a 100 µF capacitor between the transistor base and ground to slow sudden brightness changes such as car headlights. Outdoor installations benefit from a sealed enclosure with a small transparent window for the sensor. Copper traces or wires carrying mains voltage should maintain at least 3–5 mm spacing from the low-voltage sensing section to reduce leakage and accidental contact.

Light-Sensing Illumination Controller: Practical Design and Implementation

Use a photoresistor paired with a voltage divider to switch a small lighting unit once ambient illumination drops below about 30–50 lux. Connect an LDR with a 10 kΩ resistor to form a divider feeding the input of an LM393 comparator. Set the reference level with a 50 kΩ potentiometer tied between 5 V and ground. Adjust the potentiometer until the output flips when room brightness decreases to the desired threshold. This arrangement provides stable detection with minimal components.

The sensing stage works best with an LDR rated around 5–10 kΩ at moderate indoor brightness and 100 kΩ or higher in darkness. Such a range creates a strong voltage swing across the divider, simplifying threshold tuning. Place the sensor away from the light source it controls; direct exposure causes rapid toggling. A short plastic tube over the LDR reduces side reflections and improves repeatability.

The comparator output can drive a 2N2222 transistor used as a low-side switch. Insert a 1 kΩ resistor between comparator output and the transistor base. Connect the emitter to ground and the collector to the load through a relay coil rated for the supply voltage. A diode such as 1N4148 or 1N4007 across the coil prevents voltage spikes during switching. For small LED fixtures under 300 mA, the relay can be replaced by a MOSFET like IRLZ44N, lowering mechanical wear and power loss.

Add hysteresis with a feedback resistor between comparator output and the non-inverting input. A value near 470 kΩ shifts the switching point slightly after activation, preventing flicker when illumination hovers around the threshold. Without this feedback path, streetlight reflections, car headlights, or passing shadows can trigger rapid on-off behavior.

Power the controller with a regulated 5–12 V supply. If using mains-derived adapters, include a 100 µF electrolytic capacitor and a 100 nF ceramic capacitor near the comparator to reduce ripple. Long wires between the sensor and the board may introduce noise; twisted pair conductors or shielded cable maintain stable readings.

Mount the sensing element facing open space rather than walls or glass surfaces. Calibration works best during dusk conditions: rotate the reference potentiometer slowly until the lighting unit activates slightly before the surrounding area becomes difficult to navigate. Once set, secure the adjustment with a drop of acrylic varnish to prevent drift caused by vibration.

How an LDR-Based Light Sensor Switch Detects Darkness and Activates a Relay

Set the photoresistor (LDR) in a voltage divider with a trimming resistor between 10 kΩ and 100 kΩ so the midpoint voltage crosses the transistor base threshold near 0.6–0.7 V during low illumination. In bright conditions many LDR elements measure roughly 3–8 kΩ, which keeps the divider output low and the switching transistor off. As illumination drops, resistance can rise beyond 200 kΩ–1 MΩ, pushing the divider voltage upward. Once the base–emitter junction of an NPN device such as BC547 or 2N2222 reaches conduction level, current flows through the collector path and energizes the relay coil.

Darkness Detection Mechanism

automatic night lamp circuit diagram

The sensing process relies on the large resistance swing of the LDR. The device contains a semiconductor layer whose charge carrier density decreases sharply with reduced light exposure. During daylight the divider node might sit near 0.2 V–0.3 V when paired with a 47 kΩ resistor, far below the switching point. As the environment becomes dim, the LDR resistance climbs rapidly, shifting the node voltage upward. When this node surpasses the transistor’s base conduction level, the transistor saturates. At saturation the collector-emitter path behaves like a closed switch with voltage drop typically under 0.2 V, allowing current from the power rail to pass through the relay winding.

Relay Activation Stage

The relay driver stage converts the small sensor signal into mechanical switching. A coil rated for 5 V or 12 V commonly draws 30–90 mA, far above what the sensor divider can supply directly. The transistor handles this load amplification: a base current of about 1 mA can control tens of milliamps at the collector when the gain (hFE) is near 100. A diode placed across the coil–cathode toward the supply rail–suppresses the reverse voltage spike produced when the magnetic field collapses. Without this protection the transistor junction may experience pulses exceeding 50 V. Adjusting the trimming resistor allows the lighting unit to engage precisely at the illumination level desired, preventing flicker during twilight conditions.