Loading...
Hackathon 24 - Hamburg

Smart Home

mailbox notification project

Smart Home

The Problem
The underlying problem being projected here is that many times, the individual does not come to know about the arrival of any letter or any important delivery in the mailbox. This could delay tacit responses to various time-sensitive communications, such as bills, documents, and urgency-related deliveries. In other cases, this could also lead to missed deadlines, late fines, or even losses of some essential or sensitive items. This also causes a lot of inconvenience, having to go physically check the mailbox, wasting time when no new mail has arrived. A system that would notify when the mail has been delivered would greatly enhance efficiency and make sure important communications are attended to on good time.

Who is the Problem for
-Elderly people
-Busy Professionals

Customer Empathy

Pains & Gains

Before using product
-Manually checks their mailbox daily, often finding it empty.
-Worries about missing important mail or packages.
-Occasionally forgets to check the mailbox, leading to delays.

After using product
– Receives timely notifications on their phone or computer.
– No longer checks the mailbox unnecessarily.
-Feels more organized and connected.
-affordable .

Ideas for solution

The ESP8266 microcontroller-based automatic electronic mailbox notification system solves the problem of not knowing when mail has been received inside a physical mailbox. It detects the presence of mail using an ultrasonic sensor and then sends an email notification to the user each time new detected mail is found. The project connects via Wi-Fi with the SMTP server of Gmail for sending notifications.

Information Needed

Hardware and software Needed
-ESP8266 (NodeMCU or similar).
-Ultrasonic Sensor HC-SR04.
-Breadboard and jumper wires.
-Power supply options for ESP8266: battery pack and USB.

1. Working principle of an Ultrasonic Sensor:
It is a distance-measuring sensor, sending an ultrasonic sound wave and taking the time to return after bouncing off an object-in this case, mail.
You can provide a threshold distance; for example, if the distance inside the mailbox becomes shorter, this may detect mail.

2. Wiring the Ultrasonic Sensor to ESP8266
-VCC (Ultrasonic Sensor) → 3.3V (ESP8266).
-GND (Ultrasonic Sensor) → GND (ESP8266).
-Trig (Ultrasonic Sensor) → D1 (GPIO5) on ESP8266.
-Echo (Ultrasonic Sensor) → D2 (GPIO4) on ESP8266.

3. Ultrasonic Sensor Mailbox Notification Code:
Here is a full code example for the ESP8266 that will
Measure the distance inside the mailbox with the help of the ultrasonic sensor. Writing the email notification at every instance when the sensor detects mail above the distance threshold:

How Mail Detection Works

An ultrasonic sensor measures the distance to the bottom of the mailbox. When mail is inserted, the measured distance decreases.
If the distance falls below a pre-set threshold (15 cm), the system detects that mail has been received.

Wi-Fi Connection:
The ESP8266 connects to the local Wi-Fi network using stored SSID and password credentials. Once connected, it is ready to communicate with the internet.

Email Notification:
Upon detecting mail, the system establishes a secure connection to Gmail’s SMTP server via SSL.
It sends an email alert to the user, notifying them that they’ve

 

Code:

#include <dummy.h>

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <Base64.h>

const char* ssid = “SAL WIFI”; // Your Wi-Fi SSID
const char* password = “client@sal123!”; // Your Wi-Fi Password

const char* smtp_server = “smtp.gmail.com”;
const int smtp_port = 465;
const char* smtp_user = “kwameb792@gmail.com”; // Your Gmail address
const char* smtp_pass = “qbznedhjkeiptzrr”; // App password from Gmail (not your usual password)

WiFiClientSecure client;

const int trigPin = 5; // GPIO5 for Trig pin
const int echoPin = 4; // GPIO4 for Echo pin
long duration;
int distance;
int threshold = 15; // Set threshold for mail detection (in cm)

void setup() {
Serial.begin(115200);

pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

// Connect to Wi-Fi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println(“Connecting to WiFi…”);
}
Serial.println(“Connected to WiFi!”);
}

void sendEmail() {
client.setInsecure();
if (!client.connect(smtp_server, smtp_port)) {
Serial.println(“Connection to SMTP server failed”);
return;
}

// Communicate with the SMTP server
client.println(“EHLO smtp.gmail.com”);
client.println(“AUTH LOGIN”);

// Encode user and password in base64 and send
String smtp_user_base64 = base64::encode((char*)smtp_user);
String smtp_pass_base64 = base64::encode((char*)smtp_pass);
client.println(smtp_user_base64);
client.println(smtp_pass_base64);

// Start sending the email
client.println(“MAIL FROM:<” + String(smtp_user) + “>”);
client.println(“RCPT TO:<kwameb792@gmail.com>”); // Change this to your recipient email
client.println(“DATA”);

// Email content
client.println(“From: Mailbox Notification <” + String(smtp_user) + “>”);
client.println(“To: Kwame <kwameb792@gmail.com>”);
client.println(“Subject: Mail Alert”);
client.println();
client.println(“You’ve received mail in your mailbox!”);
client.println(“.”);

client.println(“QUIT”);
Serial.println(“Email sent”);
}

void loop() {
// Measure the distance using the Ultrasonic Sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;

Serial.print(“Distance: “);
Serial.print(distance);
Serial.println(” cm”);

if (distance < threshold) { // If the distance is less than the threshold, mail is detected
Serial.println(“Mail detected!”);
sendEmail();
delay(60000); // Wait 1 minute before checking again to prevent multiple emails
}

delay(1000); // Check every second
}