How to "build a better mousetrap" by adding a wireless camera

By Chee Keat “CK” Fong, R&D Software Engineer, HP Houston

Editor’s Preamble (or why we have a blog post about rats)

Some of the greatest duels ever fought, filmed, or fictionalized pit Man against Nature.

In Moby Dick, Captain Ahab pursued his great white whale with extreme prejudice. In Jaws, Matt Hooper, captain of a too-small boat, faced off against a great white shark. In The Birds, Hitchcock brought down terror from the skies. In Game of Thrones, the Lannisters' claim to the Iron Throne was incinerated by a fire-breathing dragon.

In real life, HP R&D software engineer Chee Keat “C.K.” Fong is engaged in a less dramatic but surely more ancient battle of wits and wills – Man vs. Rodent.

By day, C.K. spends his days in the bright, modern workspace of HP’s new Springwoods Campus north of Houston, Texas. The campus is surrounded by trees full of wildlife and Texas-sized bugs, but the denizens of the southern woodlands have respected the separation suggested by walls and windows. But when C.K. returns home, he has on several occasions discovered that he and his family are victims of a home invasion. Below is C.K.’s account of how he used a wireless web cam, Gmail, and a browser to, as they say, “build a better mousetrap.” C.K.’s ingenuity shows that reinventing is as much about combining technologies as it is about replacing existing solutions.

"I knew I had a problem when..."

I first discovered that I had a problem with rats in my attic when my uninvited guests started leaving little "presents" behind on the attic floor.

To deal with this, I placed rat traps in the attic. When my family noticed flies mysteriously appearing inside our home, and I detected a foul aroma permeating the area by the attic’s trap door, I realized that an unattended trap in a hot Texas attic was not a good idea. After retrieving and disposing of a long dead and disgusting rodent, I resolved to find a better way.

My challenge was to detect that a trap had been sprung as quickly as possible. Since my attic is a pain to access, inspecting the trap every day was out of the question.

Here's how I applied a WiFi night vision IP camera, web browser, and a Gmail account to win the upper hand and save my sense of smell.

Bill of Materials

  1. Wireless security camera
    Any security camera that supports motion detection should work. Ideally, the camera should also have a night vision feature. This usually means that the camera has infra-red LEDs that illuminate in the dark and allow the camera to see in little or no ambient light. I use an old Foscam VGA wireless IP camera. It connects using WiFi and needs just a single cable for power. While viewing the camera’s output on a browser, I can remotely pan the camera left-and-right, up-and-down.
  2. Rat trap and bait of your choice
    I used a traditional spring-tensioned trap, baited with cheese and peanut butter. This IP camera setup will work with a humane trap too. In fact, it would be inhumane to set up a live trap unattended for days or weeks without some kind of routine monitoring.

Setting up the wireless security camera

My security camera can send an email when the camera detects motion. The trickiest part is just setting all this up. The instructions below are for my camera, but you should be able to find similar settings for yours.

First, I had to set up an email account dedicated just to the rat cam. With the Foscam, I need to log in to the camera first using a browser. Then, I select Device Management followed by Mail Service Settings.


The camera typically sends email using the SMTP service. For Gmail, you can use the following settings:

  • Sender: <Your gmail address>
  • Receiver: <The email address you want emails sent to>
  • SMTP Server:
  • SMTP Port: 587
  • Transport Layer Security: STARTTLS
  • Need Authentication: Yes
  • SMTP User: <Your gmail account, without the ''>
  • SMTP Password: <Your gmail account password>


Google disables SMTP by default. To enable it, visit: and turn on access for Less secure apps.

Security Tip:
Security cameras are often vulnerable to hacking. It is a good idea to keep your security camera's firmware up-to-date and set up a dedicated Gmail account for this purpose, with credentials that are different from your regular Gmail account.

Next, we would need to enable the motion sensing part of the camera. For my Foscam, I selected Device Management followed by Alarm Service Settings. Here, I check Motion Detection Alarmed and Send Mail on Alarm. There is usually also a motion detection sensitivity setting that you can tweak.


Finally, it's time to put it to the test - set up the rat trap and point the camera at it. As you are moving the camera around to set it up, you should start getting emails. If not, check your camera settings.


Over a couple of years, I have been able to catch and promptly dispose of half-a-dozen Texas-sized rats, keeping my family safe, protecting my home’s value, and preserving my peace of mind.

With the camera, I was also able to observe one very smart rat that twice swatted the side of the trap to set it off before picking off the cheese. However, his third time was not a charm.

There were times when the camera failed, such as when a power failure caused the camera to automatically pan away to a default position, so it still helps to check on the camera periodically; this can usually be done remotely.

Reinvention by combination

One of the oldest axioms about innovation states, "Build a better mousetrap, and the world will beat a path to your door." Maybe the thing that has been missing all this time is just knowing when you've caught one.

:) C.K. Fong

Chee Keat “C.K.” Fong is a Principal Tech Lead on HP’s Personal Systems team at the new HP campus near Houston, Texas. A graduate of Monash University in Australia, he has been cranking out code for more than three decades, programming smartphones, PDAs, and computers. (For our millennial readers, “PDAs” were Personal Digital Assistants – progenitors to the smartphone in your pocket.) C.K. started programming in Applesoft BASIC, then learned C/C++ and Pascal, and now codes in C#. In his spare time he works on automating his home and learning new skills, and likes to play with cool gadgets and have fun with technology.

Author : fongck

This was fun to read and a great application of technology. Maybe I will do the same to find out what animal is rattling my front gate early in the morning!