Raspberry Pi: 433Mhz Funksteckdosen schalten (binary)

Anschluss:

VCC – 3.3V
GND – GND
DATA – GPIO 24 (intern 5)

Wiring Pi installieren:

sudo apt-get install wiringpi

oder:

wget http://raspberrypiguide.de/stuff/wiringPi-27afc01.tar.gz
tar xfz wiringPi-27afc01.tar.gz
cd wiringPi-27afc01
./build

RC Switch installieren:

git clone https://github.com/sui77/rc-switch.git

Beispielscript (senden-test.cpp)

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup()
{
// Transmitter is connected to Arduino Pin #7
mySwitch.enableTransmit(7);
// Optional set pulse length.
// mySwitch.setPulseLength(439);
// Optional set protocol (default is 1, will work for most outlets)
mySwitch.setProtocol(1);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
}
void loop()
{
mySwitch.send("000101010011011101010101");// Device 1 ON
delay(1000);
mySwitch.send("000101010111010101010100");// Device 1 OFF
delay(1000);
}

int main()
{
  wiringPiSetup ();
  setup();
  for(;;) {
    loop();
  }
}

alternativ (einmalige Ausführung):

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup()
{
// Transmitter is connected to Arduino Pin #7
mySwitch.enableTransmit(5);
// Optional set pulse length.
// mySwitch.setPulseLength(439);
// Optional set protocol (default is 1, will work for most outlets)
mySwitch.setProtocol(1);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
}
void loop()
{
mySwitch.send("111011010001001011011111");// Device 1 ON
}

int main()
{
  wiringPiSetup ();
  setup();
  for(;;) {
    loop();
    break;
  }
}

Kompilieren:

g++ -I. -D RPI -o senden-test senden-test.cpp RCSwitch.cpp -lwiringPi

Ausführen:

./senden-test

Als Schalter in HA einbinden:

Schalter in configuration.yaml anlegen:

- platform: command_line
  switches:
    kameralampe:
      friendly_name: 'Kameralampe'
      command_on: '/opt/rc-switch/woziledan'
      command_off: '/opt/rc-switch/woziledaus'

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.