Am not able to send data to phpmyadmin database using sim900a via TCP/IP.

hi everybody… please i need your help… am not able to send data to phpmyadmin database using sim900a and tcp/ip connection. the code that i have tried to do that is as shown below

#include <SoftwareSerial.h>
/* Create object named SIM900 of the class SoftwareSerial /
SoftwareSerial SIM900(8, 7);
void setup() {
SIM900.begin(9600); /
Define baud rate for software serial communication /
Serial.begin(9600); /
Define baud rate for serial communication */
}

void loop() {
Serial.println(“TCP Send :”);
Serial.print(“AT\r\n”);
SIM900.println(“AT”); /* Check Communication /
delay(5000);
ShowSerialData(); /
Print response on the serial monitor /
delay(5000);
Serial.print(“AT+CIPMODE=0\r\n”);
SIM900.println(“AT+CIPMODE=0”); /
Non-Transparent (normal) mode for TCP/IP application /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIPMUX=0\r\n”);
SIM900.println(“AT+CIPMUX=0”); /
Single TCP/IP connection mode /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CGATT=1\r\n”);
SIM900.println(“AT+CGATT=1”); /
Attach to GPRS Service /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CREG?\r\n”);
SIM900.println(“AT+CREG?”); /
Network registration status /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CGATT?\r\n”);
SIM900.println(“AT+CGATT?”); /
Attached to or detached from GPRS service /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CSTT=“internet”,”",""\r\n");
SIM900.println(“AT+CSTT=“internet”,”","""); /
Start task and set APN /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIICR\r\n”);
SIM900.println(“AT+CIICR”); /
Bring up wireless connection with GPRS /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIFSR\r\n”);
SIM900.println(“AT+CIFSR”); /
Get local IP address /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIPSTART=“TCP”,“127.0.0.1”,“80”\r\n”);
SIM900.println("AT+CIPSTART=“TCP”,“127.0.0.1”,“80"”); /
Start up TCP connection /
delay(5000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIPSEND\r\n”);
SIM900.println(“AT+CIPSEND”); /
Send data through TCP connection /
delay(2000);
ShowSerialData();
delay(2000);
Serial.print(“GET http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B\r\n”);
SIM900.print(“GET http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B\r\n\x1A”); /
URL for data to be sent to /
delay(10000);
ShowSerialData();
delay(5000);
Serial.print(“AT+CIPSHUT\r\n”);
SIM900.println(“AT+CIPSHUT”); /
Deactivate GPRS PDP content */
delay(5000);
ShowSerialData();
delay(5000);
}

void ShowSerialData()
{
while(SIM900.available()!=0) /* If data is available on serial port /
Serial.write(char (SIM900.read())); /
Print character received on to the serial monitor */
}

the url that am using to send data is http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B

am not able to send data to phpmyadmin database

You never will be able to. phpmyadmin is a php script for administering MySQL databases, NOT a database.

  Serial.print("GET http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B\\r\\n");

A GET request does NOT contain a protocol, so the http:// bit is wrong. It does NOT contain a server name, and even if it did, the server name is NOT localhost.

thank you for your reply sir, so can you help me to correct it so that i can send data that are in the url to phpmyadmin please?

Solomon1992: thank you for your reply sir, so can you help me to correct it so that i can send data that are in the url to phpmyadmin please?

No, because you will NOT be sending data to the phpmyadmin script. EVER.

The server you are sending data to is NOT localhost. YOU need to get a clue as to what localhost means, then maybe you'll understand why the Arduino can not execute a php script on localhost.

ok thanks, so what shoul i do? coz am not interested on that. that's why i need some helps so that i can fix it

ok thanks, so what shoul i do?

When in doubt,
run in circles,
scream and shout.

When that doesn’t work, put the Arduino in a box and nail it shut.

Learn how to make one PC make a GET request to a server on another PC. When you can do that, you can get the Arduino back out, and make it make the GET request PROPERLY.

I’ve told you TWICE EXACTLY what the problem is, but you are not listening.

