// Enter a MAC address for your controller below. // Newer Ethernet shields have a MAC address printed on a sticker on the shield byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress server(192.168.1.101); EthernetClient client; voidsetup() { // start the Ethernet connection: if (Ethernet.begin(mac) == 0) { //Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: for(;;) ; } // give the Ethernet shield a second to initialize: delay(1000); } voidloop() { int n = analogRead(A0); //读取A0口的电压值 float temp = ((5/1024)*in)/0.01//计算温度 char buffer[25]; String tempStr = floatToString(buffer,temp,2); //arduino比较变态的的类型转换 if (client.connect(server, 8080)) { client.println("GET /sendTempData.htm?key=securityKey&tempNum="+tempStr); client.println(); } delay(1000); client.stop(); delay(1800000); //半小时采集一次 }