Arduino Auto Email Notification

I would like to start work on a project involving arduino and email notifications. I'm not sure if something like this has been done before, but I guess it has some form. Let me explain. Basically, I would like to set up arduino either with the help of some piezoelectric sensors or with the help of a kinect, so that when an action (or pressure is detected), an email (or tweet) will be sent automatically. I'm sure this can be done, but I'm not sure where to start, and I wonder if anyone has an idea? Thanks in advance.

+5
source share
3 answers

I have not tested the code below, but this is the most basic structure of what you are trying to do.

On Arduino, configure your code to output something on the serial line ("arduino_output") when you want to send an email. Then on the computer, wait for this event.

Linux is very simple because the serial port can be handled in the same way as reading a file.

#!/usr/bin/perl
use open ':std';
use MIME::Lite;

#Open the COM port for reading
#just like a file
open FILE, "<", "/dev/usbTTY0" or die $!;

#setup e-mail message
$msg = MIME::Lite->new(
    From        => '"FirstName LastName" <something@gmail.com>',
    To          => "somebody@hotmail.com",
    Subject     => "subject",
    Type        => "text/plain"
);

#loop forever (until closed w/ ctrl+c)
while (1){
    while (<FILE>){
        # if there is output from the arduino (ie: Serial.write(...))
        # then the e-mail will be sent
        if ($_ == "arduino_output"){
            MIME::Lite->send('smtp','mailrelay.corp.advancestores.com',Timeout=>60);
            $msg->send();
        }
    }  
}

Good luck with your project.

+1
source

Very easy to check mail with arduino!

I wrote a message here http://www.albertopasca.it/whiletrue/2011/03/arduino-mail-notifier-cs/ use C # in windows to check gmail mail.

You can adapt the code to use it for every OS you want.

hope this helps.

0
source

Pyserial

arduino python

void setup(){
  Serial.begin(9600);
}
void loop(){
  if (EVENT BECOME TRUE /* sensor value or whatever */){
    Serial.write("Send mail");
  }
}

python { pyserial}

import serial
import smtplib
def sendMail(receiver,message):
    try:
        s=smtplib.SMTP_SSL()
        s.connect("smtp.gmail.com",465)
        s.login("YOUR-SENDER-MAIL@gmail.com", "Password")
        s.sendmail("your.log.result@gmail.com", receiver, message)#write the destination at receiver parameter  
    except Exception,R:
            print R

ser = serial.Serial('/dev/tty.usbserial', 9600)# or in windows you could write port name
while 1:
  receive = ser.readline()
  if receive == "send mail":sendMail("send-me-notification@gmail.com","YOU got mail from arduino!")

well, you can change smtp according to your MAIL host, in my case I used gmail, good luck in your project: D

0
source

All Articles