Who wants to keep going out to the mailbox only to be disappointed? In this tutorial we'll show how you can receive real time notifications on your phone when your products arrive in the mail and add lighting to the inside of your mailbox with Adafruit NeoPixels.

Adafruit Products

Additional Products

  • 12' USB Cable
  • 5 Terminal Screw Headers
  • Stackable Female Headers 10 Pin
  • Magnetic Reed Switch
  • Super Magnets
  • 5V DC SPDT (Single Pole Double Throw) Relay from Digi-Key (Z773-ND) http://www.digikey.com/product-detail/en/0/Z773-ND
  • 2.2K Resistor (for solar charger)
  • 1K Resistor (for photocell)
  • Acrylic Sheet to mount solar panel
  • Heat Shrink Tubing
  • 4x Wood Screws

Follow the Adafruit learning guide to print your circuit board using the following Eagle CAD files.  They are located in the eagle sub directory. Or just grab it from the github repository

git clone https://github.com/shellbit/mailbox

A printed circuit board isnt required but it does make the project a little neater, wiring-wise

Use a coping saw to cut the board to size so it fits inside the small plastic enclosure box.  I placed the board between two thin pieces of scrap wood in a vise to avoid damaging the board while cutting.

NOTE: The board is sitting upside down in this picture.

Solder Flora Pins

Flora is the low powered microcontroller that will be running the code for this project.  Use an exacto knife to cut away 14 male header pins and drop through the mounting holes for the Flora.  Seat the Flora onto the pins to hold in place while you solder the bottom of the pins to the board.  The USB connector on the FLORA should be at the bottom of the board in this picture.  We are not soldering the Flora to the board at this time, just the header pins.  It is easier if you have someone hold the Flora against the circuit board while you solder the bottom pins.

Solder the SPDT Relay

A Single Pole Double Throw Relay is used to eliminate outside noise and provide a true High/Low value to the interrupt pin on the Flora.  When the interrupt pin state changes, Flora will wake up, turn on the XBee end device radio and send a message to a router or coordinator radio.  Flora will also activate a series of NeoPixel lights to illuminate the inside of the mailbox.  Solder the 6 pins on the SPDT Relay to the board now.

Solder the Female Header 10 Pins

This header allows for the XBee radio to be easily seated and removed from the board for reprogramming and upgrading at a later time.

Solder the 5 Terminal Screw Headers

The 5 Terminal Screw Headers will be used to connect the outside wires coming into the box to the circuit board.  If you are facing the inputs to the terminal screw headers, from left to right, the input pins are for Voltage Output, Photocell Pin, NeoPixel Pin, Door Pin, and Ground.

Top View of Board

Solder Flora

Make sure the USB port is at the bottom of the board!

Solder the Flora to the male header pins and use wire cutters to trim away the excess pins.  This is required so the pins to not touch the solar panel charging board.  Also solder the 1K resistor at this time (see photo).  The 1K resistor is used in conjunction with the photocell as a pull down resistor.

Prepare the Solar Charger Stands

Cut away 8 male header pins and double stack the black plastic stands on 4 of the pins.  These 4 pins will be used to position the solar charger board over top the Flora.

Solder the Solar Charger Pins

This is easier to do with a second pair of hands.  Have one person hold the board upside down and hold each pin in place with a pair of needle nose pliers while you solder to the bottom of the board.

Follow the Adafruit learning guide to solder the solar charger.

You need to desolder the 10K surface mount resistor from the THERM pads and solder in place a JST cable with Female port.  I cut one of the JST Battery Extension cables in half and soldered the female end to the solar charger board.  Solder the male end to the 10K Thermistor wire.  Be sure to use heat shrink tubing!  This will allow you to run the thermistor wire into the project box from the outside and easily disconnect when you want to remove the board from the box.  

Also, I recommend solderinng a 2.2K resistor over top of the PROG surface mount resistor for about 950mA of max current draw. This will let you take full advantage of the solar panel!  Use a good amount of solder to solder the solar charger board to the printed circuit board header stands.  You will also want to solder together two JST male wires (red to red, black to black) for connecting the solar charger load female port to the Flora power female port.  The battery port shown here is connected to a rechargeable battery using the second JST Battery Extension Cable.

Drill two holes in the side of the enclosure box to run one wire from the solar panel and another wire from the mailbox, which will contain internal wires for power, ground, the NeoPixel strip, and the door switch.

Use a drill press vise to hold the box in place while you drill.

Drill two holes through the back of the box for mounting to the mailbox post with wood screws.

Next, drill a row of small holes at 1/16" diameter across the bottom of the enclosure lid.  This will help keep moisture out and allow for water to drain if the box happens to leak.

