Lights Out!

Made by monishag

Lights Out is a device that detects whether a person has left the lights on after leaving a room to help them conserve power.

Created: February 2nd, 2017

0

Problem Statement

I am designing this hack for college students who don’t live on campus, who have to worry about power bills, and who need help figuring out where they could save electricity. The area of power usage I am specifically focusing on is light usage.

College students have very hectic schedules, and so it’s hard to figure out patterns in their behavior. Using an IoT appliance would be great for them specifically because it can just silently monitor their actions without requiring any additional work in their busy lives. 

I chose college students because I personally am one and can relate more as a result. And I chose this problem because turning off unnecessary lights is personally something my roommate and I have a problem doing consistently.

0

Goal

I am trying to create a solution that monitors whether a person has left the lights on in a room/apartment after they have left. It then records that information so that the person can determine what their light usage patterns are and hopefully modify their behavior to save more on power bills.

0

Process

The components I used are:

1. Particle Microcontroller

2. Breadboard

3. Jumper Wires

4. 1kΩ Resistor

5. 10kΩ Resistor

6. A single color LED

7. Photoresistor

8. A double pole double-throw (DPDT) switch

I used two tutorials to figure out how to set up my circuits and write the code for those circuits. The first is how to set up a photoresistor (http://diotlabs.daraghbyrne.me/3-working-with-sensors/photoresistors/) and the second is how to set up a switch (http://diotlabs.daraghbyrne.me/5-getting-input/switches/). I combined both the circuits and the code from each tutorial to get my final outcome (see pictures below). 

The main challenges from this iteration of the project were figuring out how the breadboard and some basic circuitry worked, and figuring out technical issues with compiling and writing code for the microcontroller. One specific challenge I had was determining why my LED wouldn't fade when the photoresistor wasn't getting any light (like it was supposed to). The reason was that there was a small range of values that the photoresistor was reading, but my program took a bigger range and mapped it to LED values. So the LED values would only change by a little because the range of photoresistor values that was mapped to it was so large compared to the actual range. After measuring what range the photoresistor was reading and then changing my code to reflect that, my LED faded appropriately. Most of the other problems were solved by trying different circuit configurations out and searching through the internet for documentation for the coding language.

 


0
Code for Lights Out Circuit
// Code samples used from following tutorials:
// http://ideate.xsead.cmu.edu/gallery/projects/manage_projects/lights-out/documentation
// http://diotlabs.daraghbyrne.me/5-getting-input/switches/

// We will be using D1 to control our LED
int ledPin = D1;

// Our button wired to D0
int switchPin = D0;

// Define a pin that we'll place the photo cell on
int photoCellPin = A0;

// Create a variable to hold the light reading
int photoCellReading = 0;

// Create a variable to store the LED brightness.
int ledBrightness = 0;

void setup()
{
  pinMode( switchPin , INPUT_PULLUP); // sets pin as input
  pinMode( ledPin , OUTPUT ); // sets pin as output
  Particle.variable("light", &photoCellReading, INT);
}

void loop()
{
   int switchState = digitalRead( switchPin );
   Serial.print(switchState);
  if( switchState == LOW )
  {
    photoCellReading = analogRead(photoCellPin);
    // Publish the value of the photoresistor's reading to the cloud
    Particle.publish("Light Value", String(photoCellReading), 60, PUBLIC);
    ledBrightness = map(photoCellReading, 1900, 3600, 0, 255);
    analogWrite(ledPin, ledBrightness);
    delay(100);
  } else {
  digitalWrite( ledPin, LOW);  }

}
Click to Expand
0

Outcome

The final outcome is a prototype that, when turned on, will detect if you have left the light on in the room or not. It will then record the light value to the cloud. In a real-life scenario, when a person leaves the room, they would turn on the device. Of course, this isn’t as out-of-the-way as I stated in the problem statement, so next steps could include adding another sensor that detects when a person leaves a room. Then, they wouldn’t have to manually change the device settings, making the device more a part of the background (which could then allow the device to get more accurate readings).  

0
Final Circuitry Layout
Img 6429.jpg.thumb Monisha Gopal (2017)
0

Reflection

The main thing I learned from making this project is that sometimes not all the features that I initially wanted can be implemented by the deadline. Perhaps next time, I can come up with different sets of goals for the project. That way, I at least have a basic version, and if I have time, I can add more “intermediate” and “advanced” features to the prototype. 

Also, I thought that my problem statement could be easily solved. However, there are some non-trivial things that I would need to figure out. For example, how would I know (without this switch) that someone has left the room or left the house? How would I be able to differentiate between natural light and light bulb light? Where would the optimal place for each sensor be and what kind of casing would it need to have to be useful? These are good things to consider when expanding this project.

x
Share this Project


Focused on
About

Lights Out is a device that detects whether a person has left the lights on after leaving a room to help them conserve power.