Smart Table Lamp Project using Arduino: DIY IoT Project

IoT Based Automatic Table Lamp project

Smart Table Lamp Project Using Arduino

In this project, we will make an IoT based automatic smart 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

circuit diagram for smart table lamp project using IoT

 

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 of Table Lamp Project

automatic table lamp project result

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 alsoAutomatic Traffic Light Controller using Arduino: Traffic light Control System project

 

Let us know your comment on “Smart table lamp project using Arduino” in the section below.

 

Ready to Explore More? Let’s Build Smarter Together!

🔔 Subscribe to Our YouTube Channel » for IoT video Tutorials.
🌐 Start Learning IoT Basics Now » and What is IoT? – Introduction to IoT for Beginners on IoTDunia.com!

      and Check out Top IoT Applications in Real World – Smart Use Cases 2025IoT career guide 2025Best Projects on IoT for Beginners

👉 Have questions? Drop them in the comments!

💡 Start small, stay curious, and make your world smarter—one device at a time.

IoTDunia
IoTDunia is working towards a vision of empowering the youth by providing them with great professional opportunities with Internet of Things to build world class ecosystem.