我正在做一个项目,在那里我会发送两个变量到我的网站,我的网站将接收和显示它。
项目信息: Arduino + SIM900 + PHP (向网站发送数据)
我有将AT命令发送到我的SIM900并显示其回复的代码。
我的问题是,当我在Serial中运行代码时,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=2\r");
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+HTTPINIT\r");
delay(1000);
toSerial();
GPRS.println("AT+HTTPPARA=\"CID\",1\r");
delay(1000);
toSerial();
GPRS.println("AT+HTTPPARA=\"URL\",\"aclc-onlineparkingtracker.000webhostapp.com/?id=1&sts=0\r"); <--- HERE
delay(10000);
toSerial();
GPRS.println("AT+HTTPACTION=0\r");
delay(7000);
toSerial();
GPRS.println("AT+HTTPTERM\r");
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我尝试了什么:
SoftwareSerial.h和HardwareSerial.h)。没起作用。发布于 2018-02-05 12:26:32
更新:
我改变了这句话:
GPRS.println("AT+HTTPPARA=\"URL\",\"aclc-onlineparkingtracker.000webhostapp.com/?id=1&sts=0\r");至
GPRS.println("AT+HTTPPARA=\"URL\",\"aclc-onlineparkingtracker.000webhostapp.com/?id=1&st=1\"");我删除了\r,并在URL末尾添加了\"。
https://stackoverflow.com/questions/48615808
复制相似问题