Pages: [1]   Go Down
Author Topic: How should I get the Arduino to notify Via email or something?  (Read 1229 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, I am making a project that should notify me via email or something to tell me when the room gets too hot. Simple eh?
I thought so... But i quickly figured out I can no find a nice way to actually get the Arduino to send an email or something of the sort. . . . . I have an Ethernet Shield so do you guys have any suggestions of what i could do?
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have an Ethernet Shield so do you guys have any suggestions of what i could do?

You can do a google search of the forum like below and find a lot of previous info on using the arduino for emailing. Using your ISP's smtp server is fairly easy.

http://www.google.com/search?q=email+site%3Ahttp%3A%2F%2Farduino.cc%2Fforum%2Findex.php&hl=en&num=100&lr=&ft=i&cr=&safe=images
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have done a lot of searching through the forum... All I came up with is that I should try pushing the email to a web server running a PHP script. Would that be the best solution?
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
All I came up with is that I should try pushing the email to a web server running a PHP script. Would that be the best solution?

That sounds like some type of klunky workaround. My arduino just sent me an email using the below code setup.

Code:
/*
SEND AN EMAIL WITH ARDUINO
9/23/11
This code was created by modifying the connect example from arduino.cc and with the help of the YABB forums and their very helpful members.
This code sends an email to any email address and then disconnects. 
*/

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // Arduino's artificial mac address
byte ip[] = { 192, 168, 1, 102 }; // my ip
byte server[] = { xxx, yyy, zzz, aaa }; // my smtp.xxx.net server ip

Client client(server, 25);

void setup()
{
  Ethernet.begin(mac, ip);
 Serial.begin(9600);

 Serial.println("connecting...");
 
 if (client.connect()) {
                        Serial.println("connected");
   
                        client.println("HELO itismeletschat"); /* say hello (statement after helo is needed but irrelevant)*/

                        client.println("MAIL From: me@my-isp.net"); /* identify sender, this should be the same as the smtp server you are using */

                        client.println("RCPT To: you@your-isp.net"); /* identify recipient */

                        client.println("DATA");

                        client.println("To: you@your-isp.net"); /* identify recipient */
                        client.println("Subject: You Have Arduino Mail!!"); /* insert subject */

                        client.println("Please let me know it worked!!!"); /* insert body */
                        client.println("."); /* end email */
                 
                        client.println("QUIT"); /* terminate connection */
                       
                        client.println();
   
 } else {
   Serial.println("connection failed");
 }
}

void loop()
{
   delay(10000);
   if (!client.connected()) {
   Serial.println();
   Serial.println("disconnecting.");
   client.stop();
   for(;;)
     ;
 }
}
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the code! but, how exactly does that handle authentication?

and i'm assuming it also wouldn't be able to use something like Gmail SMTP.
Logged

0
Offline Offline
Tesla Member
***
Karma: 116
Posts: 8944
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Below is some previously posted code with provisions for user name and password. You may want to do a google advanced search of the forum for pevious post concerning using the gmail servers.

Code:
//http://www.motobit.com/util/base64-decoder-encoder.asp e
 //http://webnet77.com/cgi-bin/helpers/base-64.pl

 
 #include <SPI.h>
 #include <Ethernet.h>

 // Local network configuration:
 byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x23, 0x5D };
 byte ip[] = { 192,168,0, 177 };

 // Login data:
 String UserName64 = "XXXXXXX";
 String Password64 = "XXXXXXX";

 // SMTP server data:
 // smtp.libero.it : 212.52.84.54
 // smtp.iol.it : 212.52.84.203
 // out.virgilio.it : 62.211.72.20
 byte server[] = { 212, 52, 84, 54 }; // SMTP server
 String ServerName = "libero.it";

 // Mail data:
 String Sender = "XXXXXXX@libero.it";
 String Recipient = "XXXXXXX@libero.it";
 String Subject = "Messaggio inviato da Arduino!";
 String Body = "Testo del messaggio\nsu piu'\ndi una riga.";

 int time = 1000;
 int wait = 1000;
 String ServerResponse="";
 Client client(server, 25);

 void setup()
 {
  Serial.begin(9600);
  Serial.println("Program started, waiting for router...");
  delay(time); /* allow the router to identify the Arduino before the Arduino connects to the internet */

  Serial.println("Starting network module...");
  Ethernet.begin(mac, ip);
  delay(2000);

  Serial.println("connecting...");
  if (client.connect()) {
     Serial.println("connected");

     SendMsg("EHLO " + ServerName); /* say hello*/
     SendMsg("AUTH LOGIN ");
     SendMsg(UserName64); /* Username*/
     SendMsg(Password64); /* Password */
     SendMsg("MAIL From:<" + Sender +">"); /* identify sender */
     SendMsg("RCPT To:<" + Recipient + ">"); /* identify recipient */
     SendMsg("DATA");
     SendMsg("To: " + Recipient); /*  recipient in message header */
     SendMsg("From: " + Sender); /* seder name in message header */
     SendMsg("Subject: "+ Subject); /* insert subject */
     SendMsg(""); /* empty line */
     SendMsg(Body); /* insert body */
     SendMsg(""); /* empty line */
     SendMsg("."); /* end mail */
     SendMsg("QUIT"); /* terminate connection */
     client.println();

  } else {
    Serial.println("connection failed");
  }
 }

 void loop()
 {
  if (client.available()) {
    char c = client.read();
    Serial.print(c);
  }

  if (!client.connected()) {
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
    for(;;)
      ;
  }
 }

 void GetResponse() {
    if (client.available()) {
         char c = client.read();
         while (client.available()) { // Store command char by char.
           ServerResponse +=c;
           c = client.read();
         }
    Serial.println("<<<" + ServerResponse);
    ServerResponse="";
  }
 }

 void SendMsg(String m) {
   client.println(m);
   Serial.println(">>>" + m);
   delay(wait); /* wait for a response */
   GetResponse();
 }
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a bunch! Especially for the quick reply haha.
 I'll give it a go when I get home.
Logged

scranton,pa
Offline Offline
Newbie
*
Karma: 2
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what mail are you using? i tried gmail and gmx mail(gmx workes on my security cam)but can't get any to work.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay I (sorta) got this working right. I am using a private/work SMTP server and it usually connects fine over the internet but when i try reconnecting with the same LOCAL IP address it wont connect but if i change it, it does. THIS MAKES noooo sense to me what-so-ever...like, I can connect perfectly fine one time and then hit the reset button and it wont connect... ): please help me. When i use cmd to telnet in, it works every time. but my little arduino seems to be having issues :/
« Last Edit: September 25, 2011, 06:54:22 pm by samabecker » Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 71
Posts: 3515
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How about an SMS message? There are at least a few ways to send Tweets from an Arduino with an Ethernet shield (GIYF). Twitter can then send them to your phone. I'm using ThingSpeak and their Twitter interface to do something similar.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah. but.. Now with twitter using Oauth, it's pretty much you passing your log in info and status to a server which then does the real work of posting the twitter status. Which is what i described up there... Which i'd rather not do, i mean i've got the thing to send multiple emails and it worked great! just for some reason it wont simply connect : / maybe i can try again when i'm at the office on the same local network as the SMTP server, perhaps that will stop my issue.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Update** Okay, I used this code on the same local network as the mail server and it worked out perfectly fine and connected like a charm. :DD thanks everyone for the help!
Logged

Boston
Offline Offline
God Member
*****
Karma: 3
Posts: 575
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

To get around the Twitter authentication I tried a different service called Notifio.
Sends text messages to my phone.  Works great.

http://notifo.com/
Logged

Pages: [1]   Go Up
Jump to: