Snail Mail Alert


Introduction: Snail Mail Alert

I have wanted to build a device for my Snail Mail USPS Box to alert me when my box was opened. Good for security, but mostly because my box is 150 ft. from the door and I want to avoid unnecessary trips or stops at the box.

I tried to use a hacked Amazon Dash Button as described in several places on the web, but never could get consistent results, probably because of limitations of my wifi router.

Recently I found the Instructables on line Internet of Things Class. On taking the class I realized I could use what I learned to make my Snail Mail Alert device.

It worked! Opening the box, caused the device to send a text message to my smart phone. But there was a serious problem. Battery life was unacceptable. So first thing, I changed the code to read an analog input from a voltage divider and send that as the data in the text message so I could track it.

I went ahead and bought a solar panel and charge controller from Adafruit to complement the Feather Huzzah ESP8266, but I still did not feel that the 3.7v LIPO battery would last long enough through many days of cloudy weather. I included the temp sensor option on the charge controller since it would be in a black mailbox.

Searching the net, I found the idea to use a low power scheme based on the ESP.deepSleep() function. It seemed that the Huzzah used very little current in deep sleep which was fine as I only needed it to run when the box door was opened.

Instead of the normal setup() / loop() structure of the usual Arduino program, all the work is done in setup(), then deepSleep() is called. The loop() is never started and the program sleeps till a LOW on the RST pin triggers a restart that executes setup() again. And repeat every time the RST is pulled LOW by a magnetic reed switch in the mail box. The setup() code connects to wifi, reads the battery voltage and sends the message to the Adafruit IO feed, then sleeps till the next reset.

Good luck if you try to make this, I've no doubt left out some details and assume some level of experience. I'll try to field any questions, comments or suggestions.

Step 1: Materials and Prototyping

  • Adafruit Feather Huzzah ESP8266 board in the configuration of your choice:

    assembled with regular headers

  • USB power supply (optional)

  • 3.7v Lipoly battery

  • USB / DC / Solar Lithium Ion/Polymer charger - v2

  • Medium 6V 2W Solar panel - 2.0 Watt

  • 3.5 / 1.3mm or 3.8 / 1.1mm to 5.5 / 2.1mm DC Jack Adapter Cable

  • 47K and 10K Resistor (for voltage divider)

  • 1 x 1MΩ resistor (optional)

  • 1 x 1µF capacitor (optional)

  • Magnetic Reed Switch
  • Plastic project box

I used a push button to simulate the door switch while prototyping.

Step 2: Instalation in the Mailbox

Put it all in the box and done.

Step 3: And It Works!

IFTTT Applet

Code: take the class if you need help with what this is.


// visit if you need to create an account,

// or if you need your Adafruit IO key.

/************************ Adafruit IO Configuration ***********************/

#define IO_USERNAME "you2adafruit"

#define IO_KEY "alongstringofcharactersthatadafruitwillgiveyou"

/****************** WIFI Configuration***********************/

#define WIFI_SSID "yourroutername"

#define WIFI_PASS "yourpassword"

#include "AdafruitIO_WiFi.h"



// Instructables Internet of Things Class sample code

// Circuit Triggers Internet Action

// A reset is triggered and battery voltage stored in a feed

// An LED is used as confirmation feedback


/ Modified by Becky Stern 2017

// based on the Adafruit IO Digital Input Example

// Tutorial Link:


/ Adafruit invests time and resources providing this open source code.

// Please support Adafruit and open source hardware by purchasing

// products from Adafruit!


/ Written by Todd Treece for Adafruit Industries

// Copyright (c) 2016 Adafruit Industries

// Licensed under the MIT license.


/ All text above must be included in any redistribution.


/ Adapted by Tom Phillips 2018

// Changed to execute code formerly in loop()

// Sends Battery voltage to Adafruit IO to indicate

// execution then go to deep Sleep.

// On LOW to RST pin, program restarts to send voltage message again.

#include "config.h"

/************************ Main Program Starts Here ************************/

#include "ESP8266WiFi.h"
#include "AdafruitIO.h"

#include "Adafruit_MQTT.h"

#include "ArduinoHttpClient.h"

#define LED_PIN 13

// battery voltage

float battVolts = 0.0;

void setup() {

//set up the 'command' feed

AdafruitIO_Feed *command = io.feed("command");

// start the serial connection



// flash the LED


digitalWrite(LED_PIN, HIGH);


digitalWrite(LED_PIN, LOW);

// connect to

Serial.print("Connecting to Adafruit IO ");


// wait for a connection

while(io.status() < AIO_CONNECTED) {




// we are connected



//; is required for all sketches.

// it should always be present at the top of your loop

// or in this case, in setup()

// function. it keeps the client connected to

//, and processes any incoming data.;

// borrowed some of the math from:


// get that voltage from the voltage divider

int rawLevel = analogRead(A0);

// convert battery level to percent

int level = map(rawLevel, 500, 609, 0, 100);

// used my ohmmeter to set these values. 9820 for the 10K and 49800 for the parallel 100Ks I used

battVolts = (float)rawLevel / 1000 / (9820. / (49800 + 9820));

// round to 2 decimal places

battVolts += 0.05;

battVolts = float(int(battVolts * 100)) / 100;

// save the battVolts value to the 'command' feed on adafruit io

Serial.print("sending battery volts -> ");



//Go to sleep and stay there till RST goes LOW



void loop(){} // never get here.



    • Oil Contest

      Oil Contest
    • Casting Contest

      Casting Contest
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.




    Very practical and nice idea!

    Excellent idea, and nicely done!