Automatic Street Light Using LDR and BC547 Transistors with Relay
An automatic street light turns itself on when it gets dark and off when daylight returns. Real street lights use the same idea: a light sensor, a decision circuit and a switch that handles the lamp current. In this project you will build a small 12 V version using a light dependent resistor (LDR), two BC547 transistors and a 12 V relay. The relay switches a 12 V LED lamp or LED strip, so the whole project stays at safe low voltage.
Every stage is easy to see and measure: a divider turns light into voltage, one transistor senses it, a second inverts and amplifies it, and the relay gives an isolated contact for the lamp current.
Components Required
| Part | Value / Type | Quantity |
|---|---|---|
| LDR (photoresistor) | GL5528 or similar 5 mm LDR | 1 |
| Preset / trimmer pot (VR1) | 47 kilo-ohm | 1 |
| Resistor R1 | 1 kilo-ohm | 1 |
| Resistor R2 (Q1 base) | 10 kilo-ohm | 1 |
| Resistor R3 (Q1 collector) | 4.7 kilo-ohm | 1 |
| NPN transistor Q1, Q2 | BC547 | 2 |
| Relay RL1 | 12 V coil, SPDT, contacts rated at least 2 A DC | 1 |
| Diode D1 | 1N4007 | 1 |
| LED + resistor (status) | Red LED with 1 kilo-ohm | 1 each |
| Load | 12 V LED lamp or LED strip | 1 |
| Power supply | 12 V DC adapter, 1 A or more | 1 |
Circuit Explained Stage by Stage
Stage 1: Light sensing divider
An LDR is a resistor whose value falls as light increases. A typical GL5528 type reads roughly 10 to 20 kilo-ohm in ordinary room light and close to 1 mega-ohm in darkness, but check the datasheet of your part. The LDR is connected from +12 V to node A, and VR1 in series with R1 runs from node A to ground. In daylight the LDR resistance is low, so node A sits close to the supply. In darkness the LDR resistance is high and node A is pulled down towards ground by VR1 and R1.
Stage 2: Sensing transistor Q1
Node A drives the base of Q1 through R2 (10 kilo-ohm). When node A is above about 0.7 V with enough current, Q1 conducts and its collector drops to near 0 V. In darkness node A falls, Q1 switches off and its collector is pulled up to 12 V through R3.
Stage 3: Relay driver Q2
The collector of Q1 is connected directly to the base of Q2, with R3 acting as Q2's base resistor. When Q1 is off, about (12 - 0.7) / 4700 = 2.4 mA flows into Q2's base. That is plenty to saturate Q2 for a relay coil current of around 30 to 40 mA, well within the 100 mA rating of the BC547. Q2 then energises the relay. D1 across the coil absorbs the voltage spike when the coil is switched off; without it the spike can destroy Q2.
Connections
| From | To | Notes |
|---|---|---|
| +12 V | LDR pin 1 | LDR pin 2 is node A |
| Node A | VR1 (one end and wiper) | VR1 other end to R1, R1 to GND |
| Node A | R2 to Q1 base | Q1 emitter to GND |
| Q1 collector | R3 to +12 V and Q2 base | Q2 emitter to GND |
| Q2 collector | Relay coil, other coil end to +12 V | D1 across coil, cathode to +12 V |
| +12 V | Status LED + 1 kilo-ohm, to Q2 collector | Lights when relay is on |
| Relay COM | +12 V | NO contact goes to the lamp positive; lamp negative to GND |
+12V --+-- LDR --+-- (node A) --R2 10k--> Q1 base
| |
| VR1 47k
| |
| R1 1k
| |
GND -------+
+12V --R3 4.7k--+-- Q1 collector
+-- Q2 base
+12V --[relay coil]--+-- Q2 collector (D1 across coil, band to +12V)
Q1 and Q2 emitters to GNDHow It Works
In daylight node A is high, Q1 is on, Q2's base is held low, the relay is off and the lamp is dark. As evening comes the LDR resistance rises and node A falls. At some point Q1 can no longer stay on, its collector rises and Q2 switches on, energising the relay and lighting the lamp. At dawn the process reverses.
VR1 sets the switching point. A larger VR1 setting keeps node A higher for longer, so the lamp waits until it is darker before turning on. Using two transistors instead of one gives more gain, so the relay changes state over a smaller change in light and chatters less.
Assembly and Testing
- Build the circuit on a breadboard first. Check the BC547 pinout from your datasheet; for most BC547 parts, with the flat face towards you and leads down, the order is collector, base, emitter.
- Fit D1 with its band (cathode) towards +12 V. A reversed diode short-circuits the supply when Q2 turns on.
- Leave the lamp disconnected and power the circuit. Set VR1 to the middle.
- Cover the LDR with your hand or a black cap. The relay should click and the status LED should light. Uncover it and the relay should release.
- Measure node A with a multimeter in room light and with the LDR covered. You should see a clear difference of a few volts.
- Adjust VR1 at dusk so the relay switches at the light level you want.
- Connect the 12 V lamp to the relay NO contact and test again. Then transfer the circuit to veroboard and mount it in a box with the LDR facing upwards.
Troubleshooting
- Relay never turns on: measure Q1 collector with the LDR covered. If it stays low, node A is still too high; lower VR1 or check the LDR is not shorted.
- Relay always on: Q1 is not conducting. Check the LDR connection to +12 V, R2, and the Q1 pin order.
- Relay buzzes or chatters at dusk: the light is changing slowly and the circuit sits near its threshold. Shield the LDR, add a 100 microfarad capacitor from node A to ground to slow changes, or use the op-amp comparator with hysteresis described in the dark/light sensor project.
- Q2 gets hot or fails: check D1 is present and correctly oriented, and that the relay coil current is under 100 mA.
- Lamp flickers when on: the supply may be too weak. Use an adapter rated well above the lamp current.
Summary
You built a light-controlled switch from an LDR divider, two BC547 transistors and a relay. The divider converts light into voltage, Q1 senses it, Q2 inverts and drives the relay, and the relay switches the lamp at 12 V. The same front end can control a fan, a buzzer or a garden light, and once you understand it, the op-amp version with hysteresis is a natural next step.