我正在进行一个项目,我将两个变量发送到我的网站,我的网站将接收并显示它。
项目信息:Arduino SIM900 PHP(将数据发送到网站(
我的代码在命令上发送到我的SIM900并显示其答复。
我的问题是,当我在串行监视器中运行代码时,似乎URL上的最后一个引号未发送/打印到我的SIM900。
这是我的代码:
#include <SoftwareSerial.h>
SoftwareSerial GPRS(5, 6);
long duration;
int distance;
const int trigPin = 10;
const int echoPin = 11;
void setup() {
powerUp();
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
GPRS.begin(19200);
Serial.begin(19200);
Serial.println("Con");
delay(2000);
Serial.println("Done!...");
GPRS.flush();
Serial.flush();
// See if the SIM900 is ready
GPRS.println("AT");
delay(1000);
toSerial();
GPRS.print("at+cmee=2r");
toSerial();
// SIM card inserted and unlocked?
GPRS.println("AT+CPIN?");
delay(1000);
toSerial();
// Is the SIM card registered?
GPRS.println("AT+CREG?");
delay(1000);
toSerial();
// Is GPRS attached?
GPRS.println("AT+CGATT?");
delay(1000);
toSerial();
// Check signal strength
GPRS.println("AT+CSQ ");
delay(1000);
toSerial();
// Set connection type to GPRS
GPRS.println("AT+SAPBR=3,1,"Contype","GPRS"");
delay(2000);
toSerial();
// Set the APN
GPRS.println("AT+SAPBR=3,1,"APN","internet"");
delay(2000);
toSerial();
// Enable GPRS
GPRS.println("AT+SAPBR=1,1");
delay(10000);
toSerial();
// Check to see if connection is correct and get your IP address
GPRS.println("AT+SAPBR=2,1");
delay(2000);
toSerial();
}
void loop() {
delay(10000);
sensor();
GPRS.println("AT+HTTPINITr");
delay(1000);
toSerial();
GPRS.println("AT+HTTPPARA="CID",1r");
delay(1000);
toSerial();
GPRS.println("AT+HTTPPARA="URL","aclc-onlineparkingtracker.000webhostapp.com/?id=1&sts=0r"); <--- HERE
delay(10000);
toSerial();
GPRS.println("AT+HTTPACTION=0r");
delay(7000);
toSerial();
GPRS.println("AT+HTTPTERMr");
toSerial();
}
void toSerial() {
while(GPRS.available()!=0) {
Serial.write(GPRS.read());
}
}
void powerUp() {
pinMode(9, OUTPUT);
digitalWrite(9, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(2000);
digitalWrite(9,LOW);
delay(3000);
}
这是我的串行显示器中的输出:
Con
Done!...
AT
OK
at+cmee=2
AT+CPIN?
OK
AT+CREG?
+CREG: 0,1
OK
AT+CGATT?
+CGATT: 0
OK
AT+CSQ
+CSQ: 10,0
OK
AT+SAPBR=3,1,"Contype","GPRS"
OK
AT+SAPBR=3,1,"APN","internet"
OK
AT+SAPBR=1,1
OK
AT+SAPBR=2,1
+SAPBR: 1,1,"10.32.133.18"
OK
AT+HTTPINIT
OK
AT+HTTPPARA="CID",1
OK
AT+HTTPPARA="URL","aclc-onlineparkingtracker.000webhostapp.com/?id=1&st=1 <--HERE
+CME ERROR: operation not allowed
我尝试的是:
更改TX&amp;RX至256(
SoftwareSerial.h
和HardwareSerial.h
(。不起作用。添加了延迟。不起作用。
更新:
我更改了这一行:
GPRS.println("AT+HTTPPARA="URL","aclc-onlineparkingtracker.000webhostapp.com/?id=1&sts=0r");
to
GPRS.println("AT+HTTPPARA="URL","aclc-onlineparkingtracker.000webhostapp.com/?id=1&st=1"");
我删除了r
,然后在URL的末尾添加了"
。