How To Make Smart Home Electronics: A Smart Mailbox

smart home electronics

smart home electronics

This project combines the idea of IOT and Smart Home electronics in one useful project. The project aims to save your time checking your mailbox by simply sending you notifications to your mobile phone if you get new mail. With one of the features offered in this project, connection coverage, you are able to check your mailbox at home from any place in the world.

Description

Detect if there is new mail inside your mailbox.

Notify the user by the mobile app with the detection result.

Hardware components:

ESP8266

smart home electronics

Figure 1: ESP8266 / ©ACROBOTIC

  • 32-bit microcontroller with 80 MHz clock frequency with built-in Wi-Fi module
  • Extremely low-cost around $1
  • Could be run with Lua (NodeMCU), JavaScript (Espruino), and Python (Micro Python) interpreters
  • Arduino IDE integration

ESP-12E Development Board (aka NodeMCU DevKit)

smart home electronics

Figure 2: NodeMCU / ©ACROBOTIC

The ESP-12E module breaks out all the available ESP8266 pins on a development board for easy interaction with the user.

  • Can be programmed easily via micro USB cable.
  • Visible LED for indicating the status of the SoC’s Tx pin.
  • ESP-12E a 4MB SPI flash storage IC
  • onboard antenna with a reasonable range (–70~–80 dBm at 50 feet).
smart home electronics

Figure 3: ESP-12E Development Board / ©ACROBOTIC

HC-SR04 Ultrasonic Sensor

smart home electronics

Figure 4: Ultrasonic sensor

The HC-SR04 ultrasonic sensor uses sonar ultrasonic waves to determine distance to an object. It offers excellent non-contact range detection with high accuracy and stable readings. Its operation is not affected by sunlight or black material. It comes complete with an ultrasonic transmitter and receiver module.

You can find the User’s Manual for the HC-SR04 ultrasonic sensor here.

Software components:

Arduino IDE
Blynk App
Milestones

Install ESP-12E Development Board driver in Arduino IDE

In the Arduino IDE open the Preferences window and Copy the URL below into the Additional Boards Manager URLs field, and select OK.

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Add a comma and then space before adding the above URL if you already have some other boards in the board manager’s URL.

smart home electronics

smart home electronics

Select the menu option Tools → Board → Boards Manager… Scroll down and locate the option esp8266 by ESP8266 Community, which should be the last item on the list, then click Install.

Please refer to this tutorial if you need additional help setting up the board:

Sketch Ultrasonic sensor with ESP-12E Development Board

Connections

smart home electronics

Figure 5: System wiring

Clearly, we only have a few connections since most of the functions are done internally by our sketch.

Sketch

Jumping to the sketch used to detect new mails in your post mailbox:

You don’t need to include any library for this sketch; you can simply flash the following sketch on your NodeMCU.

[https://github.com/formus14/Smart_mailbox/tree/master/Ultrasonic_HC_SR04_ESP8266]

You can monitor the results from the Serial monitor from the Arduino IDE.

Connect the sketch with Blynk app

This part consists of two parts: 1. Arduino sketch; and 2. Building a mobile app using Blynk.

Sketch

There is a lot going on in the sketch part. I will try to break it down into simpler steps.

Blynk is an app that can interact with most microcontrollers in the market right now by sending and receiving data from a mobile app and microcontroller.

  • Download and include Blynk library so we can use all Blynk functionalities.

[https://github.com/formus14/Smart_mailbox/tree/master/blynk-library-0.3.4]

[https://github.com/formus14/Smart_mailbox/tree/master/SimpleTimer-library]

  • If you’re using simple LCD, use virtual pins to send data to the mobile app. In this project, we’ll use normal digital or analog pins to send data from the app to the hardware.
  • If you’re using advanced LCD, simply create an object for the LCD as you see in the sketch.

Download all the sketches and libraries here: [https://github.com/formus14/Smart_mailbox]

smart home electronics

Blynk Mobile App

With Blynk, you can build interfaces by using widgets to control and monitor hardware projects from your iOS and/or Android devices. Blynk supports Arduino, Raspberry Pi, ESP8266, Particle Core, and other common microcontrollers.

There are other platforms that allow you to control hardware over the internet. For this project, however, we will use Blynk, which is very user-friendly.

A few things you should notice in the sketch:

  • char auth[] = ” “;

This line in the mailbox.ino sketch should be filled with your own auth token that you get when create your app.

Blynk.begin(auth, “WIFI Network”, “WIFI PASSWORD”);

For this line in the setup function, you should replace “WI-FI Network” by your own Wi-Fi network name. The same goes for “Wi-Fi PASSWORD”

In addition to Getting Started on Blynk, here is a step-by-step guide on how you can create your app with screenshots:

1)         After logging on with your account details, you will see this screen:

smart home electronics

2)         After pressing “Create New Project” enter your project title and choose “ESP8266” as your hardware model.

smart home electronics

smart home electronics

3)         It’s very important that you save the Auth Token since we will add it to our main sketch on ESP8266. You have an option to send it on the same email you are logged in with by simply pressing e-mail.

smart home electronics

4)         Once sending is done, you can click “Create” to complete creating your project. After creating your project, you will be ready to add widgets to your app.

smart home electronics

5)         Press add “+” from the top right corner of the screen. All widget boxes will be visible for you, then drag the LCD widget to your workspace.

smart home electronics

smart home electronics

6)         For our system, we only need LCD but enjoy playing around with all widgets available.

There are 2 ways to print on the LCD (Simple or Advanced). This tutorial introduces the advanced way.

smart home electronics

smart home electronics

7)         Press “O Screen” under COLORS to change LCD backlight; the same goes for “(T) Text” and text color.

Now you should connect the LCD to a virtual pin so it can communicate with ESP8266 over the Blynk server.

In the main sketch, I connected the LCD with Virtual pin 1.

smart home electronics

smart home electronics

smart home electronics

smart home electronics

8)         Now the app is ready to interact with your hardware system.

smart home electronics

9)         Upload the sketch to ESP8266 and run your app on Blynk.

If you don’t have any mail you will get this message on the LCD:

smart home electronics

If you did get mail in your mailbox, you will see this message on your screen instead:

smart home electronics

Now, you can save your time by checking your mailbox only when you receive mail.

smart home electronics