Skip to content

Rom3oDelta7/MailNotifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MailNotifier

Hardware and software solution to be notified when your mail arrives

Apple Watch notification

This is a simple system that will notify you when your mailbox has been delivered. You get a notification for the first opening (mail delivered) and the second (mail collected). These notifications will be sent to your phone using both Blynk and SMS text. If you have an Apple Watch, the notification will be displayed on the watch as well (see picture above). The Blynk dashboard provides more information and options, including the date and time the mail was delivered, what the operating hours are, and status LEDs.

Since the wiring was already in place for my home I designed this with a wired connection to my mailbox using a standard magnetic reed switch such as that found in security systems. Any normally closed switch can be used to sense when the mailbox is open. If your installation requires a normally open switch instead, there is a single define in the code that allows you to change the sense.

See more about this projects on [hackster.io].

Hardware

board image

The hardware is quite simple. A WeMOS D1 R2 Mini (ESP8266) is used as the controller. There are just 3 connections:

  1. the reed switch (which should be normally closed (e.g. magnet is engaged)), and
  2. a status LED
  3. 5V DV power

The system requires a 5V 1A DC power supply.

Earlier versions of this system suffered from EMI (electromagnetic interference) when lightning stuck nearby (a common occurrence during the summer monsoons) due in part to a long wire out to the mailbox acting as an antenna. In Rev B hardware (and Rev 2 software), this issue is handled sensing the switch differently to distinguish an open event from EMI. Moreover, the lightning-caused high-voltage EMI over time caused the input port to go deaf requiring replacement of the MCU. Rev B hardware insulates the ESP8266 input port from the external line with a diode and a MOSFET; these parts have much higher voltage tolerances are easier and cheaper to replace than the ESP8266 MCU module.

PCBs may be ordered from PCBs.io at https://PCBs.io/share/49aNb.

User Interface

The user interface is shown below:

ready state

open notification

after mail delivered

  • The "READY" LED (green) indicates that the mailbox is currently closed. Note that the ready light will not be on outside operating hours (see below).
  • The "OPENED" LED (red) indicates that the mailbox has been opened.
  • The "CLLCTD" LED (blue) indicates that the mail has been collected. This is a heuristic: it is activated if the mailbox is opened again after 10 minutes.
  • "DATE" and "TIME" indicate the date (YYYY.MM.DD) and time (24 hr) the mailbox was first opened. If the mailbox is opened multiple times, the date & time do not change; you must reset the system (see below) to clear the date & time and reset the indicators.
  • The "STOP/START" field is used to set operating hours. The default is 1100 to 2000 hours.
  • "IGNORED" indicates how many times the mailbox was opened outside operating hours.
  • The "RESET" button resets the LEDs and the date & time displays. Note that the system will reset itself automatically at midnight each day.
  • The "REBOOT" slider is used to reboot the system. To reboot, slide the switch all the way to the right. You have 5 seconds to change your mind and slide it back to the left. The "READY" LED will extinguish, a message about canceling the reboot will appear in the DATE and TIME displays, and the system will reboot after a 5 second delay. Note that this mechanism can also be used to ensure the end-to-end system is running: if the reboot message comes up this indicates the system is active - just quickly slide the switch back to the left.

Note that all of the built-in delays and timing heuristics can be easily personalized by changing the C++ preprocessor defines in the sketch.

Firmware

The C++ code uses the [Blynk] service. You must first download the Blynk app for your smartphone (iOS or Android) and sign up for the service. You can then download this app from within Blynk using the QR code in the "Blynk" folder.

Blynk mail notifier app QR code

See the [Blynk getting started guide].

The code uses the [Blynk Library], my [NTP (Network Time Protocol) clock library], and Paul Stoffregen's [Time Library]. Be sure to change the "auth", "SSID", and "password" strings and set the email address string to the [address your carrier uses to send an SMS to your phone] in the file "locals.h". In the sketch file, set the parameter to the

NTP_UTC_Timezone()

