Categorieën bekijken

Wireless Switch Units

Wireless switch units controlled by a microcontroller like Arduino/ESP and for example a CC1101 transciever.

Arduino Library #

Using CC1101 module: https://domoticx.net/docs/433mhz-cc1101-transciever

Icoon

SmartRC-CC1101-Driver-Lib #

1 bestand(en) 1.13 MB

Silvercrest IAN 276299, IAN 303937 #

Arduino code

#include <ELECHOUSE_CC1101_SRC_DRV.h>

#define GDO0_PIN 2   // CC1101 GDO0 on D2

// Pulse timing (in microseconds) SILVERCREST
const unsigned int T0H = 440;   // Pulsduur bit 0 HIGH
const unsigned int T0L = 1040;  // Pulsduur bit 0 LOW
const unsigned int T1H = 1240;  // Pulsduur bit 1 HIGH
const unsigned int T1L = 300;   // Pulsduur bit 1 LOW
const unsigned int SYNC_HIGH = 520;   // Sync puls HIGH
const unsigned int SYNC_LOW = 2140;  // Sync puls LOW

void setup() {
  Serial.begin(115200);
  Serial.println(F("Init CC1101 TX met GDO0 direct pulsen"));

  ELECHOUSE_cc1101.getCC1101();
  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(433.92);
  ELECHOUSE_cc1101.setModulation(2); // ASK/OOK
  ELECHOUSE_cc1101.SetTx();

  pinMode(GDO0_PIN, OUTPUT);
  digitalWrite(GDO0_PIN, LOW);
  delay(100);
}

void transmitHigh(unsigned int duration) {
  digitalWrite(GDO0_PIN, HIGH);
  delayMicroseconds(duration);
}

void transmitLow(unsigned int duration) {
  digitalWrite(GDO0_PIN, LOW);
  delayMicroseconds(duration);
}

void sendBit(bool bit) {
  if (bit) {
    transmitHigh(T1H);
    transmitLow(T1L);
  } else {
    transmitHigh(T0H);
    transmitLow(T0L);
  }
}

void sendCode(unsigned long code) {
  for (int repeat = 0; repeat < 10; repeat++) {
    for (int i = 23; i >= 0; i--) {
      bool bit = (code >> i) & 1;
      sendBit(bit);
    }
    // Sync-puls
    transmitHigh(SYNC_HIGH);
    transmitLow(SYNC_LOW);
  }
  Serial.println(F("Code sent!"));
}

void loop() {
  sendCode(0xFFB2AC); //ON (LEARN)
  Serial.println(F("ON"));
  delay(2000);
  sendCode(0xF2CB2C); // OFF
  Serial.println(F("OFF"));
  delay(2000);
}

Flamingo SF-501P #

Additional Library: arduino-sf501remote

Github: https://github.com/arjhun/arduino-sf501remote

Icoon

arduino-sf501remote #

1 bestand(en) 7.23 KB

Arduino code

#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include "sf501-remote.h"

Sf501Remote remote;
const int remoteId = 25134;

#define GDO0_PIN 2   // GDO0 van CC1101 verbonden met D2

// Pulse settings
const unsigned int pulseLength = 190;
const unsigned int shortPulse = 2 * pulseLength;
const unsigned int longPulse = 7 * pulseLength;
const unsigned int startGap = 14 * pulseLength;
const unsigned int interFrameGap = 2660; // optioneel

void setup() {
  Serial.begin(115200);
  Serial.println("Start SF501 with CC1101");

  // Init CC1101
  ELECHOUSE_cc1101.getCC1101();
  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(433.92);
  ELECHOUSE_cc1101.setModulation(2); // OOK/ASK
  ELECHOUSE_cc1101.SetTx();

  pinMode(GDO0_PIN, OUTPUT);
  digitalWrite(GDO0_PIN, LOW);

  remote.startTransmitter(GDO0_PIN);
  delay(100);
}

void loop() {
  int button = 1; // up to 15 buttons (4 bits)
  
  remote.sendCommand(remoteId, button , true);
  Serial.println("Send ON");
  delay(2000);

  remote.sendCommand(remoteId, button , false);
  Serial.println("Send OFF");  
  delay(2000);
}

Elro Home Easy HE-874 (Flamingo) #

Arduino code

#include <ELECHOUSE_CC1101_SRC_DRV.h>
#define GDO0_PIN 2   // GDO0 of CC1101 module

// Compiler only coding
#define FREMOTE 2                                  /* Amount supported remotes */
#define FUNITS  4                                  /* Amount of units supported per remote */
#define FCMDN   2                                  /* Amount of CMD 0 = On, 1 = Off */

int rfPin = 2;

