Mailbox Sensor Email and Alarms

Introduction: Mailbox Sensor Email and Alarms

About: I love home automation. I hate home automation.

This instructable will show you how to make a web-connected mailbox sensor. Besides emailing you when your mailbox is opened, it will also signal a Raspberry Pi sitting in your house to play an audio announcement. There is also a web-accessible Android/iPhone interface for you to check what time mail was delivered, as well as display the battery voltage left on the sensor.

But this could also easily be used as a web-connected security system, one that both plays an audio alarm in your home and emails you when the someone breaks into your house.

Under normal use (a few door openings per day), the battery powered mailbox Arduino should last over a year on a set of 4xAA batteries. The transceiver has a range of over 700 feet through multiple walls, so this should work for most situations.

General Components:

  • One strip board Arduino, circuit optimized for low battery power consumption
  • Strip board components (voltage regulator, capacitor, resistors, etc...), see details later on.
  • Two wireless transceivers (RFM69HW)
  • Two Arduino Uno's with selectable 3.3V/5V switch for the gateways
  • One Raspberry Pi, but could be replaced with your PC/Mac if you don't mind running the computer 24/7

I'll explain how to piece all these parts together and provide all the code needed.

Step 1: Better Video Explanation of How It Works

Take a look at this longer video to understand how the pieces of this system talk to each other. Then, we'll start the first step of making the Mailbox Arduino.

Step 2: Make Mailbox Arduino

Obtain the following parts for the Mailbox Arduino:

  • A blank ATMEGA328P-PU
  • HopeRF's RFM69HW
  • Two position screw terminal for connecting the battery to the strip board
  • Battery voltage divider: two 1MOhm resistors, 0.1uF ceramic capacitor
  • Voltage regulator circuit: two 0.1uF ceramic capacitors (one for input, one for output), one 10uF tantalum capacitor(for output)
  • Oscillator: one 8MHz oscillator, two 22pF capacitors
  • Indicator LED: one LED, one 220 ohm resistor for current limiting
  • One 10k ohm pull up resistor for reset line
  • Reed switch and one 10k ohm pull down resistor
  • A strip board about 3x6 inch
  • 24 pin socket to mount the ATMEGA328 on
  • 4xAA battery box, or 3xAA if your mailbox is really narrow.

Follow the circuit diagram above and solder up the components. You may want to assemble a breadboard prototype to test it out before committing to a soldered strip board, depending on your comfort level. Note that there are two locations where you need to strip the copper off the strip board. Under the LED, and under the reed switch.

Burn the Arduino bootloader on the ATMEGA328P-PU using the standard "Arduino as ISP" bootloader burning instructions from Arduino here. Use the "Pro/Mini 3.3V 8MHz" bootloader.

Step 3: Create the Two Gateway Arduinos

Components Needed:

  • Two Arduino Uno Clones with 3.3V/5V switch
  • One Wiznet 5100 ethernet shield
  • One RFM69HW

In order to receive the wireless packet and communicate the data to the Raspberry Pi, we need to use two other Arduino Uno clones. Buy an Arduino Uno clone that has a 3.3V/5V switch, and only run it at 3.3V. They're available for about $10 on ebay. One Arduino will be designated the "RFM Gateway" and the other is the "Ethernet Gateway". In the picture above, you can see the RFM Gateway Arduino on the left. It has the wireless transceiver mounted on it. On the right is the Ethernet Gateway with the ethernet cable connected. Below the two of them is the Raspberry Pi.

On the RFM Gateway Arduino, wire up the RFM69HW like this:

  1. RFM69HW To Arduino
  2. NSS to Pin 10
  3. MOSI to Pin 11
  4. MISO to Pin 12
  5. SCK to Pin 13
  6. GND to Ground
  7. 3.3V to the 3.3V header
  8. DI00 to Pin 2 (interrupt)

Plug the ethernet shield on the "Ethernet Gateway". Hook together these two gateway Arduinos for I2C:

  1. Ground to Ground
  2. Analog Pin 4 to Analog Pin 4
  3. Analog Pin 5 to Analog Pin 5

Step 4: Download the Three Arduino Sketches

