Php 如何将数据从SIM900 HTTP GET发送到mySQL数据库(75%?)

Php 如何将数据从SIM900 HTTP GET发送到mySQL数据库(75%?),php,mysql,arduino,sim900,Php,Mysql,Arduino,Sim900,感谢您抽出时间阅读我的帖子。我会尽量涵盖我认为是重要的问题,但我不是一个专业的编码器,所以请容忍我 我有一个带有Arduino Mega的SIM900模块,我正在尝试使用http get函数将数据发送到mySQL数据库。我已经成功地使用SIM900在我的.ftp服务器中创建了文本文件,所以我知道它在某种程度上是有效的,只是http功能不起作用。我有一个.php脚本,当我通过浏览器使用它时,它运行良好(例如,访问“mysite.epizy.com/senddata.php?sensor69=69”

感谢您抽出时间阅读我的帖子。我会尽量涵盖我认为是重要的问题,但我不是一个专业的编码器,所以请容忍我

我有一个带有Arduino Mega的SIM900模块,我正在尝试使用http get函数将数据发送到mySQL数据库。我已经成功地使用SIM900在我的.ftp服务器中创建了文本文件,所以我知道它在某种程度上是有效的,只是http功能不起作用。我有一个.php脚本,当我通过浏览器使用它时,它运行良好(例如,访问“mysite.epizy.com/senddata.php?sensor69=69”将在浏览器中返回:

阵列([sensor69]=>69[_测试]=>dfc33491ff131abef9348da81e436528[_ga]=>GA1.2.428043981.157293465)

当我尝试连接SIM900时,我的串行端口上显示以下内容:

    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
如果有人能帮助解释为什么SIM900模块根本无法激活my.php,我们将不胜感激


干杯

我已经解决了这个问题。事实证明,我使用的服务器(epizy.com(infinity free))需要SIM900所没有的javascript功能(至少在我当前的设置中)。
我已经用heroku创建了一个新服务器,使用了几乎相同的.php文件(数据库是postgreSQL而不是mySQL,所以做了一些小调整)现在,我已经成功地按照我的要求将数据发送到数据库中。我仍然没有解决截断串行响应问题,但这对于我所追求的功能来说不是必需的。

它不仅看起来被截断了,而且与PHP代码应该返回的内容完全不同-我没有看到任何
函数toNumbers(d)…
在那里。我首先检查运行PHP的web服务器的访问和错误日志,看看这些请求是什么样子的。实际上,这些脚本似乎来自某种“机器人检测”功能,警告:
mysql\uU*
扩展从PHP 5.5.0开始就被弃用,从PHP 7.0.0开始就被删除。相反,应该使用或扩展。选择mysql API时,请参阅以获取更多帮助。
<?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();

?>
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();     

}