top of page
Writer's pictureSanskruti Ashtikar

Automatic Street Light Control Using 8051 Microcontroller

Introduction


Automatic street light control systems are designed to manage the lighting of street lamps efficiently by turning them on during the night and off during the day. This system saves energy and reduces manual intervention. In this project, we will design an automatic street light control system using the 8051 microcontroller and a Light Dependent Resistor (LDR) sensor to detect the ambient light levels.


Components Required


  • 8051 Microcontroller (e.g., AT89S52)

  • Light Dependent Resistor (LDR)

  • Operational Amplifier (Op-Amp, e.g., LM358)

  • Relay Module (to control the street light)

  • Resistors (10kΩ, 1kΩ, 330Ω)

  • Capacitors (33pF, 100μF)

  • Crystal Oscillator (11.0592 MHz)

  • Transistor (e.g., BC547)

  • Diode (e.g., 1N4007)

  • Breadboard and Connecting Wires

  • Power Supply (5V for the 8051, 12V for the relay)


Circuit Diagram


The LDR sensor is used to detect the light levels and the Op-Amp is used as a comparator to determine whether it is day or night. The 8051 microcontroller reads the output from the comparator and controls the relay to switch the street light on or off.


+5V ----- +5V
          |
          |
        LDR
        +---+
        |   |
        |   |
       10kΩ |
        |   |
        |   +---------- P1.0 (8051)
LM358 Op-Amp
    +Vcc to +5V
    GND to Ground
    Non-Inverting Input (+) to Voltage Divider (LDR and 10kΩ resistor)
    Inverting Input (-) to Reference Voltage (set with a potentiometer)
    Output to P1.0 (8051)
Relay Module
    VCC to +12V
    GND to Ground
    IN to P2.0 (8051)
    NO to one terminal of the street light
    COM to AC mains (through a fuse)
Transistor (BC547)
    Collector to IN (Relay Module)
    Emitter to Ground
    Base to P2.0 (8051) through 330Ω resistor
Diode (1N4007)
    Anode to Ground
    Cathode to Collector (Transistor)

Pin Connections


  • LDR and Resistor:

  • One terminal of the LDR to +5V

  • The other terminal to a voltage divider with a 10kΩ resistor and then to the non-inverting input of the Op-Amp.

  • The same point between the LDR and resistor to P1.0 of the 8051.

  • Op-Amp (LM358):

  • Non-inverting input (+) connected to the voltage divider (LDR and resistor).

  • Inverting input (-) connected to a reference voltage set using a potentiometer.

  • Output connected to P1.0 of the 8051.

  • Relay Module:

  • VCC to +12V

  • GND to Ground

  • IN connected to the collector of the BC547 transistor.

  • NO connected to one terminal of the street light.

  • COM connected to AC mains.

  • Transistor (BC547):

  • Collector connected to IN of the relay module.

  • Emitter to Ground.

  • Base connected to P2.0 of the 8051 through a 330Ω resistor.


Software Implementation


The code is written in C using Keil uVision IDE. It involves reading the LDR sensor's output, determining whether it is day or night, and controlling the relay accordingly.


#include <reg51.h>
sbit LDR_INPUT = P1^0; // LDR sensor output
sbit RELAY = P2^0; // Relay control pin
void delay(unsigned int count) {
    int i, j;
    for(i=0; i<count; i++)
        for(j=0; j<1275; j++);
}
void main() {
    while(1) {
        if (LDR_INPUT == 0) { // Night time (LDR output low)
            RELAY = 1; // Turn on the street light
        } else { // Day time (LDR output high)
            RELAY = 0; // Turn off the street light
        }
        
        delay(1000); // Check every second
    }
}

Explanation


  1. Initialization:

  2. No special initialization is required for this simple project. The main loop continuously monitors the LDR sensor's output.

  3. Reading LDR Output:

  4. The LDR sensor output is read from P1.0. If it is low, this indicates it is night time (since the LDR resistance increases in the dark, causing a low voltage at the Op-Amp's output).

  5. Controlling the Relay:

  6. If the LDR sensor output is low (indicating night time), the relay is turned on by setting P2.0 high. This energizes the relay coil and turns on the street light.

  7. If the LDR sensor output is high (indicating day time), the relay is turned off by setting P2.0 low, turning off the street light.

  8. Delay Function:

  9. The delay function is used to introduce a small delay between each check of the LDR sensor's output.


Conclusion


This project demonstrates the use of the 8051 microcontroller to create an automatic street light control system. By integrating an LDR sensor and a relay module, the system can automatically switch street lights on and off based on the ambient light levels. This project is a great way to learn about sensor interfacing, relay control, and using microcontrollers for automation applications.


Want us to guide you through your project or make the project for you ?






Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 


10 views0 comments

Related Posts

See All

Comments


bottom of page