In this session we are going to make a 9WATT Emergency Lamp using Raspberry Pi and Python. This lamp will automatically detect the darkness and absence of AC power supply, and light up when there is power failure and proper light is not there.
Although there are various emergency lamps available but they are purely dedicated to serve single purpose, like one Simple Emergency Light Circuit that we have created previously, triggers only on power failure. With Raspberry Pi we can add various other functionalities to it, like here we have added LDR to detect Darkness at various levels. Here we have added two levels, when there is complete dark, the lamp will glow with full intensity and when there is semi dark, it will glow at 30% capacity. So here we are going to design this lamp to be turned ON when AC line power is OFF and when the light intensity in the room goes very low.
Here we are using Raspberry Pi 2 Model B with Raspbian Jessie OS. All the basic Hardware and Software requirements are previously discussed, you can look it up in the Raspberry Pi Introduction and Raspberry PI LED Blinking for getting started, other than that we need:
- 1000µF capacitor
- 1WATT LED (9 pieces)
- +12V Sealed LEAD ACID battery
- 6000-10000mAH power bank
- +5V DC adapter
- Lm324 OP-AMP chip
- 4N25 Optocoupler
- IRFZ44N MOSFET
- LDR (Light Dependent Resistor)
- LED (1 piece)
- Resistors: 1KΩ (3 pieces), 2.2KΩ, 4.7KΩ, 100Ω (2 pieces), 10Ω (9 pieces), 10KΩ, 100KΩ
- 10KΩ pot (3 pieces) (all resistors are 0.25 watt)
Before going into Circuit Connections and its working, we will learn about the components and their purpose in the circuit:
9 Watt LED Lamp:
The LAMP is made up of nine 1WATT LEDs. There are different kinds of LEDs present in market but 1WATT LED are easily available everywhere. These LED operate at 3.6V, so we will connect three of them in series along with protection diodes to operate at +12V. We will connect three of these strips forming a 9WATT LED lamp. We will operate this lamp with Raspberry Pi accordingly.
LDR (Light Dependent Resistor) to detect Darkness:
We are going to use LDR (Light Dependent Resistor) to detect the light intensity in the room. The LDR changes its resistance linearly with the light intensity. This LDR will be connected to voltage divider. With that we will have variable voltage to represent variable light intensity. If the light intensity is LOW the voltage output will be HIGH and if light intensity if HIGH voltage output will be LOW.
Op-amp LM324 IC for checking LDR output:
Raspberry Pi does not have an internal ADC (Analog to Digital Converter) mechanism. So this setup cannot be connected directly to Raspberry Pi. We will use OP-AMP based comparators to check the voltage outputs from LDR.
Here we have used op-amp LM324 which has four operational amplifiers inside it and we have used two op-amps out of those four. So our PI will be able to detect light intensity at two levels. Depending on these levels we will adjust the brightness of LED lamp. When there is complete dark, the lamp will glow with full intensity and when there is half dark, it will glow at 30% capacity. Check the Python code and video, at the end, to understand it properly. Here we have used PWM concept in Raspberry Pi to control the intensity of LEDs.