我在将数据从SIM800C发送到网站时遇到问题。
第一个问题是,我将以下代码上传到Arduino(我使用Arduino IDE中的串行监视器将AT命令发送到SIM800并阅读响应)。
#include <SoftwareSerial.h>
#define TX 10
#define RX 11
#define t 2000
SoftwareSerial mySerial(RX, TX);
int k=0, aS=0, amS=0;
void setup() {
Serial.begin(9600);
while(!Serial); // Wait for Serial ready
Serial.println("Intalizing...");
mySerial.begin(9600);
delay(5000);
mySerial.println("AT"); // Send the first AT command to auto set baud rate
delay(1000);
Serial.println("You can type AT command and send to SIM800 by using Serial Monitor");
}
void loop() {
k=0;
aS=Serial.available(); // aS: The number of bytes available to read from the buff of Serial
amS=mySerial.available(); // amS: The number of bytes available to read from the buff of mySerial
while(aS>0) {
mySerial.write(Serial.read());
k=1; aS--;
}
if (k==1) {
mySerial.println();
}
while (amS>0) {
Serial.write(mySerial.read());
k=2; amS--;
}
delay(1000);
}
下一步,我逐个发送下面的AT命令并查看回复。所有AT命令和响应都可以在串行监视器上看到。
AT+SAPBR=3,1,"Contype","GPRS"
AT+SAPBR=3,1,"APN","m3-world"
AT+SAPBR=3,1,"USER","mms"
AT+SAPBR=3,1,"PWD","mms"
AT+CSTT="m3-world","mms","mms"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://weatherstation.byethost3.com/"
AT+HTTPDATA=9,10000
value=YOU
AT+HTTPACTION=1
下面的最后一个响应显示数据(值= YOU)已成功发送。
OK
++HTTPACTION:1,200,839
我创建了a website来使用GET方法读取数据。 我的问题在网站上没有任何变化。这意味着该网站尚未读取SIM800发送的数据。
答案 0 :(得分:-1)
您的示例是发送POST请求。如果您希望发送带有名称/值对的GET请求,则其结构应该略有不同。从上面改变你的例子:
AT+SAPBR=3,1,"CONTYPE","GPRS"
AT+SAPBR=3,1,"APN","m3-world"
AT+SAPBR=3,1,"USER","mms"
AT+SAPBR=3,1,"PWD","mms"
AT+SAPBR=1,1
AT+HTTPINIT
AT+HTTPPARA="CID",1
AT+HTTPPARA="URL","http://weatherstation.byethost3.com/?value=YOU"
AT+HTTPACTION=0
请注意,名称/值对现在位于网址中,AT+HTTPACTION=1
更改为AT+HTTPACTION=0
以表示GET而不是POST