Automated Room Light

Made by Vaibhav Gupta

Found in DioT 2019: Augmented Objects

The project aims to automate the turning on and off the room lights by sensing a person entering or exiting the room. While in the room, the room lights could be triggered on and off by using a smartphone. For controlling the light the device would be set on already existing switch and mechanically move the switch to automate the process.

0

Problem Statement

A rented home is generally not designed as per the tenant's comfort. Also, tenant's are not very interested in making expensive/painstaking home improvements. One such problem is controlling the lights of the room before sleeping. The switch position is far from the bed which needs the tenant to switch off the lights and then navigate to the bed in dark.

0

Goal

The goal was to develop a modular attachment that could automate the turning on/off the room lights. This would improve the comfort of the tenant while maintaining the flexibility of having a modular/non-permanent home improvement solution.  The solution would consist of sensors at the door, which senses when a person enters the room and turns off when the person exists. Along with that, the person can remotely operate the switch using a smartphone.

0

Process

The project started with identifying the sensors needed for the implementation. For sensing the entry and exit through the door, two IR break beam sensors were used. A single IR break beam sensor is sufficient to identify a break, but to have a sense of direction, two IR break beam sensors were employed. Next, to actuate the switch, a servo motor was the ideal choice. For the initial prototyping, an LED was used to see the correct functioning of the direction sensing algorithm.

0

Outcome

The final prototype functioned as expected, turning on the LED when a person passes in one direction and turning it off when they pass the other direction. The code was further improved to acknowledge the number of people in the room so that the lights do not turn off when someone walks out while someone else is still in the room.

0
#define SENSORPIN1 1 //Defining entry side IR break beam sensor pin
#define SENSORPIN2 2 //Defining exit side IR break beam sensor pin
#define LEDPIN 3 //Defining the LED pin

int sensorState1 = 0; //Variable to store the entry side IR break beam sensor reading; 1 is unbroken, 0 is broken
int sensorState2 = 0; //Variable to store the exit side IR break beam sensor reading;  1 is unbroken, 0 is broken
int state = 0; //Variable to store the state of light; 1 is ON, 0 is OFF
int numPeople = 0; //Variable to store the number of people in the room

void setup() {
  
  pinMode(LEDPIN, OUTPUT); //Defining the light as an output
  digitalWrite(LEDPIN, LOW); //Initially the light stays off
  pinMode(SENSORPIN1, INPUT_PULLUP); //Setting the entry IR break beam sensor as a pull up input
  pinMode(SENSORPIN2, INPUT_PULLUP); //Setting the exit IR break beam sensor as a pull up input
 
}
 
void loop(){
  
  sensorState1 = digitalRead(SENSORPIN1); //Reading the entry IR break beam sensor 
  sensorState2 = digitalRead(SENSORPIN2); //Reading the exit IR break beam sensor
    
    if (sensorState1==0) { //Checking if the entry beam is broken
        numPeople++; //Increasing the number of people in the room
        state = 1; //Setting the light state to ON
        delay(1000); //Delay to prevent misreading of exit beam
    }
    
    if (sensorState2==0) { //Checking if the entry beam is broken
        if (numPeople==0) { //Checking the number of people in the room
            return; //If no one is in the room, the function does nothing
        } else { //If the number of people is non zero
            numPeople--; //Reduce the number of people in the room
        }
        state = 0; //Setting the light state to OFF
        delay(1000); //Delay to prevent misreading of exit beam
    }
    
    if (state==1) { //Checking if the light state is ON
        digitalWrite(LEDPIN, HIGH); //If yes, we turn on the light
    } else { //If not, then the state is OFF
        if (numPeople>0) { //If the number of people in the room is non zero
            state=1; //The light state is changed to ON
        } else { //If the number of people in the room is zero
            digitalWrite(LEDPIN, LOW); //We turn off the light
        }
    }
}
Click to Expand
0
0

Next Steps

The intended functioning of the project is in the wireless nature. To attain it, the IR break beams must wirelessly convey the sensor data to the microprocessor which would control the servo to actuate the switch. Also, a wireless power source must be designed to give power to the sensor and microprocessor.

0

References

A major challenge was developing the algorithm for the direction sensing and triggering. The main reason for the challenge was a variable delay in the sensors turning off due to the motion.

x
Share this Project

Courses

49713 Designing for the Internet of Things

· 18 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


Focused on
About

The project aims to automate the turning on and off the room lights by sensing a person entering or exiting the room. While in the room, the room lights could be triggered on and off by using a smartphone. For controlling the light the device would be set on already existing switch and mechanically move the switch to automate the process.

Created

January 31st, 2019