//magikh0e.ihtb.org #include #include byte mac[] = { 0xDA, 0xRP, 0xA0, 0xR0, 0xCK, 0xSS }; byte ip[] = { 1, 2, 3, 4 }; // IP Address byte gateway[] = { 1, 2, 3, 1 }; // Default Gateway byte subnet[] = { 255, 255, 255, 0 }; // Netmask EthernetServer server(80); String readString; void setup(){ pinMode(6, OUTPUT); Ethernet.begin(mac, ip, gateway, gateway, subnet); server.begin(); Serial.begin(9600); Serial.println("TCP/IP Power Controller - v1.5"); Serial.println("By: magik"); sensors.begin(); // set the resolution to 10 bit (good enough?) sensors.setResolution(insideThermometer, 10); sensors.setResolution(outsideThermometer, 10); } void printTemperature(DeviceAddress deviceAddress) { float tempC = sensors.getTempC(deviceAddress); if (tempC == -127.00) { Serial.print("Error getting temperature"); } else { Serial.print("C: "); Serial.print(tempC); Serial.print(" F: "); Serial.print(DallasTemperature::toFahrenheit(tempC)); } } void loop(){ EthernetClient client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read(); //read char by char HTTP request if (readString.length() < 100) { //store characters to string readString += c; //Serial.print(c); } if (c == '\n') { Serial.println(readString); //print to serial monitor for debuging client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); client.println(""); client.println(""); client.println("Light Controller - By: magik"); client.println(""); client.println(""); client.println("

TCP/IP Power Controller

"); client.print("Socket 1
"); client.print(""); client.print(""); // ALL OFF - client.print(" "); client.print("
Socket 2
"); client.print("Socket 3
"); client.print("Socket 4
"); client.print("

Temperature(s):
"); client.print("Outside: "); client.print("
Inside: "); client.print("Weather Status: Not Connected
"); client.print("Humidity: Not Connected
"); client.print("GPRS Status: Not Connected
"); client.println(""); client.println(""); delay(1); client.stop(); if(readString.indexOf('Light_1_ON') >0) { digitalWrite(6, HIGH); Serial.println("Light On"); } if(readString.indexOf('Light_1_OFF') >0) { digitalWrite(6, LOW); Serial.println("Light Off"); } readString=""; } } } } }