Snack Preventer

Made by Alok Joshi

Found in Home Hack

My roommate loves to snack. He literally opens the fridge 20 times a day and forgets to close the fridge door 20 times a day. 'Snack Preventer' is an IoT device that reminds you to close the fridge door via a visual cue (LED) and a sound. The device also sends you an alert message reminding you of the number of times you snacked today.

0

Intention

My roommate loves to snack. He literally opens the fridge 20 times a day and forgets to close the fridge door 20 times a day. 'Snack Preventer' is an IoT device that reminds you to close the fridge door via a visual cue (LED) and a sound. The device also sends you an alert message reminding you of the number of times you snacked today. After getting an alert message my roommate will become more conscious about his snacking habit and then hopefully he will make an effort to curb it.

0

Process

Since this was the first IoT device prototype I was making on my own, I decided to research on the components required to make the prototype. After researching on the major components: PIR motion detection sensor and a piezo sound generator, I found out other projects which used the same components on their devices. From the precedent projects, I learn't how the code worked for each of these components. I changed the code so that the PIR sensor notices the fridge door opening up causing the LED to light up. If the door is opened 5 times (count = 10, since one motion is for open and one for close) the device will play a melody and send an SMS to alert my roommate. SMS capability was added using IFTTT and a single line of code - Particle.publish()

0

Product

Bill of Materials:

- Particle Photon

- Breadboard

- Jumper Cables

- 1k Ohm resistor

- LED

- PIR Sensor

- Piezo sound generator

0
int speakerPin = D2; //Speaker as OUTPUT at D2
int inputPin = D0; // PIR sensor = INPUT at D0
int ledPin = D1; // LED at D1
int val = 0; // inputPin status
int count = 0; // Counter Variable

// create an array for the notes in the melody:
//C4,G3,G3,A3,G3,0,B3,C4
int melody[] = {1908,2551,2551,2273,2551,0,2024,1908};

// create an array for the duration of notes.
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {4,8,8,4,4,4,4,4 };

void setup() {

  pinMode( speakerPin, OUTPUT ); // Speaker as OUTPUT
  pinMode( ledPin, OUTPUT ); // LED as OUTPUT
  pinMode(inputPin, INPUT); // Motion detection with PIR as INPUT

}

void loop() {

  val = digitalRead(inputPin);
  if (val == HIGH) {
    digitalWrite(ledPin, HIGH);
    delay(1000);
    count++;
    if (count == 10) { // if door has been opened for 5 times
      count = 0;
      playNotes();
      Particle.publish("Close the door"); // Send roommate a SMS alerting him about his snacking habits
    }

  }

  digitalWrite(ledPin, LOW);
  delay(1000);
}

void playNotes()
{
    // iterate over the notes of the melody:
    for (int thisNote = 0; thisNote < 8; thisNote++) {

      // to calculate the note duration, take one second
      // divided by the note type.
      //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
      int noteDuration = 1000/noteDurations[thisNote];
      tone(speakerPin, melody[thisNote],noteDuration);

      // to distinguish the notes, set a minimum time between them.
      // the note's duration + 30% seems to work well:
      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes);
      // stop the tone playing:
      noTone(speakerPin);
    }
}
Click to Expand
0
0

Reflection

This project showed me a glimpse into the world of IoT. I thought of a product idea, prototyped it and conducted a usability test all in a week's time. Particle Photon has truly made it easy to rapidly prototype your ideas and connect them to the internet.

0

Summary

Prevent your roommate from eating all your snacks!

x
Share this Project

Found In
Courses

49-713 Designing for the Internet of Things

· 26 members

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


About

My roommate loves to snack. He literally opens the fridge 20 times a day and forgets to close the fridge door 20 times a day. 'Snack Preventer' is an IoT device that reminds you to close the fridge door via a visual cue (LED) and a sound. The device also sends you an alert message reminding you of the number of times you snacked today.

Created

January 26th, 2017