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?