function to your local timezone. See WorldTimezones.h in the [NTP (Network Time Protocol) clock library] for details and a list of timezones you can set.

The code may be updated using OTA (Over The Air) updates. You can still upload the code in the traditional USB approach, but after the firmware has been uploaded for the first time you can upload subsequent updates over WiFi. See the [ESP8266 OTA update documentation] for details.

Important: access to the current time is fundamental to the operation of the system. Therefore, you must have Internet access for the NTP library to work.

Enclosure

enclosure

The STL files to 3D print the enclosure are included in the repo: one file for the base and one for the lid. The wiring I piggybacked onto to reach my mailbox happens to come into a patch panel, so I have an RJ45 jack opening in my enclosure, which is what you see in the picture. In your slicing software you should turn on support for the RJ45 opening. Just about any filament is fine - I used PLA with a layer height of 0.4mm. The HEX address you see on the label is the unit address fro OTA updates.

Implementation

Assembly

enclosure

  • 3D print the enclosure base and lid.
  • Assemble the discrete components to the PCB.
  • Solder the female headers that come with the WeMOS to the PCB.
  • If using the RJ45 connector, punch down the switch connection wires into the RJ45 keystone connector, leaving enough wire to comfortably reach the PCB. Then insert the RJ45 into the case.
  • Solder the connection for the LED and use some 2mm shrink wrap tubing to protect the leads from shorting (or electrical tape if you don't have this).
  • Mount the LED. The hole is sized for a 3mm LED. If the fit is too loose, then secure the LED to the case with some UV-curable resin (preferred) or hot melt glue. If you don't use a green LED, you should recalculate the value of the current limiting resistor to match the Vf of your LED. If you don't know what this means, just use a green LED.
  • Solder the power wires to the DC power jack and fasten to the case.
  • Solder the wires to the PCB: power, switch, and LED, being sure to observe the correct polarity (marked on the PCB).
  • Insert the WeMOS into the headers. Note: You can mount the PCB to the enclosure now, but you will probably find it easier to program it first (see below).
  • Fasten the board to the mounting post in the base of the enclosure.
  • Attach the lid using the flat head screws.

Programming

  • Ensure the aforementioned local/personal changes have been implemented in the sketch (.ino) file and "locals.h".
  • For the first upload, connect a microUSB plug to the WeMOS.
  • In the Arduino IDE, select the "LOLIN(WeMos)D1 R2 & Mini" board.
  • Board settings:
Parameter Setting
CPU Frequency 160 MHz
Flash Size 4M(1M SPIFFS)
Upload SPeed 921600
Port your USB serial port
  • The WeMOS has an automatic system for enabling the flash sequence so no buttons need to be pressed.
  • After the code is uploaded, the green LED will illuminate when all of the setup and initialization steps are complete.
  • While the serial cable is still connected, open the serial port (115200 baud) and reset the WeMOS. The HEX address you need to do OTA updates will be printed. Save this for future use. At this point, you can launch the Blynk app and run the notifier app dashboard.
  • The USB cable may now be removed.

Copyright

Copyright 2018 Rob Redford. This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license, visit [CC-BY-SA].

[hackster.io] https://www.hackster.io/Rom3oDelta7/smartphone-mailbox-notifier-version-2-sept-2018-822a1d [Blynk]: http://www.blynk.cc/ [Blynk Library]: http://www.blynk.cc/getting-started/ [Blynk getting started guide]: http://www.blynk.cc/getting-started/ [NTP (Network Time Protocol) clock library]: https://github.com/Rom3oDelta7/NTP-RTC [Time Library]: http://www.pjrc.com/teensy/td_libs_Time.html [ESP8266 OTA update documentation]: https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html [address your carrier uses to send an SMS to your phone]: http://www.digitaltrends.com/mobile/how-to-send-e-mail-to-sms-text/ [CC-BY-SA]: https://creativecommons.org/licenses/by-sa/4.0/

About

Hardware and software solution to be notified when your mail arrives

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published