Introduction: Mailbox Notifier
If your mailbox is far away it might be nice to know if the mail actually arrived before walking there.
In this project i will show you how to build a sender device which will be placed in the mailbox which will send a signal to the receiver device located in your house which will light up when the mail arrives. The user resets the receiver by touching the metal button on the front (turns lights off). The remote device has a very long battery life (years).
Before you start/buy anything
- You should have good understanding of electrical components and programming. If you're in over you head it might work out anyway if you're lucky, but if you encounter any problems it will be hard for you to do relevant problem solving if you lack understanding of how the components work.
- This project requires common electrical tools (multimeter, cables, serial programmer, soldering iron etc..)
- Please read the guide & code thoroughly first to see if you understand everything and feel up for the task.
Step 1: How It Works
Before we get into the details I'd like to first lay out the basics of the project to make it easier to follow.
Outline- Mailbox device
The device runs on 3 AA batteries in series. MCU is a attiny85 and transceiver is a 433 MHz HC-12. On the first run both devices will ping each other to confirm connection, after that the device goes in power-down-mode and is awoken by a interrupt when the mailbox is opened. The MCU then turns on a NPN transistor to power up the transceiver which sends a signal back to the receiver unit and then goes back to sleep. Turning off all components when not in use gives very low power consumption (1µA). With quality lithium batteries the batteries should last for 5-10 years (without realistic deterioration about 300 years) .
Outline- Receiver device
The device is powered by USB connected to the mains, therefor this device never sleeps. It has the same transceiver and MCU as the mailbox device. It constantly listens for signals from the mailbox unit. To let the user know mail has arrived it blinks a color pattern with leds. User can interact with the device using a metal touch button.
Step 2: BOM & $
- 2 pcs HC-12 transceiver
- 2 pcs Attiny-85 + 2 DIP sockets (you will most likely regret it you decide to yolo without one) :D
- 150 Ohm resistor, 100K Ohm resistor
- 2 pcs 1000μF electrolytic caps
- NPN transistor, i use (BC337-25)
- Battery pack + batteries (coin cell will work fine and reduce the overall package size with 500% vs AA).
- Usb port for circuit board or usb cable
- Sensor for mailbox, i use a reed switch which activates when a magnet passes.
- NeoPixel Ring 16
- Aluminium button
- Cases/boxes containing the devices. A solution that i would recommend if you don't have access to a 3d printer is to buy something off the shelf and use. My initial plan for the receiver was to buy a glass sphere and light it from below (but I couldn't find one in my city)
- Micro switch or reed switch. Any suitable switch that triggers when the mailbox is opened.
- Depending on range and placement you might want to consider smaller antennas.
The total cost of the project should be around 20 USD.
Work time should be around 3-8 hours depending on bad luck and skill.
Step 3: Getting Started
We'll start with the attiny. My code is written for the arduino IDE. This makes programming the attiny much faster. My code contains a lot of comments so you should be able to follow it.
Start by burning the bootloader, connect a LED and upload the blink sketch to confirm its working. I generally recommend getting some sort of feedback on every step you do during the process. If you don't and it doesn't work when everything is assembled it could be cause by 50 different things.
There's hundreds of guides written about how to use these so I rather not write another one, especially when this guy shows it thoroughly.
This little bugger is also pretty well documented. If you want to reach max distance you have to set it to FU-4 mode.
Check out this guys great guide on the HC-12 and how to set it to FU-4 mode. A good way to make sure they work before continuing is to complete his push button tutorial. If you encounter any problems later down the road at least you'll know the transceivers and attinys are working together. One more thing; the max range is 1.8 km theoretically, in line of sight. I suggest you test the transmitters range early in the project to make sure they are strong enough as the range might be reduced to < 100 m if used in urban environments.
Step 4: Prototype
Before we start to solder stuff together we want to make sure everything is working as it should.
Upload the code to attinys. A good tip is to put a piece of tape on the sender device to keep track of it.
Connect a battery or a PSU to power the circuit (3.3-5.3 V), each transceiver peaks at 100 mA when sending so a bit steep for an arduino uno.
If you decide to use 3 AA batteries as i do, make sure they don't exceed 5.3 V when they're fully charged!
Connect according to schematic above. The mysterious capacitor switch will be explained in the next step.
Step 5: The Switches
The switch is simply an aluminum button with a drilled hole and a cable soldered to it.We will measure capacitance with it and use the readings as a switch.
The second switch is the reed switch. This will pull a pin on the sender unit to low, thereby waking up the the sender and to transmit the signal. The switch will close when introduced to a magnetic field. So we glue a neodyne magnet to the mailbox "door" and when the magnet passes the reed switch the circuit closes.
Step 6: Testing
It's now time to test the circuit!
I designed and ordered 10 general boards for attiny and HC-12 as I have 2-3 projects with these components and will need to make at least 8 boards. These are 2 layer boards and cost me only 10 dollar + 10 dollar shipping and saves a lot of time. I really recommend http://www.pcbway.com/
When both units are powered on for the first time:
Sender device will start to listen. Receiver will do nothing but blink until user touches the button, then it'll send "22" to the sender which will respond will "33". Sender will now go to sleep and receiver will stop blinking.
When the sender wakes up from an interrupt it will send "55" and goes back to sleep. When receiver receives "55" it will start blinking blue and will continue to do so until user touches button.
Consider these steps when testing! Since the device only draws 1 uA, the 1000 uF cap will sustain the sender device for a long time. This means removing the power source won't reset the device. The best way is to remove the power source and then trigger the alarm (pin2->GND). This will turn on the transceiver and attiny draining all the energy in the cap. Adding a reset switch might be a good idea.
If you encounter problems you can use an arduino uno to eavesdrop on the tinys, just use the Software serial example sketch. I also use a pocket usb oscilloscope (about 120 dollar) for error checking. Initially i had a problem with receiving data (faulty pin in protoboard). In the above image you can see the sent data. I just send a "1" which translates to "00110001" in binary (in unicode). Binary is read from right-to-left and the serial line is pulled high when idle. When the transmission begins it goes low first and then start sending. Thanks to this info I knew the data format and baudrate were correct and could start searching for errors elsewhere.
Step 7: The Cases
If you don't have access to a 3d printer you can use about anything for your cases. If your mailbox is made of metal you most likely need to place the sender device on the outside of the box, hence you need a splash-proof case.
If you want to use my cases you can download them here and print. The only place where a "support" is needed is for the top part of the receiver. I print at high speed so I get a lot of "hairs" on my inside and the outside is quite rough, but that doesn't really matter as I will sand it and paint it later anyway.
I used a piece of 50x50x3 mm acrylic for the "window".
Now that the cases are done the first step is the double check that everything fits. When 3d printing parts with a tight fit it's smart to slice out that specific section from part in cad, print it and test the fit. This way you don't end up with a bad fit after printing a 8 h object.
Step 8: Sanding and Painting
The main rule when painting is you'll get the finish you deserve. Spend a lot of effort on the ground work and your surface finish might look good, spend little effort on the groundwork and your finish will never look good.
- Now i will continue with the initial sanding, with 300 grit paper i just even out the worst parts. I exclude the interior of the parts as this won't be visible.
- Then I cover them in 2-component filler, I let it harden for 12 hours. For the initial sanding I use a machine with 180 grit and very carefully remove the roughest parts and the bulk of the filler. Use mask + gloves as this stuff is not healthy!
- When this step is done I water sand with 300 grit again until they look fairly perfect. Then I apply the base coat/primer to the part. If you don't need/want to use the filler and want to paint PLA parts, make sure to use a primer for plastic before painting!
Layers should be really thin. A classic mistake is to apply a too heavy coat, wait 15 min until it's dry to touch and add some more layers. When you're done and the part is dry to touch you'll notice a push with the nail on the surface will leave a mark.
Why this is happening: The first paint layer has only dried on the surface, not all the way through. If you at this time add another layer it will work as moisture barrier preventing the inner layer to dry. Some paints also needs to harden.
So in conclusion; thin layers and a lot of dry time between layers to be sure. (personally I've never used a good water based spay)
Okay lets continue!
- After the base coat i add two layers of color. When they have dried I use 600 grit to gently water sand any last imperfections then I apply the final coat.
- If you want the surface to be perfect you can use a 2000 grit paper to super light water sand after the final layer.
Step 9: The Result
On the second picture you can see I also made my own rubber gasket to protect the unit from moisture, this is necessary only if you intend to place the unit on the outside of the mailbox.
If you managed to get this far, good job!!
If you have any problems with range, try changing the function sendSignal(22,1,80);
to sendSignal(22,5,1500); for instance, this will send message "22" 5 times with 1500 ms delay. Don't forget to increase the time before sender goes to sleep (the transmitter takes about 1 sec to send each message in this mode)
If you still have problems, try using an external antenna. They are fairly cheap and easy to attach.
rayxoxo1 made it!