无法使用Arduino + A6 gsm模块将新数据插入MYSQL

时间:2018-03-09 00:20:28

标签: php mysql arduino gsm

我尝试将新数据插入MYSQL数据库,但没有任何反应。所有GSM模块AT命令响应OK,最后一个GSM响应 HTTP / 1.1 200 OK 。但是当我去检查我的数据库时,我发现没有新的数据。对此问题的任何建议?

这是我使用的PHP代码:

<?php

$servername = "xxxxxxxx-mysql.services.clever-cloud.com";
$username = "xxxxxxxx";
$password = "xxxxxxxx";
$dbname = "xxxxxxxx";

$nr= $POST["i"];
$rk= $POST["r"];

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";

$sql = "INSERT INTO test(id, value)
VALUES ($nr,$rk)";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();


?>

这是我使用Arduino代码:

void setup() {

 A6Module.begin(115200);
 delay(5000);

 A6Module.println("AT");
 delay(3000);

 A6Module.println("AT+CIPSHUT");
 delay(3000);

 A6Module.println("AT+CIPMUX=0");
 delay(3000);

 A6Module.println("AT+CGATT=1");
 delay(3000);

 A6Module.println("AT+CSTT=\"internet\",\"\",\"\"");
 delay(3000);

 A6Module.println("AT+CIICR");
 delay(3000);

 A6Module.println("AT+CIFSR");
 delay(3000); 

 A6Module.println("AT+CIPSTART=\"TCP\",\"www.xxxxx.epizy.com\", 80");
 delay(3000);

 A6Module.println("AT+CIPSEND");
 delay(3000);

 A6Module.println("POST /send.php? HTTP/1.1");  //start msg
 delay(3000);

 A6Module.println("Host: www.xxxxx.epizy.com");
 delay(2000);

 A6Module.println("Content-Type: application/x-www-form-urlencoded");
 delay(500);

 A6Module.println("Content-Length: 25\r\n");
 delay(500);

 A6Module.println("i=69&r=69");
 delay(2000);

 A6Module.write(0x1A); //end msg
 delay(20000);

}

0 个答案:

没有答案