我正在建立一个气象站,通过GET请求将数据发送到网络服务器。我想知道你们是否可以查看我的代码并帮助我。我浏览了整个互联网,找不到什么问题。我正在使用arduino mega,arduino / telefonica gsm盾牌和EE SIM卡。非常感谢你!
#include <GSM.h>
GSM gsmAccess;
GPRS gprs;
GSMClient client;
const boolean gprsCheck = true;
char server[] = "";
int value = 112358132134;
void setup(){
Serial.begin(19200);
if(gprsCheck) {
boolean notCon = true;
Serial.println("Establishing connection...");
while(notCon) {
if((gsmAccess.begin("") == GSM_READY) & (gprs.attachGPRS("everywhere","eesecure","secure") == GPRS_READY)) {
notCon = false;
Serial.println("GPRS connection successful.");
Serial.println("");
}
else {
Serial.println("GPRS connection failed. Trying again.");
Serial.println("");
delay(1000);
}
}
}
if(!client.available() && !client.connected()) {
client.stop();
}
if (client.connect(server, 80)) {
Serial.println("Connection successful.");
client.print( "GET /add.php?");
client.print("value=");
client.print(value);
client.print(" HTTP/1.1\n");
client.print("Host: ");
client.print(server);
client.print("\nConnection: close\n\n");
client.stop();
client.stop();
Serial.println("Data sent.");
}
else {
Serial.println("Error.");
}
}
void loop() {
}