uint32_t fdev[FREMOTE][FUNITS][FCMDN] = {0xD9762A10,                                           /* Remote 0, Unit A, On  */
                                         0xDAA47850,                                           /* Remote 0, Unit A, Off */
                                         0xDBDA22E0,                                           /* Remote 0, Unit B, On  */
                                         0xDBA27220,                                           /* Remote 0, Unit B, Off */
                                         0x19BFD260,                                           /* Remote 0, Unit C, On  */
                                         0x195EEAA0,                                           /* Remote 0, Unit C, Off */
                                         0x984CC650,                                           /* Remote 0, Unit D, On  */
                                         0x9A8C1050,                                           /* Remote 0, Unit D, Off */
                                         0xDBFFFE90,                                           /* Remote 1, Unit A, On  */
                                         0xD91CEF10,                                           /* Remote 1, Unit A, Off */
                                         0xDBC52FA0,                                           /* Remote 1, Unit B, Aan */
                                         0xD9E35160,                                           /* Remote 1, Unit B, Off */
                                         0x19B0FE60,                                           /* Remote 1, Unit C, On  */
                                         0x19682B20,                                           /* Remote 1, Unit C, Uit */
                                         0x9924E7D0,                                           /* Remote 1, Unit D, On  */
                                         0x9BA928D0                                            /* Remote 1, Unit D, Uit */
                                        };                                          


// Define Flamingo_send variables / constants

int fpulse = 300;                              /* Pulse witdh in microseconds */
int fretrans = 5;                              /* Code retransmission         */
uint32_t fsendbuff;
uint32_t fdatabit;
uint32_t fdatamask = 0x80000000;

void Flamingo_Send(int fhousec, int funitc, int fcmd) {
  // Test if used codes are valid
  if ((funitc < 1) || (funitc >  2)) {                  // check if unit code between 1-2 (Remote 0 of 1)
    Serial.print("Unit error: ");
    Serial.println(funitc);
    return;
  }
  else  {
    funitc = funitc - 1;                               // To address right code in array
  }

  if ((fhousec < 0) || (fhousec >  3)) {               // check if house code between 1-4 (A-D)
    Serial.print("House error: ");
    Serial.println(fhousec);
    return;
  }

  if ((fcmd < 0) || (fcmd > 1)) {                       // check if command = 0 (off) or 1 (on)
    Serial.print("Command error: ");
    Serial.println(fcmd);
    return;
  }
  
  // End test used codes
  Serial.println("Send Flamingo command ");
  Serial.print("Flamingo House/Device code = :");
  Serial.println(fhousec);
  Serial.print("Flamingo Unit/remote code = :");
  Serial.println(funitc);
  Serial.print("command = :");
  Serial.println(fcmd);
  Serial.println();

  // Send Command
  for (int nRepeat = 0; nRepeat <= fretrans; nRepeat++) {

    fsendbuff = fdev[funitc][fhousec][fcmd];

    // send SYNC 1P High, 15P low
    Serial.println("Send sync");

    digitalWrite(rfPin, HIGH);
    delayMicroseconds(fpulse * 1);
    digitalWrite(rfPin, LOW);
    delayMicroseconds(fpulse * 15);
    // end send SYNC

    // Send command
    for (int i = 0; i < 28; i++)                                 // Flamingo command is only 28 bits */
    {
      // read data bit
      fdatabit = fsendbuff & fdatamask;                         // Get most left bit
      fsendbuff = (fsendbuff << 1);                             // Shift left

      if (fdatabit != fdatamask)
      { // Write 0
        digitalWrite(rfPin, HIGH);
        delayMicroseconds(fpulse * 3);
        digitalWrite(rfPin, LOW);
        delayMicroseconds(fpulse * 1);
      }
      else
      { // Write 1
        digitalWrite(rfPin, HIGH);
        delayMicroseconds(fpulse * 1);
        digitalWrite(rfPin, LOW);
        delayMicroseconds(fpulse * 3);
      }
    }
  }
}

void setup() {
  Serial.begin(115200);
  Serial.println("Start...");

  // Init CC1101
  ELECHOUSE_cc1101.getCC1101();
  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(433.92);
  ELECHOUSE_cc1101.setModulation(2); // OOK/ASK
  ELECHOUSE_cc1101.SetTx();

  pinMode(GDO0_PIN, OUTPUT);
  digitalWrite(GDO0_PIN, LOW);
  delay(100);
}

void loop() {
  Flamingo_Send(0, 1, 1);
  Serial.println("SEND ON");
  delay(2000);
  Flamingo_Send(0, 1, 0);
  Serial.println("SEND OFF");
  delay(2000);
}

KlikaanKlikuit PAR-1000 (codeschijf) #

Additional Library: RemoteSwitch-arduino-library

Github: https://github.com/jccprj/RemoteSwitch-arduino-library

Arduino code

#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <RemoteSwitch.h>

#define GDO0_PIN 2   // GDO0 van CC1101 verbonden met D2

//Intantiate a new ActionSwitch remote
ActionSwitch actionSwitch(GDO0_PIN);

//Intantiate a new KaKuSwitch remote
KaKuSwitch kaKuSwitch(GDO0_PIN);

//Intantiate a new Blokker remote
BlokkerSwitch blokkerSwitch(GDO0_PIN);

void setup() {
  Serial.begin(115200);
  Serial.println("Start...");

  // Init CC1101
  ELECHOUSE_cc1101.getCC1101();
  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(433.92);
  ELECHOUSE_cc1101.setModulation(2); // OOK/ASK
  ELECHOUSE_cc1101.SetTx();

  pinMode(GDO0_PIN, OUTPUT);
  digitalWrite(GDO0_PIN, LOW);
  delay(100);
}

void loop() {
  kaKuSwitch.sendSignal('A', 1, true);
  Serial.println("SEND ON");
  delay(2000);
  kaKuSwitch.sendSignal('A', 1, false);
  Serial.println("SEND OFF");  
  delay(2000);
}