Download the sketches onto the three Arduinos.

To load the sketch on the Mailbox Arduino's ATMEGA328P, you'll need a TTL-USB adapter. Purchase one that as a 3.3V/5V switch if you're going to be working with RFM69HW's more in the future. Alternatively, you can use one of the pre-built Arduino Unos to program the ATMEGA328 following these instructions.

Step 5: Install and Configure Two Programs on Raspberry Pi

Two programs need to be installed on the Raspberry Pi. One is the MQTT broker called "Mosquitto". The other is the program that runs the interface, called OpenHAB.

  1. Install the MQTT broker Mosquitto onto Raspberry Pi:
  2. To install OpenHAB, simply download the Linux files to a directory of your choosing:
  3. Next, there's some configuration needed on OpenHAB. Use the text file attached to this step and copy and paste into the different configuration files indicated.

  4. Place a mp3 file named "aolmail.mp3" in the folder of the OpenHAB installation. This could be any audio file you want played when mailbox is opened.

Step 6: Assemble and Install

You can get creative with how you want to assemble and mount the Mailbox Arduino. Put electrical tape under the strip board to prevent electrical shorts. Put a case around it to protect it from water. I used magnets and velcro to mount the assembly.

  1. Attach a 4 or 3 AA battery box to the strip board using velcro. This allows some flexibility with repositioning.
  2. Super glue magnets to the back of the battery box to attach to mailbox
  3. Mount another magnet on the mailbox door to activate the reed switch. Adjust positioning

Step 7: Install the Mobile App

Install the OpenHAB Android or iPhone app from the app store. Or, you can access the web interface via browser by just going to the IP address of the Raspberry Pi. Of course, you'll need to open up a port on your router to make this accessible from the internet. Have fun! This doesn't have to be for your mailbox. This also works well as a door/window alarm.

Home Technology Contest

First Prize in the
Home Technology Contest

Remote Control Contest

Participated in the
Remote Control Contest

Battery Powered Contest

Participated in the
Battery Powered Contest

Be the First to Share


    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Plywood Contest

      Plywood Contest



    Question 3 years ago on Introduction

    First I find this a great project. I have got the mailbox board and was wondering about ground and also the vcc going to pin 7 and 22 on the 328p. You also said the only cuts on the board is under the led and the reed switch. Help!


    4 years ago

    I love this project and would love to build one. I’m sure technology has changed a great deal in the time since this was published. Any plans to update this instructable with the latest technology? Thanks for posting this project.


    5 years ago

    This is 3 years ago, now ofcourse one would just use an ESP8266 that pumps an MQTT message directly into the LAN.
    Put it to sleep forever, but with the mail detection switch on the RST, will go for years on a battery


    6 years ago

    Why don't you use long-distance NRF24L01+PA+LNA wireless modules 1100meters, sample and more affect


    8 years ago on Introduction

    Although wireless communication is far to my skills, I would prefer some IR detector to check, if something is in the mailbox. Please attach photo of letter to email then :-)


    Reply 6 years ago

    I know this is old, but you never know who reads these.

    A less expensive way might be to use a piezo sensor, Steve. If you have an empty mailbox, the piezo signal would bounce off of the metal more easily than it would off of, say, an envelope. Running some initial tests with a piezo should be easy and cheap. Good luck!


    7 years ago on Introduction

    Hi, would it be possible to simplify the communication here and have the arduino talk directly to the raspberry pi with a transceiver connected? Thanks! (I'm a newbie so feel free to tell me if i'm talking rubbish!)


    7 years ago

    Probably a stupid question: Does it send a signal when a magnetic field is broken or when one is detected?


    Reply 7 years ago on Introduction

    When the switch is closed, which in this case means magnetic field detected. But it doesn't really matter. You position the magnet however you want, and you tell the microcontroller what wakes it up, so any combination is possible. attachInterrupt (1, wake, HIGH);

    Reminds me of the old "AOL" Announcement Chime "You've got Mail!!" XD

    Anyways, nice project :)

    This is a great idea! I used to live on a ranch where our mailbox was like a mile away and this would have been super useful!