Hello!
I'm trying to build a small radio module which I'll mount inside of my car + connect to one of the "dead" buttons. End goal: instead of using 2 separate remotes, I'll just have an integrated button which will open both the gate as well as garage doors for me.
I managed to copy the codes from the remotes - one has a short, fixed code (12 bits) but the second one is more complex. It uses a long, rolling code.
Fortunately for me, I copied one of the codes using a cheap AliExpress remote and it continues to work + does not mess up my original button. So even though the gate uses rolling codes - I can repeat each one as many times as I want.
I'm now building+coding a prototype, but I figured it would be best if I prepare both the transmitter as well as a separate receiver project, so I can verify I'm sending it all correctly. I don't want to run 4 floors back and forth or sit in the garage with my laptop.
And here starts my problem:
I can send the shortcode without issues, but when I try to send the long one it doesn't work. Same transmitter and same receiver - one code gets received, and the second one is not.
I suspect the issue might lie in the length of the code, but I'm not sure + don't know how to check it...
Hardware:
- I'll use ESP32 but I also have an Arduino UNO Rev 3
- Radio transmitter: one of those cheapest possible, just for tests
- Radio receiver: CC1101 Module
The transmitter code:
/*
The library I use -> https://github.com/sui77/rc-switch/
*/
#include <RCSwitch.h>
#define PIN_433TX 12
#define PIN_BTN_K1 14
RCSwitch mySwitch = RCSwitch();
String codes[2] = {
"111111110110",
"111111111111001011110100111001110111001001011000101111001100000000001010010011",
};
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(PIN_433TX);
mySwitch.setProtocol(11);
pinMode(PIN_BTN_K1, INPUT_PULLUP);
}
void loop() {
if (digitalRead(PIN_BTN_K1) == LOW) {
Serial.println("Sending signals...");
delay(300);
Serial.println("[1] SEND ==> " + codes[0]);
mySwitch.send(codes[0].c_str());
delay(1000);
Serial.println("[2] SEND ==> " + codes[1]);
mySwitch.send(codes[1].c_str());
delay(1000);
Serial.println("Done 👍\n");
delay(500);
}
}
The receiver:
/*
Libreries used:
https://github.com/sui77/rc-switch/
https://github.com/LSatan/SmartRC-CC1101-Driver-Lib
----------------------------------------------------------
Mod by Little Satan.
----------------------------------------------------------
*/
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
if (ELECHOUSE_cc1101.getCC1101()) {
Serial.println("Connection OK");
} else {
Serial.println("Connection Error");
}
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setMHZ(433.92);
mySwitch.enableReceive(4);
ELECHOUSE_cc1101.SetRx();
}
void loop() {
if (mySwitch.available()) {
Serial.print("Received ");
Serial.print(mySwitch.getReceivedValue());
Serial.print(" / ");
Serial.print(mySwitch.getReceivedBitlength());
Serial.print("bit ");
Serial.print("Protocol: ");
Serial.println(mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
}
}
Note: the receiver is unable to read the code I send with my code as well as from the original button. I had to use the RTL-SDR device to intercept the transmission (that's how I figured out the cheap clone remote keeps transmitting the same signal but still works).
The log ->
time : 2024-04-08 22:44:29
model : Microchip-HCS200 id : 50033D1
Battery : 0 Button : 1 Learn mode: 0 Repeat : 1 encrypted : A4EE72F4
[pulse_slicer_pwm] Microchip HCS200/HCS300 KeeLoq Hopping Encoder based remotes
codes : {12}fff, {66}2f4e77258bcc00a4c bits :
1111 1111 1111, 0010 1111 0100 1110 0111 0111 0010 0101 1000 1011 1100 1100 0000 0000 1010 0100 11
I'm stuck and I don't know how to proceed from here. I'd appreciate any suggestions!