IoT Based Automatic Table Lamp project
In this project, we will make an IoT based automatic table lamp using Arduino, which can turn on and off automatically based on human presence. This system uses a PIR sensor to sense human presence and detect human motion. The circuit works on the readings from this sensor. A relay module is an electrical switch which allows microcontrollers to control large electrical loads.
In this project, a two-channel relay module is used, with only one relay. To control a single relay on the circuit, the VCC, GND and IN1 pins of the relay module are used. The relay module is used as active LOW, that is, when the IN1 pin is HIGH, the relay is OFF and when it is LOW, the relay is activated.
The connection of the Arduino, PIR sensor and relay module is done as follows:
- PIR sensor’s data OUT pin is connected to Arduino’s Digital I/O Pin 8. An LED is connected to pin 13 of Arduino to indicate whether the light is turned ON or OFF.
- IN1 pin of the Relay Module is connected to Pin 9 of Arduino.
- A bulb is connected to mains supply through relay. One terminal of the bulb is connected to one wire of the mains supply. The other terminal of the bulb is connected to the NO (Normally Open) contact of the Relay Module.
- COM (Common) contact of the Relay is connected to the other wire of the main power supply.
When there are no people around the lamp, the OUT pin of PIR sensor remains LOW. If the sensor detects any human motion around it, the output becomes HIGH. This is captured by the Arduino and it in turn activates the relay by making the relay pin LOW. This turns on the lamp.
If the IR radiation becomes stable, for example when the person leaves or takes a nap, then the output pin of the sensor becomes LOW again. This is situation, the Arduino turns off the relay by making the relay pin HIGH.
Therefore, with the proper Arduino programming, we can easily make an automated table lamp, which can help greatly in saving electricity. A similar circuit and PIR sensor can be used to make other automated projects, like automatic flush system, automatic door opener, etc.
Components required
- Arduino UNO
- PIR Sensor
- 5V relay module
- 100 Ω resistor
- Breadboard
- Jumper wires
Circuit Diagram
Image credit: electronicshub.
Code
int in1 = 9;
int sensor = 8;
int led = 13;
unsigned long t=0;
void setup()
{
Serial.begin(9600);
pinMode(in1, OUTPUT);
pinMode(sensor, INPUT);
pinMode(led, OUTPUT);
digitalWrite(in1,HIGH);
digitalWrite(led,LOW);
while(millis()<13000)
{
digitalWrite(led,HIGH);
delay(50);
digitalWrite(led,LOW);
delay(50);
}
digitalWrite(led,LOW);
}
void loop()
{
digitalWrite(in1,HIGH);
digitalWrite(led,LOW);
if(digitalRead(sensor)==HIGH)
{
t=millis();
while(millis()<(t+5000))
{
digitalWrite(in1,LOW);
digitalWrite(led,HIGH);
if((millis()>(t+2300))&&(digitalRead(sensor)==HIGH))
{
t=millis();
}
}
}
}
Output Images
Image credit: arduinoprojecthub
Advantages
- Saves electricity and energy
- Cost effective
- Completely automated system
Disadvantages
- Might turn off if no human motion is detected, but light is still required, like while reading a book.
Applications
- Houses
- Offices
- Schools
- Garages
- Markets
- Hospitals
See also: IoT Based Energy Monitoring System – Smart Energy System
Let us know your comment on “IoT based automatic table lamp using Arduino” in the section below.
If you like this post subscribe our YouTube Channel for IoT video Tutorials. You can also find us on Twitter, Facebook, and Instagram for more updates.
Start your IoT journey with IoT Basics from IoTDunia.
References:
Leave a Review