1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
| #include "SIM900.h"
#include <SoftwareSerial.h>
//#include "inetGSM.h"
//#include "sms.h"
//#include "call.h"
//To change pins for Software Serial, use the two lines in GSM.cpp.
//GSM Shield for Arduino
//www.open-electronics.org
//this code is based on the example of Arduino Labs.
//Simple sketch to communicate with SIM900 through AT commands.
//InetGSM inet;
//CallGSM call;
//SMSGSM sms;
#include "inetGSM.h"
int numdata;
InetGSM inet;
char inSerial[40];
int i=0;
boolean started = false;
void setup()
{
//Serial connection.
Serial.begin(9600);
Serial.println("GSM Shield testing.");
//Start configuration of shield with baudrate.
//For http uses is raccomanded to use 4800 or slower.
if (gsm.begin(9600)) {
Serial.println("\nstatus=READY");
started=true;
} else Serial.println("\nstatus=IDLE");
if(started) {
//GPRS attach, put in order APN, username and password.
//If no needed auth let them blank.
if (inet.attachGPRS("uinternet", "", ""))
Serial.println("status=ATTACHED");
else Serial.println("status=ERROR");
delay(1000);
Serial.println(" line 0001");
gsm.SimpleWriteln("AT+EMAILCID=1");
// Serial.println("AT+EMAILCID=1");
delay(50000);
gsm.SimpleWriteln("AT+EMAILTO=30");
// Serial.println("AT+EMAILTO=30");
delay(500000);
gsm.SimpleWriteln("AT+SMTPSRV='smtp.gmail.com','465' "); // stmp&port
// Serial.println("AT+SMTPSRV='smtp.gmail.com','465' ");
delay(50000);
gsm.SimpleWriteln("AT+SMTPUTH=1,'user','password'");
// Serial.println("AT+SMTPUTH=1,'user','password'");
delay(50000);
gsm.SimpleWriteln("AT+SMTPRCPT=0,0,'#######@gmail.com','NAME'");
// Serial.println("AT+SMTPRCPT=0,0,'#######@gmail.com','NAME'");
delay(50000);
Serial.println("line 5");
gsm.SimpleWriteln("AT+SMTPRCPT=1,0,'######@gmail.com','NAME'");
// Serial.println("AT+SMTPRCPT=1,0,'#######@gmail.com','NAME'");
delay(50000);
gsm.SimpleWriteln("AT+SMTPRCPT=2,0,'#####@gmail.com','NAME'");
// Serial.println("AT+SMTPRCPT=2,0,'#####@gmail.com','NAME'");
delay(50000);
gsm.SimpleWriteln("AT+SMTPSUB='TEST'");
// Serial.println("AT+SMTPSUB='TEST'");
delay(50000);
Serial.println("line 8");
gsm.SimpleWriteln("AT+SMTPBODY> HELLO WORLD !! GPRS ARDUINO ");
// Serial.println("AT+SMTPBODY> HELLO WORLD !! GPRS ARDUINO ");
delay(50000);
gsm.SimpleWriteln("AT+SMTPSEND");
// Serial.println("AT+SMTPSEND");
delay(10000);
Serial.println("finished");
}
};
void loop()
{
delay(10000);
Serial.println("0003");
} |