Thanks for taking time to read my post. Ill try just cover what i believe to be important to the problem but i'm not a professional coder so please bear with me.
I have a SIM900 module with an Arduino Mega, and am trying to use the http get function to send data to a mySQL database. I have successfully used the SIM900 to create text files in my .ftp server so i know it works to some degree, just not the http function. I have a .php script which works fine when i use it through my browser (eg. visiting "mysite.epizy.com/senddata.php?sensor69=69" will return in the browser:
Array ( [sensor69] => 69 [__test] => dfc33491ff131abef9348da81e436528 [_ga] => GA1.2.428043981.1572933465 )
When i try connect with the SIM900 i get the following on my serial:
setting connection type
AT+SAPBR=3,1,"CONTYPE","GPRS"
OK
AT+SAPBR=3,1,"APN","WWW.vodafone.net.nz"
OK
AT+SAPBR=1,1
ERROR
AT+SAPBR=2,1
+SAPBR: 1,1,"121.90.164.49"
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","mysite.epizy.com/send_data.php?sensor69=69"
OK
AT+HTTPACTION=0
OK
⸮⸮
+HTTPACTION:0,200,859
⸮
AT+HTTPREAD
+HTTPREAD:859
<html><body><script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&ar
AT+HTTPTERM
OK
As we can see on the HTTPREAD function returns 859 characters but this seems to be truncated, and there is no registration in my database or log file (created/updated within the .php) This is my .php script "senddata.php"
<?php
print_r($_REQUEST);
//log php activation
date_default_timezone_set("Pacific/Auckland");
$my_file = 'log.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$new_data = "\n"."Module=".$_GET['moduleID'].", ". date("d:m:Y")." ". date("h/i/sa");
fwrite($handle, $new_data);
fclose($handle);
// Prepare variables for database connection
$dbusername = "epiz_69696969"; // enter database username, I used "arduino" in step 2.2
$dbpassword = "69696969696969"; // enter database password, I used "arduinotest" in step 2.2
$server = "sql169.epizy.com"; // IMPORTANT: if you are using XAMPP enter "localhost", but if you have an online website enter its address, ie."www.yourwebsite.com"
$moduleID=$_GET['moduleID'];
// Connect to your database
$dbconnect = mysql_pconnect($server, $dbusername, $dbpassword);
$dbselect = mysql_select_db("epiz_24743320_testData",$dbconnect);
// Prepare the SQL statement
$sql = "INSERT INTO simData2 (moduleID) VALUES ('$moduleID')";
// Execute SQL statement
mysql_query($sql);
mysql_close();
?>
Here is the section of my arduino code for the http connect:
void httpConnect() {
myGsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""); // Set type of internet connection to GPRS context
delay(1000);
Serial.println(" setting connection type");
printSerialData();
myGsm.println("AT+SAPBR=3,1,\"APN\",\"WWW.vodafone.net.nz\""); // Set access point name
delay(1000);
printSerialData();
myGsm.println("AT+SAPBR=1,1"); // Enable GPRS connection
delay(1000);
printSerialData();
myGsm.println("AT+SAPBR=2,1"); // To check connection status
delay(5000);
printSerialData();
myGsm.println("AT+HTTPINIT"); // Initialize HTTP
delay(500);
printSerialData();
myGsm.println("AT+HTTPPARA=\"CID\",1"); // End the PARA ???
delay(500);
printSerialData();
myGsm.print("AT+HTTPPARA=\"URL\",\"mysite.epizy.com/send_data.php?sen69=69\""); // Send PARA command, set url to send data
delay(2000);
printSerialData();
delay(2000);
printSerialData();
myGsm.println(""); // close url
Serial.println("");
delay(500);
printSerialData();
delay(500);
myGsm.println("AT+HTTPACTION=0"); //HTTP method 0-get 1-post 2-head
delay(1000);
printSerialData();
delay(1000);
printSerialData();
delay(2000);
printSerialData();
delay(2000);
printSerialData();
delay(2000);
printSerialData();
myGsm.println("AT+HTTPREAD");
delay(2000);
printSerialData();
delay(2000);
printSerialData();
delay(2000);
printSerialData();
myGsm.println("AT+HTTPTERM");
delay(100);
printSerialData();
}
If anyone can help shed light on why the SIM900 module is not working to activate my .php at all any help would be so greatly appreciated.
Cheers