Cut an acrylic sheet to the size of the solar panel, leaving about a half inch lip on the bottom to attach a photocell for measuring brightness outside.  The photocell will allow you to keep the Neopixels off during the daytime to save on battery.  Use an exacto knife and a piece of scrap wood for a straight edge to cut into the acrylic sheet.  Once cut, place the acrylic sheet in between two pieces of wood along the shear and apply downward pressure to break off the measured section.

Measure and drill two center holes for attaching to the mailbox post, four corner holes for attaching the solar panel, one offset side hole for the wire coming out the back of the solar panel, and one center bottom hole for holding the photocell.

Use wood screws to attach the solar panel mounting board and the project enclosure to your mailbox.  I had originally drilled the solar panel mounting holes straight down into the mailbox post, but it is better to drill them at the angle of the mounting sheet so the heads of the screws sit flush with the solar panel board.  I had to make a modification to the mount board by attaching a thin piece of wood to the back of the acrylic sheet so I could counter sink the screws to correct this issue.

I purchased a cheap 12' long USB cable for the wiring of this project.  

We are going to use this cable to make two wires, each containing four wires inside from the USB cable (Red, Black, Green, and White).  The first wire will run from the solar panel to the project box.  

Measure out the length of cable you need to get from the solar panel into the project box and cut, leaving yourself a little extra in case you mess up.  Solder the Black and Red wires from one end of the USB cable to the Black and Red wires on the solar panel.  Use heat shrink tubing to cover up the solder points.  

The remaining Green and White wires should be soldered to the photocell, which will attach to the acrylic sheet.  Strip the wires on the other end of the USB cable and solder the tips.  We will connect this inside the project box later.

We will be cutting a small section off the remaining USB cable to run to the front of the mailbox for the door switch.  Make a cut that is a few inches longer than the depth of the mailbox.  You will only be using 2 of the four wires.  Solder the Green wire and Black wire on one end of the USB cable to individual legs of the reed switch.  A super magnet will be placed on the lid of the mailbox door to activate and deactivate this switch.

Using the second wire bundle, you will need to solder the Black wire to the NeoPixel Ground and splice it to the Black wire from the first wire bundle (see picture).  The White wire should be soldered to the NeoPixel DIN pad and the Red wire should be soldered to the NeoPixel +5V Pad.  The Green wires should also be spliced together.

The easiest way to program an XBee is to use the XCTU software provided by Digi. Check out this guide for how to set up and program XBees

Setup one radio as an End Device with Pin Hibernate Sleep Mode Option and another XBee as a Coordinator with SN=0x10E0 and SP=0x7D0 for a 3 day end device timeout.  The End Device will be placed in the female headers of the circuit board and the Coordinator will connect inside the house to your home network.

 https://www.digi.com/wiki/developer/index.php/XBee_Sleeping_Problems

Download the Arduino code from Github and upload to the Flora board using the Adafruit Arduino IDE.  The file is named mailbox.ino

      git clone https://github.com/shellbit/mailbox
    

Configuration Options

TOTAL_LIGHTS int should be set to the number of Neopixels you are using.

EVENT_DELAY or quite period, is the number of milliseconds to wait before sending a second mailbox open or close event message.  This is set to 10 seconds by default and is used to prevent someone from repeatedly opening and closing your mailbox to spam you with notifications.

LIGHT_ON_MILLIS is the number of milliseconds to leave the NeoPixels on if the mailbox lid stays open.

MAX_UPTIME is the number of milliseconds the board will stay awake before entering sleep mode.  This is set to 10 seconds by default.  Change it if you want the board to stay awake longer or shorter.

Connect the XBee coordinator to a laptop over USB and connect to the radio in Console Mode from XCTU to monitor the incoming packets.  

Connect the Red wire of the USB cable you made to +, the White wire to L (Light), the Green wire to S (Switch), and the Black wire to -.  The P terminal is reserved for the Photocell wire.  

Place a magnet against the switch and power up Flora with either a battery or DC power.  You should see the Green light on the XBee radio blink for 10 seconds then turn off.  Before the XBee and Flora enter sleep mode, Flora will write out a message to the XBee to send to the coordinator to let you know its entering sleep mode.  You will see the Red light on the radio light up when a message is sent or received.  

When you remove the magnet, you should see the NeoPixel strip light up, a message that the Flora and XBee are exiting sleep mode, and that the mailbox lid is open.  You will also see a mailbox closed message when the magnet closes the switch again.

This guide was first published on Jun 23, 2015. It was last updated on Jun 23, 2015.