Cat Counter

Made by Logan Uretsky

Found in DIoT 2018 1- Home Hack

Is my cat inside or outside? This connected device will allow my family to feel confident that our indoor/outdoor cat is inside before they close the backyard door.

0

Problem Statement

This home hack is made for my parents, who regularly leave the sliding door open in the kitchen so that our family’s cat can go outside. Our cat goes inside and outside repeatedly, and my parents often face the problem of not knowing whether the cat is inside before they leave the house and close the sliding door. They will often search the whole house for the cat or search the whole backyard in order to find the cat before they close the door.


Goal

My hack will use a switch to turn on the device, a motion detector to detect the cats movement, and an LED to indicate that motion has been detected. My parents will be able to then access the information online to see either "The cat is inside now" or "The cat is outside now" This will let them know if they are able to lock the back door, or if they need to go outside and bring the cat in. This will solve the problem of needing to look inside and outside for the cat, which is time consuming and frustrating

0

Initial Design:

The Initial Design incorporated the PIR Motion Sensor, the LED, and the resistor. The goal of the initial design was to notify the user that motion was detected by enabling the LED. I found that the user (my parents) did not want to constantly have the LED blinking on and off. The backdoor isn't always opened, so there needed to be a switch to turn off the device when not in use.  I addressed this challenge by deciding to incorporate a sliding switch into my Final Design. 

0

Final Design:

In order to prevent the motion sensor from perpetually taking readings, I incorporated an on/off sliding switch pictured below. This would allow the user to control when the device was recording motion and illuminating the LED. The switch would be in the "off" position at night, and when the back door was closed. When the door was opened up, and the cat was allowed to go outside, the switch would be turned to the "on" position and the motion sensor would start taking readings and pushing information to the cloud. This solution met the needs of my parents. 

0

Initial Code:

Additions were made to the original code to  incorporated the on/off switch into the functions of my Cat Counter.

0
int inputPin = D4;              // choose the input pin (for PIR sensor)
int ledPin = D1;                // LED Pin
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int switchPin = D2;             // switch wired to D2

int calibrateTime = 10000;      // calibrate


void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode( switchPin , INPUT_PULLUP ); // sets pin as input
  pinMode(inputPin, INPUT_PULLDOWN );     // declare sensor as input
  pinMode( ledPin , OUTPUT ); // sets pin as output

  Serial.begin( 9600 ); // start the serial monitor
}

void loop()
{
  int switchvalue = digitalRead(switchPin);
  // if the sensor is calåbrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();

  }
  if( calibrated() && switchvalue==HIGH  ){
    // report it out, if the state has changed
    reportTheData();

  }else {
    digitalWrite ( ledPin, LOW);
  }

  Serial.print( "Switch Value is : " );
  Serial.println( switchvalue );
  Serial.print( "PIR value is : " );
  Serial.println( val );
  Serial.print( "PIR State is : " );
  Serial.println( pirState );


  delay( 100 );
}


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

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


  setLED( pirState );

}

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

Final Code:

The Final Code enabled data to be pushed to the Particle Console. This allowed my parents to check whether the cat was inside or outside, by looking on their computer.  New information would be pushed to the cloud every 5 seconds that the "Cat is inside now" or "Cat is outside now"

0
int inputPin = D4;              // choose the input pin (for PIR sensor)
int ledPin = D1;                // LED Pin
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int switchPin = D2;             // switch wired to D2

int calibrateTime = 10000;      // calibrate
int cat_pos = 0;
void setup()
{
  pinMode( ledPin, OUTPUT );
  pinMode( switchPin , INPUT_PULLUP ); // sets pin as input
  pinMode(inputPin, INPUT_PULLDOWN );     // declare sensor as input
  pinMode( ledPin , OUTPUT ); // sets pin as output
  Particle.publish("I sensed","Cat is inside first");
  Serial.begin( 9600 ); // start the serial monitor
}

void loop()
{
  // if the sensor is calåbrated
  if ( calibrated() )
  {
  // get the data from the sensor
    readTheSensor();

  }
  if( calibrated()  ){
    // report it out, if the state has changed
    reportTheData();

  }
  Serial.print( "PIR value is : " );
  Serial.println( val );
  Serial.print( "PIR State is : " );
  Serial.println( pirState );
  Serial.println(millis());

  if (val == HIGH){
    cat_pos = cat_pos + 1;

  }
  if (cat_pos%2 == 1){
    Particle.publish("I sensed","Cat is outside now");
    delay(5000);
  }

  if (cat_pos%2 == 0){
    Particle.publish("I sensed","Cat is inside now");
    delay(5000);
  }
  delay( 500 );
}


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

}

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

void reportTheData() {
  Serial.println( "REPORT THE DATA" );


  setLED( val );

}

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

Circuit Diagram:

**Distance Sensor pictured below in the place of a PIR Motion Sensor 

0

Bill of Parts:

  1. 1x Particle Photon
  2. 1x Breadbord
  3. 1x PIR Motion Sensor
  4. 1x LED
  5. 1x Resistor 330 ohm
  6. 1x  SPDT Slide Switch
  7. 10x Jumper Cables
0

Product Demo Video:

0
Cat Counter
Logan Uretsky - https://youtu.be/KZg3NEwyaE0
0

Particle Console:

0

Next Steps:

  1. For future iterations of the Cat Counter, I would like the LED light to remain illuminated when the cat is outside, and turn off when the Cat comes back inside. This would allow my parents to simply look at the device in order to see if the cat is out, without having to look on the Particle Console, dashboard, or a cellphone.
  2. would also like to incorporate a push notification to their phone or a simple app/dashboard they could check to determine if the cat is inside or outside. How they would get the information would depend on whether they would want to receive a notification, or just want to check the status at their own leisur.
  3. I would like to iterate on this device, so that it could track multiple cats in one household. 

0

Reflection:

Developing the Cat Counter was a very informative process. I learned how to use a simple  PIR motion sensor to accomplish a unique problem for my parents. This was very interesting to me because when I thought about the problem at first, I didn't realize that it would require so few components, yet be able to do something so powerful. I learned that their are so many unique applications for sensors, and that a simple motion sensor could solve so many problems and have such an interesting use case. If I were to do this again, I would think about different types of LEDs and utilizing color in a unique way, rather than just the white LED. I am happy about where I got with this project, because it solves a unique frustration my parents and is a unique idea that I have not seen elsewhere.

x
Share this Project

Courses

49713 Designing for the Internet of Things

· 25 members

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


Focused on
About

Is my cat inside or outside? This connected device will allow my family to feel confident that our indoor/outdoor cat is inside before they close the backyard door.

Created

January 24th, 2018