Updated: Jun 28, 2022
Imagine yourself as an office employee. Further in the morning, you went to your workplace without switching off the lamp in your home. Just imagine, how many units of current will be wasted until you get back home in the evening. In order to avoid this kind of energy wastage, the concept of a smart lighting system is being introduced. It is nothing but controlling of electrical appliances such as lamps using the internet and mobile application.
This article gives a detailed explanation of this concept starting from circuit assembling till the end output. Here, instead of electrical appliances, we are using #LEDs for better understanding. #Blynk is a mobile application designed to control electrical appliances. The article provides step by step instructions involved in this interfacing which is pretty simple, starting from the list of electronic components required.
The list provides all the hardware and software components required for the interfacing.
This is a cadmium-sulfide cell works based on the principle of Photoconductivity. It is basically a resistor whose resistance value changes depending upon the intensity of light. When the light falls on the surface of the senor, material conductivity varies as a result of which resistance also varies.
2. Raspberry pi 3:
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.
3. Jumper wires:
These are simple connecting wires, that are used to connect the ends without any soldering. The male wires have the ends that can be connected to other ends and the female wires are the ones that have the receiving end.
4. USB Cable:
This cable is used to connect the Raspberrypi to the power supply. It also helps in the transmission of data.
The resistance measured by the LDR sensor is done with the help of time constant concept. The time required to charge a capacitor is equal to the multiplied value of resistance of the circuit and capacitance. Here, a 0.1 uF capacitor is used.
The SHH Terminal is used in this project to connect the Raspberrypi module to the terminal of another computer.
#Python Programming is done in an IDE (Integrated Development Environment) is a platform where we can write the code, run, and test the working.
In this section, let's see the connections made to the interface #Bluetooth module to the Raspberrypi device.
What goes where?
The Blue line connects one terminal of the LDR sensor to GPIO 17 pin of the raspberry pi module. The other end of the sensor is connected to one end of the capacitor.
The orange line connects this end to GPIO 27 pin of the raspberry pi.
Another end of the capacitor is connected by the Black wire to the ground (GND) pin of the pi module.
Now, we shall see the interface of LEDs with the raspberry pi. The anode of LED 1, LED 2, LED 3 are first connected to the resistors to avoid damage of the board and LED at any circumstances. Then the same end is connected to the GPIO 18, 15, and 16 pins respectively. The cathode of all three LEDs is connected to the overall ground.
After completing the hardware connections and the app configurations, the circuit is connected to the power supply.
Note: This file is in the text format and should be converted to python-format (.py) before downloading.
We have to configure our Blynk app with respective buttons to show the output. Create a new project and select the device raspberry pi 3. Enter the value display settings and allocate virtual buttons for each LED. The virtual buttons are used to display the data on the app.
The V5 button is for LED 1.
The V7 button is for LED 2.
The V6 button is for LED 3.
V8 button is to select either smart mode or the manual mode.
In Smart mode, the LEDs get ON once the resistance value is above the default threshold value. Here, the threshold value is 500 ohm. In manual mode, irrespective of the threshold value the ON/OFF of the LEDs is determined manually.
After the execution of code, now let us check the working of the circuit. Now the setup is in the manual mode.
When the virtual button for LED 1 is ON, the corresponding output is,
Similarly, when the virtual button for LED 2 is ON, the output is:
When all the three virtual buttons are ON, the output is:
We can also perform operations such as all buttons are OFF, only 2 buttons in ON state, and obtain the respective output. Now the setup is switched to the smart mode. At first, all three LEDs are glowing because the LDR value is above the threshold value (500 ohms).
When the mobile flashlight is on, the LDR value starts decreasing. At some point, it gets below the default threshold value and all the LEDs get OFF.
The practical implementation of this interfacing is presented here as a video.
Video credits: Sai Parimal
As mentioned before, nowadays the demand for a smart lighting system is getting increased. By experimenting with this prototype of controlling LEDs using a mobile application, we can understand the concept of controlling our smart home appliances from workplaces. Energy conservation is a big advantage of this theme.