arduino+w5100+php服务器 w5100无法访问到服务器
本帖最后由 万圭 于 2018-2-25 15:21 编辑arduino需要向服务器传输数据,如果直接在浏览器输入http://1.doormonitor.applinzi.com/downup.php?token=********&data=22,可以成功访问服务器,并修改数据库,可是通过arduino端的代码,无法访问到服务器(如果访问该地址成功,我的log文件中会有记录,可是arduino运行中log文件中没有记录,并且数据库值也没有改变),(既然能通过浏览器访问成功,说明服务器端的代码没有问题,有问题的应该是arduino端)求解,arduino端代码如下:
#include <SPI.h>
#include <Ethernet.h>
#define sen 9
char c;
char state = "0";
byte mac[] = {
0xDE,0XAD,0XBE,0XEF,0XFE,0XED
};
IPAddress ip(192,168,2,177);
IPAddress myDns(192,168,2,104);
EthernetClient client;
char server[] = "http://1.doormonitor.applinzi.com";
int sensrdata = 11;
unsigned long lastConnectionTime = 0;
boolean lastConnected = false;
const unsigned long postingInterval = 200*1000;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000);
Ethernet.begin(mac,ip,myDns);
Serial.println(Ethernet.localIP());
pinMode(sen,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//if(sensrdata != digitalRead(sen)){
//sensrdata = digitalRead(sen);
char c;
while(client.available()) {
c = client.read();
Serial.println(c);
}
if (!client.connected()&&lastConnected){
Serial.println("disconnecting 2.");
client.stop();
}
if(!client.connected()&&(millis() - lastConnectionTime > postingInterval)){
if(client.connect(server,8080)){
client.stop();
Serial.println("start");
client.print("GET /downup.php?token=********&data=");
client.print(sensrdata);
client.println("HTTP/1.1");
client.println("Host: 1.doormonitor.applinzi.com");
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println();
Serial.println("ok");
delay(1000);
lastConnectionTime = millis();
}else{
Serial.println("connection failed");
Serial.println("disconnecting 1.");
client.stop();
}
//}
lastConnected = client.connected();
}
}求解答!万分感谢!!!
求帮助:sleepy:。。。。。 我也遇到类似的问题,求帮助。 "http://1.doormonitor.applinzi.com";
把http:// 去掉试试
页:
[1]