mailbox sensor

Mailbox Sensor Email and Alarmsmailbox sensor here!
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.

wireless mailbox sensor on the site!
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

Make Mailbox Arduino
strip_boardP1070987.JPG
bread board and strip board P1070913.JPG
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 3×6 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

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:

RFM69HW To Arduino
NSS to Pin 10
MOSI to Pin 11
MISO to Pin 12
SCK to Pin 13
GND to Ground
3.3V to the 3.3V header
DI00 to Pin 2 (interrupt)
Plug the ethernet shield on the «Ethernet Gateway». Hook together these two gateway Arduinos for I2C:

Ground to Ground
Analog Pin 4 to Analog Pin 4
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.

Mailbox.inoMailbox.inoDownload
RFM_Gateway.inoRFM_Gateway.inoDownload
Ethernet_Gateway.inoEthernet_Gateway.inoDownload
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.

Install the MQTT broker Mosquitto onto Raspberry Pi:
http://alexander-rudde.com/2014/02/install-mosquitto-mqtt-broker-on-raspberry-pi-running-arch-linux/
To install OpenHAB, simply download the Linux files to a directory of your choosing:
http://www.openhab.org/downloads.html
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.

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.

Welcome to http://mailboxsensor.com!