Go Down

Topic: How can I send data to update a remote mysql database (Read 988 times) previous topic - next topic

pierrot10

Dear All,

I am a beginer and I am still working hard to get my goal  :)
I finally could send send SMS via a Arduino UNO. Later, I will use Arduino mini pro
(Does Sketch work with all microcontroller, or only with Arduino?)
I also was able to send data to a server with TCP protocol, but it has never worked perfectly.
Between that time I also discover a library (WISMO228) wich send data to a remote php file throug HTTP.
I liked this but it only wok with a card whoch has a Sierra Wireless item.
Then , as I am working with a prototyp and later I will change my parts to smaller parts, that library will not work  :smiley-roll:

Then I am trying to re-code with AT command and not that code does not work perfretly. It does not...
I tried to increase the delay....
Code: [Select]

     Serial.println(F(""));
     
     Serial.println(F("GPS Parser Initialized"));
     delay(1000);
     
     Serial.println(F("Setting up PDP Context"));
     cell.println("AT+CGDCONT=1,\"IP\",\"internet\"");
     status(); // Some time it display OK or nothing
     delay(1000);
     
     Serial.println(F("Activating PDP Context"));
     cell.println("AT+CGACT=1,1");
     status(); // Some time it display OK or nothing
     delay(1000); // I also tried to increase up to 20000
     
     Serial.println(F("Configuring TCP connection to TCP Server"));
     cell.println("AT+SDATACONF=1,\"TCP\",\"host.server.org\",81");
     
     status(); // +CME ERROR: 33, +CME ERROR: 28, +CME ERROR: 4, it is random
     delay(1000);
     
     Serial.println(F("Starting TCP Connection"));
     cell.println("AT+SDATASTART=1,1");
     status(); // +CME ERROR: 33, +CME ERROR: 28, +CME ERROR: 4, it is random
     delay(500);
     
    /*
     Serial.println(F("Getting status"));
     cell.print("AT+SDATASTATUS=1");
     status();
     
     delay(3000);
     Serial.println(F("Display status"));
     cell.print("+SOCKSTATUS");
     delay(5000);
     status();
     */
     
     
     cell.println(data);
     
     Serial.println(F("Close connection"));
     cell.print("AT+SDATASTART=1,0");
     delay(1000);
 
     Serial.println(F("Disable PDP Context"));
      cell.print("AT+CGACT=0,1");
      delay(1000);
     
     Serial.println(F("**************************"));


My goal is to have a code which work with different GSM/GPRS shield, particularely with a next small shield I am going to buy
https://www.sparkfun.com/products/10138

In the TCP or HTTP(s) case, Someone cane tell me the adventage and disaventage of TCP vs HTTP?

Someone has a sample code to send data with HTTP protocol to a remote PHP file, which will get the sent data and update a MSQL database?
Or someone know a "multiplatform" library to send data to a remote server using HTTP, or HTTPS, or TCP.... (I do not really like FTP because it need a username and password, and I want to send data to update a Mysql data base, With ftp we can delete and add file.

Another interesting  way is to work with XML or JSON. Does Arduino can use JSON to send data?

Many thank for your advises, help and support.
Cheers
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

pYro_65

You want to keep the Arduino's work to a minimum. In my opinion, http is the most useful, you would need some sort of remote server to communicate with a DB or file system, most free web servers fully support what you need.

This looks like it will do the job

Quote
Someone cane tell me the adventage and disaventage of TCP vs HTTP


Nope, tcp is a transport layer protocol. http is an application/communication protocol.

HTTP can run on both TCP and UDP. For quality assurance it is typically TCP.

pierrot10

Thank for your answer and for the link.
But does the Ethernet library will work? Because I do not have a Ethernet shield. I am using a GSM/GPRS shield
Cheers
Il ne suffit pas de tout savoir, la persévérance, c'est déjà presque tout!

Go Up