Calm Tech Dog Monitor
Made by Matthew M ·
Made by Matthew M ·
We are often away from our dogs for long periods of time. Wouldn't it be nice to know your pet is safe and sound without having to constantly check?
Created: January 24th, 2018
My roommate is often away from his dog Fermi for extended periods of time. As a result, he is often worried about his pet’s wellbeing, and is generally curious about what he is doing. While there are countless pet video systems on the market, they require constant vigilance, and the act of opening an app to check a video stream is an interruption to his everyday activities. Ken lacks the ability to passively monitor and feel connected with his dog remotely.
The goal of the project is to prototype an unobtrusive and “Calm” way to monitor what Fermi is doing. His owner should be able to be made aware of Fermi’s status without actively seeking out the information.
Fermi is a Greyhound, a breed known for sleeping throughout the day. As such, Fermi being located on his bed is a fair proxy for ruling out unordinary events that might be of concern to his owner.
The ultimate vision for the project is to detect when Fermi is on his bed and when he is not, and utilize an orb to display his status remotely, with an ambient glow.
For the purposes of this prototype, a sensor will detect whether Fermi is on his bed (or not), and post that status to Twitter.
Next, I created a simple circuit for a toggle switch that powered an LED. The LED would represent system status to the user. (diagram)
The toggle switch also afforded me the opportunity to integrate IFTT with Google Docs, where I had intended to log status and test the logic of comparing previous state vs current state.
I moved the IFTT logic from the LED switch to the push switch. Multiple events with the same target created conflicts within Google Docs, even as unique events with delays. I ultimately used Twitter for logging.
Finally I replaced the push switch for the mat without issue, and the prototype was ready for testing.
int switchState = 0;
int previousSwitchState = 0;
int floorState = 0;
int previousFloorState = 0;
int status = 0;
int ledPin = D1;
int switchPin = D0;
int floorPin = D6;
void setup()
{
pinMode( switchPin , INPUT_PULLUP); // sets pin as input
pinMode( floorPin , INPUT_PULLDOWN);
pinMode( ledPin , OUTPUT ); // sets pin as output
}
void loop()
{
if (status == 1)
{
digitalWrite( ledPin, HIGH);
}
else if (status == 0)
{
digitalWrite( ledPin, LOW);
}
int switchState = digitalRead( switchPin );
floorState = digitalRead( floorPin);
//LIGHT AND SYSTEM STATUS
// set system status flag where 1 is ON, 0 is OFF
//status effects state of LED
if(switchState == HIGH)
{
status = 1;
} else if (switchState == LOW)
{
status = 0;
}
if(previousFloorState == LOW && floorState == HIGH && status == 1 ){
Serial.println("DOWN");
Particle.publish("bed_status", "sleeping");
}
if(previousFloorState == HIGH && floorState == LOW && status == 1 ){
Serial.println("GOT UP");
Particle.publish("active_status", "not sleeping");
}
previousFloorState = floorState;
}
Click to Expand
As a refinement to the existing prototype, I will need to eliminate the noise of rapidly toggling the floor mat on then off, as this likely represents Fermi settling into place, and not a long-term position which the project is concerned with. Setting a time threshold is likely simple, feasible approach.
The next in the larger project is to determine the best method for particle to particle communication either by logging the sleep status into a spreadsheet or that can be read by a second particle, or by using the particle API on both ends of IFTT. It would also be worthwhile to investigate if variable monitoring is a more efficient or responsive solution than publishing events each time the state of the floor switch changes.
The most significant learning from this project was
with regard to the usefulness of using stand-in parts, and testing code on circuits
proven to be working properly. By using a push switch to simulate the floor mat
detection apparatus, I was able to get started before the part arrived, and
focus on producing working code before troubleshooting issues of physicality.
Furthermore, by initially hooking up IFTT to the system status/LED switch, the
process of learning the IFTT platform, however simple, was uninterrupted by
questions of whether the my second circuit has been properly configured.
However, had I followed through on the approach
This project is only accessible by signed in users. Be considerate and think twice before sharing.
A hands-on introductory course exploring the Internet of Things and connected product experiences.
We are often away from our dogs for long periods of time. Wouldn't it be nice to know your pet is safe and sound without having to constantly check?