我正在尝试使用Arduino 和 Ethernet shield访问我的服务器中的PHP文件。此文件捕获 URL 参数“传感器”和“值”并将读取的数据存储到数据库中。
这是我的代码:
#include <SPI.h>
#include <Ethernet.h>
EthernetClient client;
byte MACaddress[] = {0xDE,0xAD,0xBE,0xEF,0xFE,0xED};
byte IPaddress[] = {10,0,0,178};
byte DNSserverIPaddress[] = {4,4,4,4};
byte gatewayIPaddress[] = { 10, 0, 0, 100 };
byte subnetMask[] = { 255, 255, 255, 0 };
char serverName[] = "log.server.com";
void setup() {
Serial.begin(9600);
Ethernet.begin(MACaddress, IPaddress, DNSserverIPaddress, gatewayIPaddress, subnetMask);
}
void loop()
{
delay (5000);
Serial.println("connecting to server...");
client.connect(serverName, 80);
Serial.println("making HTTP request...");
client.println("GET /logger.php?sensor=temp&value=19 HTTP/1.1");
client.println("HOST: log.server.com");
client.println();
}
将此代码上传到我的Arduino Mega + Ethernet shield 后,我的数据库中没有任何变化......
怎么了?