Bothered by mice living in our attic, we have set up simple mousetraps and caught multiple mice every winter. This has spawned two problems based on mousetraps not being checked systematically or frequently:
- In some cases a mouse has been caught and left for weeks or even months unnoticed. This is a quite undesired discovery when finally checking.
- In other cases a mouse has successfully eaten the bait without having been caught. This has (also) left the mousetrap out of function for longer periods.
To accommodate both problems and optimize the “mousetrap operational uptime” I wanted/needed a connected mousetrap. I researched online, but was not able to find any attractive solutions. After complaining about this at a Christmas party, a friend of mine, Thomas Jørgensen, came to the rescue with a custom-made hardware solution.
Hardware and configuration
It is based on a microcontroller connected to a HAT on a Raspberry Pi Zero WH which acts as a gateway for this custom long-range RF communication:
The sensor will register any movement. So I just let it touch my old-fashioned mousetrap, and when the trap is moving, the sensor will be triggered and send a small packet to the Raspberry Pi Zero WH.
The Pi will listen to serial communication with a small Python script and receive a small JSON payload from the microcontroller:
{
"sensortype": "mousetrap",
"messageid": "10",
"guid": "0x00000001",
"seq": "27",
"status": "0x01",
"mousecount": "134",
"batteryvoltage": "304",
"temperature": "20",
"rssi": "-57",
"snr": "11",
"freq": "868900",
"freq_error": "-1246",
"sf": "10",
"bw": "125"
}
The script will parse this and use MQTT to inform openHAB about any state changes for mousetrap triggered, temperature and battery voltage (converted to approximate level in percent). Every seven hours a payload will be sent even if sensor wasn’t triggered. This is quite battery-optimized and also makes it possible to monitor if it’s operating correctly, temperature and remaining battery life.
Notifications
Rules implemented in openHAB makes sure I get notifications when:
- The mousetrap has been triggered (on cellphone and TV).
- On cellphone a picture will be included (from a Hikvision surveillance camera).
- It has been more than sevens hours since last payload was received.
- When payload has been received again after previously missing.
- When battery is low.
A notification could look like this:
Power consumption
The Raspberry Pi Zero WH with HAT uses ~0.6 W in this configuration. It’s connected through Wi-Fi, not Ethernet.
Statistics
I started using this setup in October 2020. Since then caught 3-4 mice and quickly reloaded traps at least as many times without a successful hit. The last part is important as this increases the chance of actually catching the small rodents when traps are always operational and loaded with bait.