top of page

Smart Lighting System - Using LED's, LDR and Raspberry Pi

Updated: Apr 6

Street lights play a major role in increasing the safety of people working late nights like drivers. Lighting accounts for 10-38% of the total electrical energy consumption across the globe. Initially, operation of lights was done manually. As people getting busy day by day in their daily routine activities, they keep forgetting to switch OFF the lights even when there is ample amount of sunlight present and switch ON when there is a need for lights. This lead to heavy wastage of electricity. Later, engineers came up with the timer circuits in which the circuit allows the light to function for a pre-defined time interval. But, this idea also had its drawbacks due to the seasons, weather conditions and at times during special occasions when the need for lighting differs from the usual periods.

Our project comes up with an easy solution for the above-mentioned drawbacks from the previous models. In this concept, we use an LDR sensor to sense the amount of sunlight present in the environment. With the help of these LDR values switching of lights will be done automatically. It automatically switches OFF the lights in the presence of illumination and switch ON the lights in a case when the sunlight goes below the visible region of eyes.

Hardware Requirements:

1. Breadboard:


A #breadboard is a flat piece of wood that is provided with holes that allow users to build a circuit including the components and connections without the need for soldering due to which it is reusable and finds its best usage for the students who are new to build circuits. The holes in any horizontal line will be in series whereas the vertical holes remain at an equipotential state. There are different sizes of breadboards available in the market which include "full size", "half size" and, "mini size" breadboards.

2. Connecting wires:

Connecting wires
Connecting wires

Jumper wires are used to establish connections between different components in the circuit.

3. USB Cable: This USB cable is used to connect the Raspberry Pi to the power supply. It also helps in the transmission of data.

USB Cable
USB Cable

4. LDR Sensor:

LDR- Light Dependant Resistor Sensor
LDR- Light Dependant Resistor Sensor

LDR- Light Dependent Resistor. This is a cadmium-sulfide cell works based on the principle of Photoconductivity. It is a resistor whose resistance value changes depending upon the intensity of light falling on it. When the light falls on the surface of the senor, material conductivity varies as a result of which resistance also varies.

5.Raspberry Pi 4 Model-B:

Raspberry Pi 4 Model-B
Raspberry Pi 4 Model-B

We are using #Raspberrypi to connect with the LEDs, the #LDR sensor, and display the output. It contains several I/O pins using which we can connect the module and then by coding the Raspberrypi, we will receive the commands/signals that are sent from the mobile. This powerful credit-card-sized single-board computer can be used for many applications and supersedes the original Raspberry Pi Model.

6. Ceramic Capacitor:

0.1 uF ceramic capacitor
0.1uF ceramic capacitor

Luminous intensity is inversely proportional to the resistance. The resistance of the LDR changes with respect to the change in intensity. This value of the resistance will be sensed by using the time constant concept. Based on the value of the time constant (i.e., the time taken to charge the capacitor is resistance multiplied by the value of capacitance.) resistance of the LDR can be found accordingly. In this project, we use a 0.1uF ceramic capacitor.

7. 16*2 LCD: LCD- Liquid Crystal Display is an electronic module that uses liquid crystal to produce a visible image. It is the basic module that is generally used in DIY and circuits. The display segments are affordable and simply programmable.

16*2 LCD
16*2 LCD

8.LED's: LED is a semiconductor light source that emits light when a current passes through it. Electrons in the semiconductor combine with holes by passing through the gap which inturns release energy in the form of photons. In this project, we use 4 LEDs of any desired color.


9. LCD Backpack: To reduce the number of I/O pins, an I2C module is used to interface the 16*2 LCD with the raspberry pi module.

LCD Backpack

10. SD Card:

SD card
SD Card

SD card is the key part of a Raspberry Pi, It provides the initial storage for the Operating System and files.

Software Requirements:

1. SSH Terminal: The SHH Terminal is used in this project to connect the Raspberry Pi module to the terminal of another computer or peripheral device. Encrypted data transfer between two computers is supported by this terminal.

SSH Terminal
SSH Terminal

2. Python IDLE: Programming is done in #Python language in an IDE (Integrated Development Environment) which is a platform where we can not only write the code but also run, and test the working.

Python Idle
Python Idle

Circuit Connection:

Hardware Circuit:

Smart lighing system using Raspberry Pi - Circuit diagram
Smart lighing system using Raspberry Pi - Circuit diagram

What goes where??

Circuit Connection involves the following steps:

  • Both the terminals of the LDR sensor are connected to the GPIO pins of the Raspberry Pi and one terminal of the capacitor is connected to the LDR sensor terminal and the other terminal is connected to the ground.

  • All the 4 LEDs are connected in parallel between Vss and the ground.

  • 16*2 display is connected using the backpack.

  • Ground and Vcc and of the I2C module are connected to the ground and Vcc of the Raspberry pi.

  • Similarly, SDA and SCL pins of I2C pins are connected to the corresponding pins of Raspberry pi as shown in the circuit diagram.

  • USB cable is used to power up the Raspberry Pi.

Code :

Note: All these files should be converted to the python file format (i.e., .py format) before uploading the code to the Raspberry Pi board.


In the program, we have set the LDR value threshold - 500. So, whenever the value goes above 500, the Raspberry Pi would turn all the LEDs connected ON and if the value is below 500 then the LEDs are OFF.

Output 1 - Starting the Project

Smart Lightening mode : ON

Output 2 - LDR value below the threshold


Output 3 - LDR value above the threshold


Check the practical implementation of the above-explained project and see how it works before you try it yourself.

Video by- Sai Parimal

Check the Project working video here - Smart Lighting System - Prototype


See Also:

Related Posts

See All


Anushka Gupta
Anushka Gupta
Aug 01, 2023

This blog is a treasure trove of knowledge for electronics enthusiasts. The Smart Lighting System guide is outstanding, and the inclusion of Raspberry Pi adds a whole new dimension to the project. Learn Electronics India, you guys rock.


Informative and concise! LearnElectronics India always delivers quality content.

bottom of page