Meet Rocky: An IoT Adventure
Meet Rocky: An IoT Adventure
The combination of a new home, a Raspberry Pi, and a lost cat led to an adventure that allowed one family to solve a mystery and meet a new furry friend.
Join the DZone community and get the full member experience.Join For Free
Earlier this year, we moved into our new home, which is just 0.2 miles (or 0.321 km for those outside the USA) from our prior home. I could easily write an article about the unexpected challenges of moving such a short distance, but I am not really sure how I could wrap these aspects into something that is appealing to DZone readers.
The new home is a bit more secluded and has far more trees and landscaping to provide a great deal of curb appeal for not only us, both our neighbors and visitors. Turns out, the number of wildlife living in this area is far greater too. Within our first few days, we noticed a great number of chipmunks and squirrels racing around — which led to the feeling of being part of some Disney movie where the animals live in tandem with humans.
Nicole noticed a cat one afternoon and was worried the feline was homeless. Her giving heart placed a bowl of cat food and water on our side deck for the cat to enjoy. However, after talking to the neighbors, we soon realized that the feline was not homeless — but was "Luna" and she had no desire to eat the food we left out. Still, the food was gone and we quickly realized something else had gotten the food.
Raspberry Pi to the Rescue
I received a Raspberry Pi (thank you DZone Bounty) several months ago and had been looking for a cool project to build. A few weeks after receiving the unit, I used the Raspberry Pi to create an arcade machine with some retro games and attached an old PS3 controller to it. The fun wore off after playing the original Donkey Kong game and a few others - which is no different than my experience playing retro PC video games from years ago. It is fun for a short time period, but really makes you appreciate the advances in video game technology even more.
With the Raspberry Pi idle, I had the thought to use a video camera and place the focus on the food bowl, then capture images of whatever is taking the food as motion is detected. Doing a quick search, I found the following article:
The article guided me through the necessary steps to use OpenCV (Open Source Computer Vision Library) to handle the motion detection between different images captured by the camera and Python to build a script to drive the program.
The focus on the article was to monitor a refrigerator in order to solve the mystery of who was taking adult beverages without permission. To be safe, the article utilized Dropbox in order to store the images - both to conserve space on the Raspberry Pi and provide proof in the event the offender opted to destroy the make-shift surveillance device.
The Modifications I Made
The article was great, but there were a few modifications I wanted to make from the article noted above:
Make sure the Python program was capturing images at 1080p resolution.
When movement occurred, I wanted to upload the frame being processed (which was at 640 x 480 resolution) and also upload a copy of the image - which was in the 1080p resolution.
I added a logger to the Python screen, in the event any unexpected errors happened during processing.
I wanted the Raspberry Pi to automatically start the program on reboot, to allow me to just plug it in and be ready to go.
Of course, I changed some of the text on the screen - updating the verbiage to match my quest.
Preparing for the Big Night
Before I was ready to run the camera all night, I setup two test runs using the Raspberry Pi and camera. The first test positioned the camera from my second-floor office and faced the driveway leading to our garage. I used the camera during day time hours and even kept a keyboard, monitor and mouse connected as well. Here is a test image that I was able to capture of our daughter arriving home:
The second test I performed was when our 10-month old son was sleeping. This time, I wanted to test out the night vision in a completely dark room. This was really cool and the experiment was a success. Well ... until one of the two rubber bands holding the camera to my tripod broke. The images, like the one below, showed us just how often our infant son moves during his bedtime hours:
Oh yeah, Nicole and I continued to set food out each evening ... to make sure our new guest didn't forget about us.
The Big Night
As the sun began to set in our town, I validated there was a 0% chance of precipitation and placed the tripod containing the Raspberry Pi and camera on the side deck. I placed some peanut butter toast and hard-boiled eggs into the same container that we had been using each evening. Here is an image I took from my smartphone:
I plugged the Raspberry Pi into an outlet just inside the doorway and I shut off the lights inside our home. Tired from a long week at work, I went ahead and crashed out.
The Next Morning
When I woke up the next morning, I checked to see if the food was gone. It was.
I then raced to my computer and opened my Drop Box page. There I found hundreds of pictures. I was excited.
Our visitor arrived no more than twenty minutes after I went to bed. The Rocky Cam image highlighted the area with a difference:
The 1080p version was a bit cleaner:
It turns out, our new friend was a racoon and Nicole quickly gave him the name of Rocky. Upon his arrival, Rocky spent about 30 minutes enjoying the peanut butter toast and departed for about an hour. He then returned to enjoy the hard-boiled eggs.
During his visit, he noticed one of our cats (if not more) on the other side of sliding door (near the tripod) and took a few minutes to engage in a stare down:
This lasted for several minutes. Then, an hour after Rocky left, we saw another new guest:
Turns out, the neighbor's cat, Luna, also made an appearance — but only passed by and didn't care at all about the food dish.
When I told people about Rocky being a racoon that we were feeding, we found a similar reaction to those who I would consider modestly older than us — that we better be careful, because those racoons can give you rabies.
I am not sure how leaving food out each night can lead to Nicole or me in need of a rabies shot. However, in the event something unfortunate does happen to us, please make sure the authorities investigating our dilemma have copies of the photos included above.
Have a really great day!
Opinions expressed by DZone contributors are their own.