我正在尝试将数据从 SIM900 发送到位于 Hostgator.com 的数据库;我有正确的PHP文件,我的Arduino文件似乎也很好。但似乎这些信息没有进入我的数据库。我尝试允许我从"AT+SAPBR=2,1"获得的 IP 地址,但它似乎不起作用。我知道PHP文件是正确的,因为我测试了手动将信息添加到数据库并且它起作用了。
这是Arduino代码:
#include <SoftwareSerial.h>
#include <Wire.h>
SoftwareSerial SIM900(7, 8);
float s1 = 55.44;
float s2 = 66.3;
float s3 = 77.2;
void setup(){
Serial.begin(19200);
SIM900.begin(19200);
delay(3000);
// See if the SIM900 is ready
SIM900.println("AT");
ReceberEFim();
delay(4000);
// SIM card inserted and unlocked?
SIM900.println("AT+CPIN?");
ReceberEFim();
delay(500);
// Is the SIM card registered?
SIM900.println("AT+CREG?");
ReceberEFim();
delay(500);
// Is GPRS attached?
SIM900.println("AT+CGATT?");
ReceberEFim();
delay(500);
// Check signal strength - should be 9 or higher
SIM900.println("AT+CSQ");
ReceberEFim();
delay(500);
// Set connection type to GPRS
SIM900.println("AT+SAPBR=3,1,"Contype","GPRS"");
ReceberEFim();
delay(1000);
// Set the APN - this will depend on your network/service provider
SIM900.println("AT+SAPBR=3,1,"APN","claro.com.br"");
ReceberEFim();
delay(1000);
// Enable GPRS - this will take a moment or two
SIM900.println("AT+SAPBR=1,1");
ReceberEFim();
delay(3000);
SIM900.println("AT+SAPBR=2,1");
ReceberEFim();
delay(500);
SIM900.println("AT+CIFSR");
ReceberEFim();
delay(500);
SIM900.println("AT+HTTPINIT");
ReceberEFim();
delay(2000);
SIM900.print("AT+HTTPPARA="URL","http://myweb.com/conexao.php?");
SIM900.print("s1=");
SIM900.print(s1);
delay(50);
SIM900.print("&s2=");
SIM900.print(s2);
delay(50);
SIM900.print("&s3=");
SIM900.print(s3);
delay(50);
SIM900.println(""rn"); //Fechar URL
ReceberEFim();
delay(5000);
SIM900.println("nAT+HTTPPARA="CID",1");
ReceberEFim();
delay(500);
SIM900.println("AT+HTTPACTION=0");
ReceberEFim();
delay(500);
SIM900.println("AT+HTTPTERM");
ReceberEFim();
SIM900.println("AT+SAPBR=0,1");
ReceberEFim();
}
void loop(){
}
void ReceberEFim() {
while (SIM900.available()) {
Serial.write(SIM900.read());
}
}
我刚刚解决了这个问题,实际上,这很简单,问题是我的网站有https,而我正在使用http,要修复它,只需简单地从http更改为https,如下所示:
SIM900.print("AT+HTTPPARA="URL","https://myweb.com/conexao.php?");