Ever since I put a mailbox out on my front gate, I have to check it manually to see if the postman has delivered any mail. That involves getting out of my car on the way in or out, or (ugh) walking all the way out to the post box! So, I’ve now installed a Raspberry Pi by the post box to send a text whenever something is put in the post box!
It’ s very simple setup, a switch is attached to a GPIO pin and GND on the Raspberry Pi, and whenever the switch is activated, it triggers an event which causes a Text to be sent to my phone. So now I only need to open the post box when there’s actually something in it.
The hardware consists of a long-lever switch, which is connected into the GPIO pin 23 and GND of a Raspberry Pi Zero. There’s 12V available on the same pillar where I mounted the waterproof box, so I used a DC-DC converter with a 5V USB output to power the Pi. Because the box is about 40 metres to the house, I used a pigtail and external antenna to improve WiFi connectivity.
I’m getting excellent connectivity:
wlan0 IEEE 802.11 ESSID:"ACCESS_POINT" Mode:Managed Frequency:2.462 GHz Access Point: AA:BB:CC:DD Bit Rate=54 Mb/s Tx-Power=31 dBm Link Quality=51/70 Signal level=-59 dBm
I had trouble thinking how to activate the switch, because of the type of post box. It does not have a single flap, but several individual flaps, making it difficult to cover with one switch. It’s supposed to be some kind of anti-theft mechanism, but I don’t see how. Anyway, that “anti-theft” mechanism also lets in a lot of water into the post box that claimed to be waterproof, so I had to make a rains shield. I did this by bending an acrylic sheet along with a laser-etched “POST” logo. This cover is what I’m using to activate the switch, as it’s heavy enough to switch the long-lever switch, and must be lifted up out of the way in order to put mail in the post box.
I made a crude mounting for the switch with some bits of plastic and hot glue to hold them in place. I doubt it’ll survive the sun, at which stage I might replace the hot glue with epoxy. Anyway, it works for the moment.
I had some old waterproof boxes in witch I could house the Raspberry Pi. I usually leave small holes in the bottom to let any moisture escape, but that usually allows the boxes to become home to spiders, not a big deal really. 🙂
The antenna is sticking out the bottom of the box, sealed with a layer of electrical tape, followed by a layer of mastic tape (3M Scotchfil Insulation Putty), then a final layer of electrical tape. Each layer overlaps the previous. Not sure I needed this, to be honest.
Once it was all in place, I gave it a test. I got my daughter ready capture the first ever text on video, and I said to her “I’m going to do this”, and lifted the rain cover, causing the first SMS to be sent to my phone (without the video rolling, of course). So I didn’t actually get the very first text, I got the second and third. 🙂
After I did the video, I re-configured the script to wait one hour before allowing another text to be sent.
So now to the code. It uses an SMS gateway called Sinch, which I use for a few other purposes around the house already, including notifying me when the home heating oil is running low.
I have a script running on the Raspberry Pi Zero that waits for a GPIO event and calls a function to send and SMS. It’s only a couple of dozen lines, and I’ve made it available on GitHub, so you can have a look.
So that’s it! An interesting Saturday afternoon’s work. And now that there’s network connectivity right beside my gate controller, I plan on doing a few interesting things there as well with the same Raspberry Pi Zero!
Thank you for sharing this great thing. It will be very helpful.