Pages: [1]   Go Down
Author Topic: problem with sending E-mail from arduino uno and sim900 standalone mode  (Read 979 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

char data[1024];
int led = 13;
int onModulePin = 2;
// the pin to switch on the module (without press on button)
int x = 0;
char name[20];
char server[ ]="mail.o2online.de";
char port[ ]="25";
void switchModule(){
  digitalWrite(onModulePin,HIGH);
  delay(2000);
  digitalWrite(onModulePin,LOW);
}
void setup(){
  Serial.begin(115200);                // UART baud rate
  delay(2000);
  pinMode(led, OUTPUT);
  pinMode(onModulePin, OUTPUT);
  switchModule();                    // switches the module ON
  for (int i=0;i < 4;i++){
    delay(5000);
    } 
    Serial.println("AT");
    delay(700);
    Serial.println("AT+CMGF=1");
    delay(700);
    Serial.println("AT+CSCS=\"GSM\"");
    delay(700);
    Serial.println("AT+CGATT=?");
    delay(700);
    Serial.println("AT+CIPSRIP=1");
    delay(700);
    Serial.println("AT+CGQREQ=1,0,0,0,0,0");
    delay(700);
    Serial.println("AT+CGCONT=1,\"IP\",\"INTERNET\"");
  do{ 
    while(Serial.available()==0);
    }while(Serial.read()!='K');

    delay(700);
    Serial.println("AT+CSTT=\"INTERNET\",\"\",\"\"");
    delay(700);
  do{ 
    while(Serial.available()==0);
    }while(Serial.read()!='K');

    Serial.println("AT+CIICR");
    delay(700);
    Serial.println("AT+CIFSR");
    delay(700);
    Serial.println("AT+CIPSTATUS");
    delay(700);
    Serial.println("AT+CIPMUX?");
    delay(700);
    Serial.println("AT+CIPSTART=\"TCP\",\"mail.o2online.de\",\"25\"");    //TCP connection in id 0       
  do{ 
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(10000);
    do{     //waits for connection
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data

  Serial.print("helo mail.o2online.de");
  Serial.write(0x1A);    //EOL character
  Serial.write(0x0D);
  Serial.write(0x0A);
  do{   
      while(Serial.available()==0);
    }while(Serial.read()!='K');   
  delay(7000);
  Serial.println("AT+CIPSEND"); //sending data
  do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.print("Auth login");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A);
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K'); 
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
         while(Serial.available()==0);
       }
       while(Serial.read()!='>');
    delay(7000);
    Serial.print("xxxx");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A);
  do{
    while(Serial.available()==0);
    }while(Serial.read()!='K'); 
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.print("xxxx");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A); 
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.print("MAIL FROM:<xxxxxxxx@o2online.de>");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A); 
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.print("RCPT TO:<xxxxxxxxxxxx>");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A); 
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.print("DATA");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A); 
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    Serial.println("AT+CIPSEND"); //sending data
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='>');
    delay(7000);
    Serial.println("my first mail.");
    Serial.println(".");
    Serial.println(".");
    Serial.write(0x1A);    //EOL character
    Serial.write(0x0D);
    Serial.write(0x0A); 
    do{
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
   
  Serial.println("AT+CIPCLOSE");
  do{ 
    while(Serial.available()==0);
    }while(Serial.read()!='K');
    delay(7000);
    }
   void loop(){
    delay(500);
    digitalWrite(led,HIGH);
    delay(500);
    digitalWrite(led,LOW);
    }

can somebody help me....
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1. Use the code tags! Without them your code is a mess to look at and it may be wrong because the tag processor is hiding parts of it.

2. Explain what your problem is.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried using AT commands from SW serial then it works but when I try to implement the same commands from arduino,It doesnt work. I need a program which can send e-mails from gprs shield using Arduino and not the serial port of pc.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 108
Posts: 5144
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Edit your original post and add code tags! I won't look at the code without the code tags because I don't wanna waste my time finding errors caused by the tag parser of the forum.
Logged

Pages: [1]   Go Up
Jump to: