HELP! Broadlink with IR Receiver and CC1101 (IRRemote and SomfyRemoteLibrary)

Hi guys,

I am currently trying to use an Arduino Uno to receive IR signals from my Broadlink RM4 using an IR Receiver, then send an RF signal via the CC101 module to control my Somfy Blinds. The good news is my code somewhat works!.....and only after I press one of the physical buttons on the physical remote.

  • I can still see commands being sent via the Serial Monitor
  • It won't work unless I press one of the physical buttons on the remote first. It will then stop working if I stop sending commands after a while.

I have no idea why this is happening and I am wondering if anyone here can enlighten me. I am using the latest versions of both libraries.

#include <EEPROM.h>
#include <EEPROMRollingCodeStorage.h>
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <SomfyRemote.h>
#include <IRremote.hpp>

int IR_RECEIVE_PIN = 7; // using the newer library
//#include "PinDefinitionsAndMore.h"


#define EMITTER_GPIO 2
#define EEPROM_ADDRESS 0
#define REMOTE 0x5184c8

#define CC1101_FREQUENCY 433.42

EEPROMRollingCodeStorage rollingCodeStorage(EEPROM_ADDRESS);
SomfyRemote somfyRemote(EMITTER_GPIO, REMOTE, &rollingCodeStorage);

void setup() {
  Serial.begin(115200);

  somfyRemote.setup();

  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);


#if defined(ESP32)
  if (!EEPROM.begin(4)) {
    Serial.println("failed to initialise EEPROM");
    delay(1000);
  }
#elif defined(ESP8266)
  EEPROM.begin(4);
#endif
  //    IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void sendCC1101Command(Command command) {
  ELECHOUSE_cc1101.SetTx();
  somfyRemote.sendCommand(command);
  ELECHOUSE_cc1101.setSidle();
}


void loop() {
//  IrReceiver.start() ;
  if (Serial.available() > 0) {
    const String string = Serial.readStringUntil('\n');
    Serial.println(string);
    const Command command = getSomfyCommand(string);
    sendCC1101Command(command);
  }
  if (IrReceiver.decode()) {
    Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);


    if (IrReceiver.decodedIRData.decodedRawData == 0x1011) // down
    {
      Serial.println("Seafox 1 = Down");
      String string = String(4);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
    }

    if (IrReceiver.decodedIRData.decodedRawData == 0x1010) // up
    {
      Serial.println("Seafox 1 = Up");
      String string = String(2);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
    }

    if (IrReceiver.decodedIRData.decodedRawData == 0x100D) // my
    {
      Serial.println("Seafox 1 = My");
      String string = String(1);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
    }
    delay(500);
    IrReceiver.resume();
  }
#ifdef DEBUG
  Serial.println("finished sending");
#endif
}

I have narrowed down the issue with IrReceiver.begin(IR_RECEIVE_PIN); when this is commented out, the serial monitor works with keyboard input. Any reason why this is interfering?

What is the use of this delay? it is a dead time for the IR receiving!
And as far as I understand you, all is working fine, I cannot spot your problem.

Thanks for trying to help! Unfortunately, removing that didn't work.

Maybe something about the timer? or memory dump? I am really baffled.

If you want help, you must describe, what is expected, what is working and what is not as expected!

I am expecting the blinds to work upon sending the command. Without sending a prior command from the physical remote, any message sent (via the IR remote or the serial monitor) doesn't work.

Everything else is still running, it’s just that sendCommand doesn’t work when IrReceiver.begin() is called.

Without sending a prior command from the physical remote, any message sent (via the IR remote or the serial monitor) doesn't work.
??????
Mabe sender and IRreceiver use the same timer. Please check the documentation, or disable receiver before sending and enable it after. See ReceiveDemo line 151 ff.

1 Like

I got it to work! Thanks for the help.

#include <EEPROM.h>
#include <EEPROMRollingCodeStorage.h>
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <SomfyRemote.h>
#include <IRremote.hpp>


int IR_RECEIVE_PIN = 7; // using the newer library
//#include "PinDefinitionsAndMore.h"


#define EMITTER_GPIO 2
#define EEPROM_ADDRESS 0
#define REMOTE 0x5184c8

#define CC1101_FREQUENCY 433.42

EEPROMRollingCodeStorage rollingCodeStorage(EEPROM_ADDRESS);
SomfyRemote somfyRemote(EMITTER_GPIO, REMOTE, &rollingCodeStorage);

void setup() {
  Serial.begin(9600);

  somfyRemote.setup();

  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.setMHZ(CC1101_FREQUENCY);
  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);


#if defined(ESP32)
  if (!EEPROM.begin(4)) {
    Serial.println("failed to initialise EEPROM");
    delay(1000);
  }
#elif defined(ESP8266)
  EEPROM.begin(4);
#endif
  //  IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}

void sendCC1101Command(Command command) {
  ELECHOUSE_cc1101.SetTx();
  somfyRemote.sendCommand(command);
  ELECHOUSE_cc1101.setSidle();
}


void loop() {
  if (Serial.available() > 0) {
    const String string = Serial.readStringUntil('\n');
    Serial.println(string);
    const Command command = getSomfyCommand(string);
    sendCC1101Command(command);
  }
  if (IrReceiver.decode()) {
    Serial.println(IrReceiver.decodedIRData.decodedRawData, HEX);

    if (IrReceiver.decodedIRData.decodedRawData == 0x1011) // down
    {
      IrReceiver.stop();
      Serial.println("Seafox 1 = Down");
      String string = String(4);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
      IrReceiver.start(100000);
    }

    if (IrReceiver.decodedIRData.decodedRawData == 0x1010) // up
    {
      IrReceiver.stop();
      Serial.println("Seafox 1 = Up");
      String string = String(2);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
      IrReceiver.start(100000);

    }

    if (IrReceiver.decodedIRData.decodedRawData == 0x100D) // my
    {
      IrReceiver.stop();
      Serial.println("Seafox 1 = My");
      String string = String(1);
      const Command command = getSomfyCommand(string);
      sendCC1101Command(command);
      IrReceiver.start(100000);

    }
    //    delay(500);
        IrReceiver.resume();
    //        IrReceiver.stop();
  }
#ifdef DEBUG
  Serial.println("finished sending");
#endif
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.