Zur Steuerung meiner Rolladen habe ich mir eine Schaltung einfallen lassen die über das Netzwerk möglich ist und somit in den FHEM integriert werden kann.
Damit können die Rollos von 4 Fenstern unabhängig von einander gesteuert werden.
Aktive Komponenten:
- Arduino Nano
- Replaiskarte 8 Port – 5V
- LanModul ENC28J60
- Spannungswandler auf 3.3V
- Schaltnetzteil auf 5V
Hier der aufbau der Schaltung:

Das Sketch für den Arduino:
/*
ENC28J60 Anschluss:
SCK -> 13
SO -> 12
SI -> 11
CS -> 8
Vcc -> 3.3 V
GND -> GND
*/
#include <EtherCard.h>
#define REQUEST_RATE 5000
#include <string.h>
static byte mymac[] = { 0x75,0x68,0x69,0x2E,0x31,0x33 };
char* on = "ON";
char* off = "OFF";
const int led = 15;
int pinAnz=8;
int pin[8]={2,3,4,5,6,7,9,10};
int offTimer=0;
int offTimerStart=0;
String switchNr;
String state;
int stateRollo1=9;
int stateRollo2=9;
int stateRollo3=9;
int stateRollo4=9;
BufferFiller bfill;
byte Ethernet::buffer[700];
void setup () {
Serial.begin(9600);
Serial.println("Getting IP via DHCP");
for (int i=0; i < pinAnz; i++){
pinMode(pin[i], OUTPUT); //alle Pins aus dem Array als Ausgabe deklarieren
relaisOff(); //alle Pins aus dem Array einschalten
Serial.println(pin[i]);
}
if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
ether.printIp("My IP: ", ether.myip);
// ether.printIp("Netmask: ", ether.mymask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);
Serial.println();
/* pinMode(RELAY_PIN, OUTPUT);
digitalWrite(RELAY_PIN, LOW);
relayStatus = false;
relayLabel = off;
linkLabel = on;*/
}
void loop () {
if (offTimerStart==1){
offTimer=offTimer-1;
Serial.println(offTimer);
if(offTimer==0){
relaisOff();
offTimerStart=0;
}
}
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(pos) {
String puffer = (char *)Ethernet::buffer + pos;
//http://192.168.11.160/?switch1;1 Hoch
//http://192.168.11.160/?switch1;0 runter
//http://192.168.11.160/?switch1;3 Stop
Serial.println(puffer);
if (puffer.startsWith("GET /?switch")){
puffer.remove(15);
switchNr=puffer.substring(12,13);
state=puffer.substring(14,15);
Serial.println(switchNr);
Serial.println(state);
//zeit setzen zum ausschalten der Strom Relais, Schleife, wenn 0 aus
offTimerStart=1;
offTimer=6000; //Zeit auf des Rollo mit der laengsten hoch/runterfahrzeit einstellen
// Rollo bewegen: hoch=1; runter=0
switch (switchNr.toInt()) {
case 1: //Rollo 1
if (state!="3"){
digitalWrite(pin[0], LOW); //Strom ein
digitalWrite(pin[1], !state.toInt()); // Hoch/runter
//Serial.println(pin[2] & !state);
}
else{
digitalWrite(pin[0], HIGH);
}
stateRollo1 = state.toInt();
break;
case 2: //Rollo 2
if (state!="3"){
digitalWrite(pin[2], LOW); //Strom ein
digitalWrite(pin[3], !state.toInt()); // Hoch/runter
//Serial.println(pin[2] & !state);
}
else{
digitalWrite(pin[2], HIGH);
}
stateRollo2 = state.toInt();
break;
case 3: //Rollo 3
if (state!="3"){
digitalWrite(pin[4], LOW); //Strom ein
digitalWrite(pin[5], !state.toInt()); // Hoch/runter
//Serial.println(pin[2] & !state);
}
else{
digitalWrite(pin[4], HIGH);
}
stateRollo3 = state.toInt();
break;
case 4: //Rollo 4
if (state!="3"){
digitalWrite(pin[6], LOW); //Strom ein
digitalWrite(pin[7], !state.toInt()); // Hoch/runter
//Serial.println(pin[2] & !state);
}
else{
digitalWrite(pin[6], HIGH);
}
stateRollo4 = state.toInt();
break;
default:
break;
}
}
bfill = ether.tcpOffset();
bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><head><meta name='viewport' content='width=200px'/></head><body>"
//"
<div style='position:absolute;width:200px;height:200px;top:50%;left:50%;margin:-100px 0 0 -100px'>"
"
<div style='text-align:center'>"
"Rollo1:$D <a href='/?switch1;1'>hoch</a> <a href='/?switch1;0'>runter</a> <a href='/?switch1;3'>Stop</a>
"
"Rollo2:$D <a href='/?switch2;1'>hoch</a> <a href='/?switch2;0'>runter</a> <a href='/?switch2;3'>Stop</a>
"
"Rollo3:$D <a href='/?switch3;1'>hoch</a> <a href='/?switch3;0'>runter</a> <a href='/?switch3;3'>Stop</a>
"
"Rollo4:$D <a href='/?switch4;1'>hoch</a> <a href='/?switch4;0'>runter</a> <a href='/?switch4;3'>Stop</a>
"
"</div>
</div>
</body></html>"
), stateRollo1,stateRollo2,stateRollo3,stateRollo4);
ether.httpServerReply(bfill.position());
}
}
void relaisOff() {
for (int i=0; i < pinAnz; i++){
digitalWrite(pin[i], HIGH); //alle Pins aus dem Array einschalten
}
}
Anschlussschema an den Rollomotor:

FHEM Integration:
define webRollos HTTPMOD none 0 attr webRollos userattr get01Name get01URL get1Name reading01Name reading01Regex readingFormat readingMap set01IMap set01Name set01ParseResponse:0,1 set01URL set02IMap set02Name set02URL setIMap attr webRollos alias Rollos attr webRollos devStateIcon 0:fts_shutter_100 attr webRollos enableControlSet 0 attr webRollos get01Name rollost1 attr webRollos get01URL http://192.168.1.13/?status attr webRollos reading01Name RolloStat1 attr webRollos reading01Regex Rollo1[^0-9]+([0-9\.]+) attr webRollos readingMap 0:oben, 1:unten, 3:Stop, 9:Unbekannt attr webRollos room Rollos attr webRollos set01IMap 0:on, 1:off, 3:stop attr webRollos set01Name dy_Rollos1 attr webRollos set01URL http://192.168.1.13/?switch1;;$val attr webRollos set02Name Rollow2 attr webRollos set02URL http://192.168.1.13/?switch2;;$val attr webRollos stateFormat RolloStat1




Schreibe einen Kommentar