Go Down

Topic: GPRS to server ubuntu (GET) (Read 488 times) previous topic - next topic

kove3374

I would like to connect my GPRS modem by internet and send a string to a server,
Does anybody correct the following code ?
Thank you very much!!

Code: [Select]



#include <SoftwareSerial.h>
#include <String.h>
SoftwareSerial mySerial(7,8);


void setup()
{

Serial.begin(9600);// inizializza seriale
mySerial.begin(9600); // nei nuovi modem 1.4 lascia il baud rate a 9600

//ACCENSIONE MODEM GPRS
  pinMode(9, OUTPUT);
  digitalWrite(9,LOW);
  delay(1000);
  digitalWrite(9,HIGH);
  delay(2000);
  digitalWrite(9,LOW);
  delay(15000);
 
 
    // INIZIALIZZAZIONE MODEM GPRS
  mySerial.println("AT+CGATT?");//interroga lo stato
  delay(5000);
  ShowSerialData();
  mySerial.println("AT+CSTT=\"ibox.tim.it\",\"\",\"\"");//definisci APN e ISP
  delay(5000);
  ShowSerialData();
  mySerial.println("AT+CIICR");//bring up wireless connection
  delay(5000);
  ShowSerialData();
  mySerial.println("AT+CIFSR");//get local IP adress
  delay(5000);
  ShowSerialData();
  mySerial.println("AT+CIPSPRT=0");
  delay(5000);
  ShowSerialData();
  //mySerial.end();
  delay(5000);

}
void loop()
{



delay(5000);

// SEND DELLA STRINGA VIA GPRS

mySerial.println("AT+CIPSTART=\"TCP\",\"xxx.xxx.xx.xxx\",\"80\"\r");//start up the connection

delay(10000);
ShowSerialData();
//mySerial.end(); FUNZIONA ANCHE SENZA QUESTO !!!!!!!!!!
delay(5000);
mySerial.println("AT+CIPSEND");//begin send data to remote server
delay(2000);
ShowSerialData();
mySerial.print("GET /xxx.php?dati=" );
//mySerial.print("GET /stazioni/firenze.php?dati=" );
delay(2000);
//terrasystem
mySerial.print("PIA,111,22,33");
//mySerial.print(tempsum);
//mySerial.print(",");
delay(1000);
ShowSerialData();
mySerial.println((char)26);//sending
delay(5000);//waiting for reply, important! the time is base on the condition of internet
mySerial.println();
ShowSerialData();
mySerial.println("AT+CIPCLOSE");//close the connection
delay(5000);
ShowSerialData();
//mySerial.flush();
//mySerial.end();

}

void ShowSerialData()
{
while(mySerial.available()!=0)
Serial.write(mySerial.read());
}


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy