“I love checking on mousetraps,” said no one ever - Hackster.io

2022-10-22 21:02:26 By : Ms. Cherry Chan

Add the following snippet to your HTML:

Get an SMS alert when there's a mouse in your live trap as we build a smarter mousetrap for the Internet of Things.

Read up about this project on

Get an SMS alert when there's a mouse in your live trap as we build a smarter mousetrap for the Internet of Things.

From chewing wires and damaging merchandise to spreading disease, rodents cost the economy over $20 billion every year: about the same as 200 Hollywood movies. Most of the money is spent on pest control so it's still worth building a better mouse trap. After setting traps, I don’t think anybody loves getting down into all those dark corners to check on whether they’ve caught anything. Here at Blues Wireless, an IoT startup dedicated to making wireless IoT simple, I decided to try my hand at making an internet-connected mousetrap. In this article, I'll show you how to modify a humane mousetrap so it will alert you with an SMS when you've caught a mouse. No need to waste time with random guessing and checking of traps any longer.

To provide the electronics I used a LoRa-based Blues Wireless Sparrow Development Kit which, helpfully, has a passive infrared (PIR) motion sensor on each sensor node. To allow the PIR sensor to see into the trap, I cut a 1/2” hole in the lid of the Victor M333 Mousetrap. To locate the circuit board securely, I cut four 1/8” holes to receive M3-threaded nylon standoffs.

Beautifully, the open source reference firmware that ships with the Sparrow kit already has everything you need to detect motion in a mousetrap like this with relatively few false positives. If you're doing your own project, use the blues developer site to find a quickstart, datasheet, and in-depth guides for adding new sensors ( applications) to the firmware.

When the Sparrow sensor detects motion, it creates a message (or adds a note in Blues parlance) and sends it over the LoRa radio protocol to the Sparrow gateway. See the addNote() function if you're curious.

The Sparrow gateway, thanks to the onboard Notecard, forwards the message through Wi-Fi to my home router and then up to the secure message routing service at Notehub.io.

One of the great things about the Notecard is it knows how to send data to a secure cloud service, Notehub.io, out of the box. Notehub is a hosted service designed to accept, authenticate, filter, transform, and forward messages from Notecards like the one in the Sparrow gateway. As an aside: if you don't need the complexity of LoRa on your project, you can easily connect a Notecard (cellular or Wi-Fi) right to your project.

If you’re following along and want to build this project yourself, you’ll need to sign up for a free account on Notehub.io, and create a new project.

To ensure data flows from your Sparrow Gateway to your Notehub Project, configure the Notecard according to the Sparrow quickstart. A maximum of one message will be sent every 15 minutes. Thus, I know one message might be from a kid kicking the trap but many messages (one each 15 minutes) means I’ve caught a mouse.

Notehub doesn’t have native SMS alerts yet, but it does allow you to route messages to any other cloud services or HTTPS API endpoint that your heart desires. I used Twilio, an inexpensive SMS service, to send message to my phone when there is motion in the trap.

To correctly format the request for the Twilio HTTP API I followed the Blues Wireless Twilio SMS Guide and modified the JSONata expression to tell me which mousetrap (Garage, Basement, etc.) saw motion based on the unique ID of the Sparrow sensor node I affixed to each trap.

[ JSONata GitHub Gist of the finished code]

With all the pieces in place, as a test I shook the trap (to shake the pivoting ramp under the PIR sensor). I saw the event on Notehub.io but didn’t see the text message.

After a bit of debugging of my JSONata syntax with the help of the dev.blues.io JSONata tutorial I got it all working swimmingly.

In just a few hours, I was able to make a connected mousetrap solution that communicates anywhere on my property using LoRa thanks to Sparrow. Thanks to LoRa’s excellent signal propagation, traps can even be put in my detached garage, made of concrete block, where Wi-Fi doesn’t reach. As a bonus, if I ever want to move my mousetraps to a property where I don’t have internet access (like a storage location on the other side of town, or a grain silo on the other side of the country) I can easily swap in a cellular Notecard (with 10 years of data included) for about $60.

If you try out this project or have another one you’re working on, we’d love to give you a hand on the Blues Wireless Community Forum.

Hackster.io, an Avnet Community © 2022