Mail Notification System

Mail Notification System

Member: Jiajie,YANG; Yuan,ZHANG

This is an intelligent mail notification system to improve user experience in mail receiving.

Features

  • Once mail comes into mailbox, user will receive email notification immediately
  • Use password to open mailbox instead of key
  • Set priority for different mails, emergent mails will be treated specially.

Image

Pin Setup

Embed PinOther Device
GNDGND
VOutVCC
VU+5V
p10TouchPad SDA
p11TouchPad SCL
p19IR Sensor1
p20IR Sensor2
p21Servo

Library

Import libraryEthernetInterface

mbed IP library over Ethernet

Import libraryHTTPClient

HTTP Library after modification

Import libraryServo

A class to control a model R/C servo, using a PwmOut

Import librarymbed-rtos

Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Demo Program

Import programMNS_Detect

Detect the mail and tweet

Import programMNS_Password

Touchpad Password and door opening and locking

main.cpp

#include <mbed.h>
#include <string>
#include "EthernetInterface.h"
#include "HTTPClient.h"
 
Serial pc(USBTX, USBRX);
DigitalIn EmergencyButton(p17);
AnalogIn DistanceSensor1(p20);
AnalogIn DistanceSensor2(p19);
 
HTTPClient http;
char str[512];
 
bool emergency=false;
bool exist=false;
 
bool checkEmergency(){
    if (!EmergencyButton){
        printf("Emergency Option Set...\n\r");
        return true;
    }
    return false;
}
 
bool checkDistance(){
    float distance1=DistanceSensor1;
    float distance2=DistanceSensor2;
    printf("First Sensor: %.3f\n\rSecond Sensor: %.3f\n\r\n", distance1, distance2);
    if (DistanceSensor1<0.60f){
        if (DistanceSensor2>0.60f) exist=true;
        else exist=false;
        printf("Waiting...\n\r");
        wait(3.0);
        if (DistanceSensor1>0.60f&&DistanceSensor2>0.60f)
            return true;
    }
    return false;    
}
 
 
void sendDistanceMessage(){
    
    char message[200];
    char emergencyMessage[]="Emergency Mail!!! Please come to fetch it IMMEDIATELY!!!";
    char normal[]="You have a mail delivered to your mailbox. Please come to check it.";
    char normalExist[]="You have a new mail...";
    if (emergency) sprintf(message, "%s", emergencyMessage);
    else if (exist) sprintf(message, "%s", normalExist);
    else sprintf(message, "%s", normal);
    emergency=false;
    
    printf("%s\n\r", message);
    
    HTTPMap map;
    HTTPText inText(str, 512);
    map.put("status", message);
 
    printf("\r\nTrying to post data...\r\n");
    http.basicAuth("ece4180mailbox@gmail.com", "MailNotificationSystem");
    int ret = http.post("https://api.twitter.com/1.1/statuses/update.json", map, &inText);
    if( ret == HTTP_OK )
    {
        printf("Tweet sent with success!\n\r");
    }
    else
    {
        printf("Problem during tweeting, return code %d\n\r", ret);
    }
    
}
 
int main() {
    EthernetInterface eth;
    eth.init(); //Use DHCP
    eth.connect();
    EmergencyButton.mode(PullUp);
    while(1) {
        if (checkEmergency())
            emergency=true;
        if (checkDistance())
            sendDistanceMessage();
        wait(1);
    }
}


2 comments on Mail Notification System:

15 Nov 2016

why cant i download the program??!!

15 Nov 2016

i love this project

Please log in to post comments.