0

I am using SIM800c gsm module to send data to php server

These are the commands i am trying to send data

AT
AT+CPIN?
AT+CREG?
AT+CGATT?
AT+CSQ
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","airtelgprs.com"
AT+SAPBR=1,1
AT+SAPBR=2,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://axxxxxxxxxx.000webhostapp.com/conn.php"
AT+HTTPPARA="CONTENT","application/json"
AT+HTTPDATA=14,20000
{"name":"abc"}
AT+HTTPACTION=1
AT+HTTPREAD
AT+HTTPTERM 
AT+SAPBR=0,1 

And my php code is:

<?php
$servername = "localhost";
$username = "xxxxxx";
$password = "xxxxxxx";
$dbname = "xxxxxxxxx";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} else{

}

$name=$_POST['data'];
$sql = "INSERT INTO info (inform)
VALUES ('$name')";

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

$conn->close();


?>   

When i am using these codes to send data, I can find a entry in my php server but no data abc is not visible.

I have tried GET method to send data where i put my data in the url

like this:

AT+HTTPPARA="URL","http://axxxxxxxxx.000webhostapp.com/conn.php?data=abc"

Using GET method shows the data perfectly.

Any ideas how to send it using POST????

Any help will be appreciated.

Thanks in advance

4

2 回答 2

0

at+sapbr=3,1,"Contype","GPRS";

OK at+sapbr=3,1,"APN","internet"

OK at+sapbr=1,1

确定在+sapbr=2,1

+SAPBR: 1,1,"ip"

好的

在+httpinit

好的

at+httppara="CONTENT","text/plain; charset=UTF-8"

好的

at+httppara="CID",1

好的

at+httppara="URL","http://你的网址"

好的

at+httpaction=0";

OK +HTTPACTION: 0,200,20

这对我有用

于 2022-03-02T09:43:40.203 回答
0

我认为你应该有AT+HTTPACTION=1而不是AT+HTTPACTION=0

并且有

AT+HTTPPARA="CONTENT","application/json" 
AT+HTTPDATA=14,10000

然后

{"name":"abc"}
于 2018-07-09T18:00:24.177 回答