SmartLamp

Made by Josh Somers · UNLISTED (SHOWN IN POOLS)

Recently, the light bulb burned out in one of my roommate’s rooms. So he just uses a lamp, but has to find it in the dark. My hack for this is a motion sensor on the lamp that will automatically turn on when there is movement sensed. When he walks into the room, the sensor will pick up his motion and automatically turn the light off. Once the light is on, it will continue to sense motion, and after 15 motionless minutes; it will then flash blue for one minute, warning that it will turn off.

Created: January 25th, 2018

0

Problem Statement

This creative home hack that I am designing is for one of my roommates. At the beginning of the year his room light burned out, and he did not have the motivation to replace it. Since the light did not work he had to resort to a lamp by his bedside for lighting. When it was dark outside, there was no natural light in the room, and when he would try to make his way to his bedside for the lamp, he would trip on his clothes because he couldn’t see where he was going. 

0

Goal

The goal of my homehack is to design a motion activated light (lamp) that can be used in my roommate’s room so that he doesn’t have to stumble around the room just to turn the light on. Another feature that is to be added to this device is a email notification whenever the light is turned on. This combines the functional nature of a lamp with a security mechanism that my roommate can use to tell if and when people enter his room. 

0

Process

During the course of this project, I lost most of my code because my computer ran out of storage space and so the code wasn’t saved. I do have a new revised code however that is functional. See photos and videos for the arrangement. As a chemistry major with little coding experience, I found the majority of the project to be difficult. One of the hardest parts was trying to get the motion sensor to turn the light on and have the light stay on for a certain period of time, and then time out and turn off. Another challenging part of this was to get the motion sensor to be constantly taking in data and updating the motion to delay the amount of time the light would be on. I was only partially able to solve this problem, in that I was able to have the light turn on and stay on for a set time, but it only detected motion once the delayed light time was over. Overall, I was able to have the motion sensor detect motion, turn a light on and then send an email notification. The notification only worked once and I could not figure out how to get it to work consistently. 

I began by following directions from a hackster project (https://www.hackster.io/reagan-bush-84/motion-activated-light-switch-3eac2e) with assembling the motion sensor. I then used the tutorials and other help from the iot website (http://diotlabs.daraghbyrne.me/7-communicating-events/pir/) to work on getting the sensor to work and writing the code. 

A push button was added to give it a manual on/off switch for the light in case the motion sensor doesn't pick up motion or my friend wants to turn the light off.

0
0

Outcome

The complete prototype would be hooked up to the lamp if I were able to get it connected. Currently there is just an LED representing the lamp. One thing that I would add next is a voice sensor that could detect my roommates voice so that it wouldn’t send him alerts when he was entering the room. 

0
int inputPin = D0;              
int ledPin = D1;                
int buttonPin = D4;
int pirState = LOW;             // start no motion detected
int val = 0;                    // 

int calibrateTime = 10000;      // wait for calibration



void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode(inputPin, INPUT);     
  pinMode( buttonPin , INPUT_PULLUP);
}

void loop()
{
  int buttonState = digitalRead( buttonPin );
  if( buttonState == LOW )
  {
    setLED( HIGH );

    digitalWrite( ledPin, HIGH);
  }
  //  digitalWrite( ledPin, LOW);
  //}
  // if the sensor is calibrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();

    // report it out, if the state has changed
    reportTheData();
    //Particle.publish("motion_detected");
  }
}

void readTheSensor() {
  val = digitalRead(inputPin);
}

bool calibrated() {
  return millis() - calibrateTime > 0;
}

void reportTheData() {

int buttonState = digitalRead( buttonPin );


  if (val == HIGH) {

    // the current state is no motion
    // changed
    // announce this change by publishing an eent
    if (pirState == LOW) {
      // we have just turned on
      Particle.publish("motion");
      // Update the current state
      pirState = HIGH;
      setLED( pirState );
      delay(10000);
      Particle.publish("motion");

    }
  }

  else {
    if (pirState == HIGH) {
      // we have just turned of
      // Update the current state and flash for off
      pirState = LOW;
      setLED( LOW );
      delay(1000);
      setLED( HIGH );
      delay(1000);
      setLED( LOW );
      delay(1000);
      setLED( HIGH );
      delay(1000);
      setLED( LOW );
      delay(1000);
      setLED( HIGH );
      setLED( pirState );
      Particle.publish("motion_complete");
    }
  }
}

void setLED( int state )
{
  digitalWrite( ledPin, state );
}
Click to Expand
0

Bill of Parts:

-Particle photon

-PIR motion sensor

-7 Jump Wires

-Resistor 1k ohm

-1 LED

-Breadboard

-1 Pushbutton

-USB Micro cable


0
0

Reflection

I learned a lot from this project. The main thing that I learned is that coding is tough and there are so many small things that make a huge difference in whether the code works or not. Even though I was focused on this specific project, the entirety of the assignment I was thinking of other homehacks that would be innovative and beneficial to either myself of my roommates; I even thought of and Iot for my brother. I got almost to where I wanted. It was hard for me to dig deep into the code with litte background and confusing tutorial videos and minimal time, however I do think I learned a lot from this project and got a lot out of it. I think I would need more lessons on the programming aspect of the project in order to make it better, just because I don’t have a lot of experience and every step would take be way longer than it should have.  

0

Project Summary

#smartlamp this is a product that eliminates the light switch and at the same time notifies the user when someone enters their room. 

x
Share this Project

This project is only listed in this pool. Be considerate and think twice before sharing.


Courses

49313 Designing for the Internet of Things (Undergrad)

· 22 members

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


About

Recently, the light bulb burned out in one of my roommate’s rooms. So he just uses a lamp, but has to find it in the dark. My hack for this is a motion sensor on the lamp that will automatically turn on when there is movement sensed. When he walks into the room, the sensor will pick up his motion and automatically turn the light off. Once the light is on, it will continue to sense motion, and after 15 motionless minutes; it will then flash blue for one minute, warning that it will turn off.