I don’t know this SIM900A GSM/GPRS card so I can’t do more that this (as I said in a PM), but I can say the following:

  1. The title of your post is misleading. You are sending data to a mySql (MariaDB) database not phpmyAdmin database. This has already now been pointed out to you. Of course, your server also has a web server and PHP installed

  2. You can successfully use the following URL to test your server :
    http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B

  3. You are attempting to follow a tutorial at http://www.electronicwings.com/arduino/http-client-using-sim900a-gprs-and-arduino-uno
    for using this Sim900A as an HTTP client for sending data to your server.

  4. The tutorial demonstrates an AT command interface to the SIM900A. The code you have attempted to integrate is not appropriate for the AT command interface and looks like it is based on a non-AT interface example:

 Serial.print("GET http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B\\r\\n");
  SIM900.print("GET http://localhost/data2_write.php?RFID_TAG_No=42:30:EB:10&SITE_NAME=BLOCK B\r\n\x1A");  
  /* URL for data to be sent to */

The format has to be much closer to the equivalent line in the tutorial:

  Serial.print("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\"\\r\\n");
  SIM900.println("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\"");	/* Set parameters for HTTP session */
  1. The full code is in the tutorial is here:
#include <SoftwareSerial.h>
/* Create object named SIM900 of the class SoftwareSerial */
SoftwareSerial SIM900(8, 7);
void setup() {
  SIM900.begin(9600);	/* Define baud rate for software serial communication */
  Serial.begin(9600);	/* Define baud rate for serial communication */
}

void loop() {
  Serial.println("HTTP post method :");
  Serial.print("AT\\r\\n");
  SIM900.println("AT"); /* Check Communication */
  delay(5000);
  ShowSerialData();	/* Print response on the serial monitor */
  delay(5000);
  /* Configure bearer profile 1 */
  Serial.print("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"\\r\\n");
  SIM900.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");	/* Connection type GPRS */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+SAPBR=3,1,\"APN\",\"TATA.DOCOMO.INTERNET\"\\r\\n");
  SIM900.println("AT+SAPBR=3,1,\"APN\",\"TATA.DOCOMO.INTERNET\"");	/* APN of the provider */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+SAPBR=1,1\\r\\n");
  SIM900.println("AT+SAPBR=1,1");	/* Open GPRS context */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+SAPBR=2,1\\r\\n");
  SIM900.println("AT+SAPBR=2,1");	/* Query the GPRS context */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPINIT\\r\\n");
  SIM900.println("AT+HTTPINIT");	/* Initialize HTTP service */
  delay(5000); 
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPPARA=\"CID\",1\\r\\n");
  SIM900.println("AT+HTTPPARA=\"CID\",1");	/* Set parameters for HTTP session */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\"\\r\\n");
  SIM900.println("AT+HTTPPARA=\"URL\",\"api.thingspeak.com/update\"");	/* Set parameters for HTTP session */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPDATA=33,10000\\r\\n");
  SIM900.println("AT+HTTPDATA=33,10000");	/* POST data of size 33 Bytes with maximum latency time of 10seconds for inputting the data*/ 
  delay(2000);
  ShowSerialData();
  delay(2000);
  Serial.print("api_key=C7JFHZY54GLCJY38&field1=1\\r\\n");	/* Data to be sent */
  SIM900.println("api_key=C7JFHZY54GLCJY38&field1=1");
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPACTION=1\\r\\n");
  SIM900.println("AT+HTTPACTION=1");	/* Start POST session */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+HTTPTERM\\r\\n");  
  SIM900.println("AT+HTTPTERM");	/* Terminate HTTP service */
  delay(5000);
  ShowSerialData();
  delay(5000);
  Serial.print("AT+SAPBR=0,1\\r\\n");
  SIM900.println("AT+SAPBR=0,1"); /* Close GPRS context */
  delay(5000);
  ShowSerialData();
  delay(5000);
}

void ShowSerialData()
{
  while(SIM900.available()!=0)	/* If data is available on serial port */
  Serial.write(char (SIM900.read()));	/* Print character received on to the serial monitor */
}
  1. To be able to adapt this code, you will need to download a AT command manual from somewhere which describes the command.
    Since you have used the HTTP GET method in your PHP, you may also have to change this line which appears to refer to another method, that is HTTP POST:
 Serial.print("AT+HTTPACTION=1\\r\\n");
  SIM900.println("AT+HTTPACTION=1");	/* Start POST session */

I hope someone with the appropriate experience with this card can help.
Use this thread for any further questions.

ok sir thank you, but i wanted to send data to mariaDB via sim900a but in the tutorial they tried to show sending data to thingspeak which is also i was able to send data to thingspkeak, but now i want also to send data to mariaDB server by using that url as i shown early sir.

then i have followed this tutorial......

http://www.electronicwings.com/arduino/sim900a-gprs-module-interfacing-with-arduino-uno