Steuerung Außenbeleuchtung
Projektinformation
LSTF_Wlan1
- Erstellt am 8. Juli 2013
- By db4bd
- info@hholthaus.de
LSTF_Wlan1
Steuerung der Außenbeleuchtung meines Hauses mit Iphone per Wlan
Beschreibung
Projekt Außenbeleuchtung
Für das Projekt Außenbeleuchtung meines Hauses habe ich jetzt einen Arduino Mega mit Ethernetshield eingesetzt. Ich hatte im Frühjahr Teile der Außenanlagen erneuert, und im Zuge dessen auch einige Dinge neu verkabelt. Da ich schon länger mit den Arduinos herum bastel, habe ich mich zu einem konkreten Einsatz entschlossen. Die Steuerung besteht also aus einem Arduino Mega, Ethernetshield und einer 4-fach Relaiskarte. Der Rest ist konventionelle E-Technik.
Mit Hilfe der NetIO App auf meinem IPhone kann ich jetzt die Leuchten steuern, und zwar sowohl zu Hause über W-Lan, als auch über das Internet von unterwegs. In Zukunft soll auch noch die Steuerung von Funksteckdosen realisiert werden.Die Steuerung der Funksteckdosen ist jetzt auch eingebaut, läuft gut.
Das passende Arduino Programm
Für das Projekt Außenbeleuchtung meines Hauses habe ich jetzt einen Arduino Mega mit Ethernetshield eingesetzt. Ich hatte im Frühjahr Teile der Außenanlagen erneuert, und im Zuge dessen auch einige Dinge neu verkabelt. Da ich schon länger mit den Arduinos herum bastel, habe ich mich zu einem konkreten Einsatz entschlossen. Die Steuerung besteht also aus einem Arduino Mega, Ethernetshield und einer 4-fach Relaiskarte. Der Rest ist konventionelle E-Technik.
Mit Hilfe der NetIO App auf meinem IPhone kann ich jetzt die Leuchten steuern, und zwar sowohl zu Hause über W-Lan, als auch über das Internet von unterwegs. In Zukunft soll auch noch die Steuerung von Funksteckdosen realisiert werden.Die Steuerung der Funksteckdosen ist jetzt auch eingebaut, läuft gut.
Das passende Arduino Programm
/* IDE Version 1.01 Arduino Mega2560 Arduino Ethernet Shield with Wiznet W5100 Ethernet chip Dieser Sketch wurde von mir auf meine Konfiguration angepasst, das Orginal ist von der Webseite http://netio.davideickhoff.de/ */ // include library #include <SPI.h> #include <Ethernet.h> #include <RCSwitch.h> // end include library //global variable RCSwitch mySwitch = RCSwitch(); byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // mac address of Ethernet shield byte server[] = { 192, 168, xx, xx}; //----- iPad Remote ------- #define BUFSIZ 64 EthernetServer iPadServer(xxxx); // server port number of Ethernet shield int Led30 = 30; int Led32 = 32; int Led34 = 34; int Led36 = 36; int Led30status = 1; int Led32status = 1; int Led34status = 1; int Led36status = 1; //--------------------------- // setup void setup(){ Serial.begin(9600); //for debug if(Ethernet.begin(mac) == 0) { //opening the Ethernet connection Serial.println("Failed the Eth-Connection!"); while(1) { // Eth-connection could not be established, cannot go on in code! ; } } // Now we want to print the IP addresse Serial.print("IP addresse is: "); for (byte ipbyte = 0; ipbyte < 4; ipbyte = ipbyte + 1) { Serial.print(Ethernet.localIP()[ipbyte], DEC); Serial.print("."); } Serial.println(); iPadServer.begin(); // start the server pinMode(Led30, OUTPUT); pinMode(Led32, OUTPUT); pinMode(Led34, OUTPUT); pinMode(Led36, OUTPUT); digitalWrite(Led30, HIGH); digitalWrite(Led32, HIGH); digitalWrite(Led34, HIGH); digitalWrite(Led36, HIGH); mySwitch.enableTransmit(7); } // end setup // main loop void loop() { iPadInterface(); } // end main loop void iPadInterface() { int index = 0; char Remote[BUFSIZ]; EthernetClient client = iPadServer.available(); if (client) { if (client.connected()) { while (client.available()) { char c = client.read(); //Serial.print(c); // print to the screen if (c != '\n' && c != '\r') { // no linefeed or CR so keep reading Remote[index] = c; index++; if (index >= BUFSIZ) index = BUFSIZ -1; continue; } Remote[index] = '\0'; } Serial.println(Remote); // print string sent from iPhone if (strstr(Remote, "Local")) { // initialsend client.println("OK"); } if (strstr(Remote, "LED30 on")) { // set the LED30 client.println("OK"); digitalWrite(Led30, HIGH); // turn the LED30 on (HIGH is the voltage level) Led30status = 1; } if (strstr(Remote, "LED30 off")) { // set the LED30 client.println("OK"); digitalWrite(Led30, LOW); // turn the LED30 off (LOW is the voltage level) Led30status = 0; } if (strstr(Remote, "LED32 status")) { // set the LED12 switch according the Status client.println(Led32status); // answer with the onText } if (strstr(Remote, "LED32 on")) { // set the LED32 client.println("OK"); digitalWrite(Led32, HIGH); // turn the LED32 on (HIGH is the voltage level) Led32status = 1; } if (strstr(Remote, "LED32 off")) { // set the LED32 client.println("OK"); digitalWrite(Led32, LOW); // turn the LED32 off (LOW is the voltage level) Led32status = 0; } if (strstr(Remote, "LED34 status")) { // set the LED34 switch according the Status client.println(Led34status); // answer with the onText } if (strstr(Remote, "LED34 on")) { // set the LED34 on client.println("OK"); digitalWrite(Led34, HIGH); // turn the LED9 on (HIGH is the voltage level) Led34status = 1; } if (strstr(Remote, "LED34 off")) { // set the LED34 on client.println("OK"); digitalWrite(Led34, LOW); // turn the LED34 off (LOW is the voltage level) Led34status = 0; } if (strstr(Remote, "LED36 on")) { // set the LED36 on client.println("OK"); digitalWrite(Led36, HIGH); Led36status = 1; } if (strstr(Remote, "LED36 off")) { // set the LED36 client.println("OK"); digitalWrite(Led36, LOW); // turn the LED36 off (LOW is the voltage level) Led36status = 0; } if (strstr(Remote, "FUNK1 on")) { // set the Funk1 on client.println("OK"); mySwitch.switchOn("10000", "10000"); // turn the Funk1 on } if (strstr(Remote, "FUNK1 off")) { // set the Funk1 0ff client.println("OK"); mySwitch.switchOff("10000", "10000"); // turn the Funk1 off } if (strstr(Remote, "FUNK2 on")) { // set the Funk2 on client.println("OK"); mySwitch.switchOn("10000", "01000"); // turn the Funk2 on } if (strstr(Remote, "FUNK2 off")) { // set the Funk2 0ff client.println("OK"); mySwitch.switchOff("10000", "01000"); // turn the Funk2 off } if (strstr(Remote, "FUNK3 on")) { // set the Funk3 on client.println("OK"); mySwitch.switchOn("10000", "00100"); // turn the Funk3 on } if (strstr(Remote, "FUNK3 off")) { // set the Funk3 0ff client.println("OK"); mySwitch.switchOff("10000", "00100"); // turn the Funk3 off } if (strstr(Remote, "FUNK4 on")) { // set the Funk4 on client.println("OK"); mySwitch.switchOn("10000", "00010"); // turn the Funk4 on } if (strstr(Remote, "FUNK4 off")) { // set the Funk4 0ff client.println("OK"); mySwitch.switchOff("10000", "00010"); // turn the Funk4 off } if (strstr(Remote, "FUNKa on")) { // set the Funka on client.println("OK"); mySwitch.switchOn("01000", "10000"); // turn the Funka on } if (strstr(Remote, "FUNKa off")) { // set the Funka 0ff client.println("OK"); mySwitch.switchOff("01000", "10000"); // turn the Funka off } if (strstr(Remote, "FUNKb on")) { // set the Funkb on client.println("OK"); mySwitch.switchOn("01000", "01000"); // turn the Funkb on } if (strstr(Remote, "FUNKb off")) { // set the Funkb 0ff client.println("OK"); mySwitch.switchOff("01000", "01000"); // turn the Funkb off } if (strstr(Remote, "FUNKc on")) { // set the Funkc on client.println("OK"); mySwitch.switchOn("01000", "00100"); // turn the Funkc on } if (strstr(Remote, "FUNKc off")) { // set the Funkc off client.println("OK"); mySwitch.switchOff("01000", "00100"); // turn the Funkc off } if (strstr(Remote, "FUNKd on")) { // set the Funkd on client.println("OK"); mySwitch.switchOn("01000", "00010"); // turn the Funkd on } if (strstr(Remote, "FUNKd off")) { // set the Funkd 0ff client.println("OK"); mySwitch.switchOff("01000", "00010"); // turn the Funkd off } } //----- End of if client.connected } //------- End of if client } //--------- End of iPadInterface()