esphome-cc1101
esphome-cc1101 copied to clipboard
not able to send
hello i have aa cc1101 hooked up to a wemos D1 mini.
when hooking up i could recieve some data.
but when i resend this data there is nothing happening, the lights wont turn on. what could be wrong, how to find out what is wrong.
below is my yaml file
# --- start default settings ---
esphome:
name: 118-rf-tranceiver
includes:
- cc1101.h
libraries:
- SPI
- "SmartRC-CC1101-Driver-Lib"
esp8266:
board: d1_mini_lite
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pwd
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "rf fallback"
password: !secret esphome_pwd
manual_ip:
static_ip: 192.168.1.118
gateway: 192.168.1.1
subnet: 255.255.255.0
captive_portal:
# Enable logging
logger:
api:
password: !secret esphome_api
ota:
password: !secret esphome_ota
web_server:
port: 80
# --- End default settings ---
# --- Start of custom sensors ---
sensor:
- platform: custom
lambda: |-
auto my_sensor = new CC1101(
D5, // SCK
D6, // MISO
D7, // MOSI
D8, // CSN
D1, // GDO0
D2, // GDO2
200, // bandwidth_in_khz
433.92 // freq_in_mhz
);
App.register_component(my_sensor);
return {my_sensor};
sensors:
id: transciver
internal: true
remote_transmitter:
- pin: D1 # This is GDO0
carrier_duty_percent: 100%
remote_receiver:
- pin: D1 # This is GDO0
# on the esp8266 use any of D1,D2,D5,D6,D7,Rx
# Don't use D3,D4,D8,TX, boot often fails.
# Can't be D0 or GPIO17 b/c no interrupts
dump: rc_switch
binary_sensor:
- platform: remote_receiver
name: Garage
rc_switch_raw:
code: "0011000100001110101001111000"
protocol: 1
button:
- platform: template
name: Garage
on_press:
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: "0011000100001110101001111000"
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: "0011000100001110101001111000"
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: "0011000100001110101001111000"
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: "001100010000111010100111100"
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
Try raw and paste the logs here: https://dbuezas.github.io/esphome-remote_receiver-oscilloscope/
It may be that it is recognized as "protocol 1" but it isn't. The full raw mode is more verbose but it doesn't assume any particular timing.
It can also be that your garage uses rolling codes, in which case the codes change all the time and transmitting won't work (unlikely)
I did read the raw data but at every key press the data isn't the same. Tommorow i will send the output of the raw data.
Make a couple of readings and paste the full log there, you'll be able to visualize it and see if they are truly different each time or just slight timing deviations (whis is normal and expected). If they do look the same in the plot, the n transmitting should work fine with those approximate flank timings. Much luck!
Past the raw messages in your tool, and they all look the same.
[06:37:56][D][remote.raw:041]: 374, -1143, 1115, -383, 1106, -396, 1124, -383, 1106, -397, 374, -1140, 351, -1145, 350, -1140, 375
[06:37:56][D][remote.raw:028]: Received Raw: 386, -1113, 392, -1121, 1110, -394, 1119, -389, 360, -1132, 368, -1148, 360, -1156, 1093, -385, 385, -1129, 369, -1124, 386, -1130, 369, -1125, 1111, -392, 1116, -388, 1112, -394, 368, -1141, 1111, -393, 369, -1144, 1090, -400, 374, -1143,
[06:37:56][D][remote.raw:041]: 365, -1140, 1103, -399, 1102, -405, 1102, -400, 1101, -380, 375, -1145, 350, -1138, 375, -1144, 364
[06:37:56][D][remote.raw:028]: Received Raw: 395, -1116, 390, -1116, 1120, -381, 1114, -394, 369, -1144, 357, -1137, 369, -1146, 1116, -370, 369, -1144, 356, -1136, 370, -1143, 357, -1137, 1121, -388, 1115, -394, 1120, -389, 360, -1131, 1118, -387, 361, -1152, 1119, -386, 358, -1153,
[06:37:56][D][remote.raw:041]: 342, -1164, 1084, -395, 1122, -384, 1109, -396, 1123, -383, 381, -1121, 370, -1132, 382, -1123, 370
[06:37:56][D][remote.raw:028]: Received Raw: 372, -1116, 390, -1140, 1097, -388, 1110, -394, 369, -1145, 364, -1140, 347, -1143, 1114, -405, 353, -1144, 364, -1140, 354, -1144, 365, -1141, 1107, -397, 1098, -407, 1106, -398, 349, -1164, 1105, -399, 351, -1140, 1105, -410, 357, -1134,
[06:37:56][D][remote.raw:041]: 369, -1145, 1114, -376, 1127, -374, 1114, -406, 1115, -390, 350, -1138, 376, -1145, 350
[06:38:59][D][remote.raw:028]: Received Raw: 387, -1131, 368, -1149, 1114, -393, 1093, -388, 387, -1126, 367, -1149, 361, -1129, 1118, -387, 386, -1126, 366, -1149, 361, -1128, 369, -1146, 1110, -394, 1121, -389, 1111, -393, 369, -1145, 1108, -396, 345, -1143, 1114, -405, 352, -1147,
[06:38:59][D][remote.raw:041]: 373, -1141, 1103, -400, 1098, -406, 1105, -398, 1099, -407, 353, -1146, 372, -1140, 352, -1148, 372
[06:38:59][D][remote.raw:028]: Received Raw: 396, -1118, 390, -1136, 1097, -402, 1106, -399, 373, -1142, 365, -1141, 351, -1146, 1123, -383, 353, -1147, 372, -1140, 353, -1146, 372, -1140, 1106, -397, 1124, -383, 1105, -397, 373, -1140, 1103, -398, 374, -1140, 1103, -398, 351, -1139,
[06:38:59][D][remote.raw:041]: 375, -1144, 1115, -384, 1108, -396, 1122, -384, 1112, -392, 371, -1141, 379, -1123, 372, -1141, 353
[06:38:59][D][remote.raw:028]: Received Raw: 375, -1140, 373, -1145, 1101, -405, 1102, -399, 351, -1140, 374, -1147, 350, -1139, 1126, -374, 379, -1139, 373, -1142, 364, -1141, 352, -1145, 1123, -383, 1105, -396, 1121, -385, 380, -1123, 1121, -385, 381, -1120, 1115, -412, 359, -1122,
[06:38:59][D][remote.raw:041]: 390, -1142, 1109, -394, 1095, -412, 1110, -395, 1094, -412, 358, -1147, 366, -1125, 387, -1124, 366
[06:38:59][D][remote.raw:028]: Received Raw: 387, -1127, 370, -1116, 1134, -370, 1120, -387, 383, -1124, 370, -1142, 381, -1121, 1121, -386, 382, -1122, 370, -1142, 380, -1120, 371, -1131, 1134, -369, 1140, -387, 1111, -394, 369, -1142, 1109, -369, 370, -1141, 1135, -369, 370, -1140,
[06:38:59][D][remote.raw:041]: 381, -1121, 1139, -388, 1109, -395, 1119, -388, 1110, -394, 369, -1117, 383, -1123, 370```
the first 4 are from the first button press, and the last 4 are from the 2e button press.
but upon sending the raw data back the light's won't go on.
below the alterd yaml
```# default template name, the first number in the name is the ending of the ip adres
# --- start default settings ---
esphome:
name: 118-rf-tranceiver
includes:
- cc1101.h
libraries:
- SPI
- "SmartRC-CC1101-Driver-Lib"
esp8266:
board: d1_mini_lite
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_pwd
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "rf fallback"
password: !secret esphome_pwd
manual_ip:
static_ip: 192.168.1.118
gateway: 192.168.1.1
subnet: 255.255.255.0
captive_portal:
# Enable logging
logger:
api:
password: !secret esphome_api
ota:
password: !secret esphome_ota
web_server:
port: 80
# --- End default settings ---
# --- Start of custom sensors ---
sensor:
- platform: custom
lambda: |-
auto my_sensor = new CC1101(
D5, // SCK
D6, // MISO
D7, // MOSI
D8, // CSN
D1, // GDO0
200, // bandwidth_in_khz
433.92 // freq_in_mhz
);
App.register_component(my_sensor);
return {my_sensor};
sensors:
id: transciver
internal: true
remote_transmitter:
- pin: D1 # This is GDO0
carrier_duty_percent: 100%
remote_receiver:
- pin: D1 # This is GDO0
# on the esp8266 use any of D1,D2,D5,D6,D7,Rx
# Don't use D3,D4,D8,TX, boot often fails.
# Can't be D0 or GPIO17 b/c no interrupts
dump:
- raw
binary_sensor:
- platform: remote_receiver
name: Garage
rc_switch_raw:
code: "11111100"
protocol: 1
button:
- platform: template
name: Garage
on_press:
- remote_transmitter.transmit_raw:
code: [364, -1120, 389, -1125, 1112, -392, 1116, -385, 385, -1128, 368, -1140, 365, -1126, 1120, -388, 359, -1152, 344, -1141, 381, -1123, 371, -1141, 1105, -397, 1124, -382, 1105, -398, 350, -1158, 1103, -397, 364, -1141, 1104, -398, 350, -1140, 374, -1143, 1115, -383, 1106, -396, 1124, -383, 1106, -397, 374, -1140, 351, -1145, 350, -1140, 375]
- lambda: get_cc1101(transciver).endTransmission();
- remote_transmitter.transmit_raw:
code: [364, -1120, 389, -1125, 1112, -392, 1116, -385, 385, -1128, 368, -1140, 365, -1126, 1120, -388, 359, -1152, 344, -1141, 381, -1123, 371, -1141, 1105, -397, 1124, -382, 1105, -398, 350, -1158, 1103, -397, 364, -1141, 1104, -398, 350, -1140, 374, -1143, 1115, -383, 1106, -396, 1124, -383, 1106, -397, 374, -1140, 351, -1145, 350, -1140, 375]
- lambda: get_cc1101(transciver).endTransmission();
- remote_transmitter.transmit_raw:
code: [364, -1120, 389, -1125, 1112, -392, 1116, -385, 385, -1128, 368, -1140, 365, -1126, 1120, -388, 359, -1152, 344, -1141, 381, -1123, 371, -1141, 1105, -397, 1124, -382, 1105, -398, 350, -1158, 1103, -397, 364, -1141, 1104, -398, 350, -1140, 374, -1143, 1115, -383, 1106, -396, 1124, -383, 1106, -397, 374, -1140, 351, -1145, 350, -1140, 375]
- lambda: get_cc1101(transciver).endTransmission();
- remote_transmitter.transmit_raw:
code: [387, -1127, 370, -1116, 1134, -370, 1120, -387, 383, -1124, 370, -1142, 381, -1121, 1121, -386, 382, -1122, 370, -1142, 380, -1120, 371, -1131, 1134, -369, 1140, -387, 1111, -394, 369, -1142, 1109, -369, 370, -1141, 1135, -369, 370, -1140, 381, -1121, 1139, -388, 1109, -395, 1119, -388, 1110, -394, 369, -1117, 383, -1123, 370]
- lambda: get_cc1101(transciver).endTransmission();```
Ok, the plot looks like this should work, but you are missing the startTransmission lambda calls now. That may just be it! Also, make sure to pick the longer pattern from the ones you received. Good luck!
stupid me, had to sleep longer :-)
after altering nothing happens, i think i have to wait for a second CC1101, so i could monitor what is sending. since there is still no communication.
Hehe, yeah, the start and end transmission calls are easy to miss.
Try this:
code: [-50000, 386, -1113, 392, -1121, 1110, -394, 1119, -389, 360, -1132, 368, -1148, 360, -1156, 1093, -385, 385, -1129, 369, -1124, 386, -1130, 369, -1125, 1111, -392, 1116, -388, 1112, -394, 368, -1141, 1111, -393, 369, -1144, 1090, -400, 374, -1143, 365, -1140, 1103, -399, 1102, -405, 1102, -400, 1101, -380, 375, -1145, 350, -1138, 375, -1144, 364, -50000]
I added a "-50000" at the beginning and end to ensure the radio leaves enough space between repetitions. I suggest you do the repetitions through this instead: https://esphome.io/components/remote_transmitter.html?highlight=remote+transmitter#remote-transmitter-actions
Also, somebody else reported success using independent pins for receiving and transmitting here: https://github.com/dbuezas/esphome-cc1101/issues/2#issuecomment-1172924868
did recieve my second device but when trying to send data the other one isn't recieving the data, so looks like somthing is still wrong
Did you try the alternative at the end of #2 ?
i put your delay at the begin and at the end, but it still isn't working. don;t know what you mean with [Did you try the alternative at the end of https://github.com/dbuezas/esphome-cc1101/issues/2 ?]
if you mean, did you call endtransmission, than yes i did see my code.
below is how i wired my device: 1 GND GND 2 VCC VCC 3 GDO0 D1 4 CSN D8 5 SCK D5 6 MOSIO D7 7 MISO D6 8 GDO2 D2
this is the device i have:https://www.ebyte.com/en/downpdf.aspx?id=165
Follow the link to the other issue here: #2 This fellow used one pin for transmitting and another one for receiving, ~~what makes the lambda calls unnecessary~~. He reported that that fixed some other issue I didn't have myself.
I see you already have GDO2 wired to d2, so you can use his modified yaml and cc1101.h files. He puts the chip in the right mode to use 2 wires. I did it with only 1 wire just because I have 3 chips and an IR receiver im the same board and ran out of pins :)
still no good, could it be that the c1101 v2 is somewhat different. Today i tryed the Somfy code from here and that one also didn't work. https://www.die-welt.net/2021/06/controlling-somfy-roller-shutters-using-an-esp32-and-esphome/
i build this one upon an esp32 and like the schematic that's on that page.
looks like this c1101 won't send data only recieve.
That's really odd. The only way I know to know for sure is to get an rtl-sdr
i will order some new ones at a different store with better reviews. after some digging i found out that there are a lot more problems with these modules.
[https://www.amazon.nl/-/en/gp/product/B07YX92NMP/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1](url)
I bought 3 different ones in AliExpress and all worked. I guess i got lucky then
I also orderd 2 new ones from ali, lets hope they are working the way i want.
I have to wait till 20 september, so no more trying for me.
Keep you informed.
No RTL-SDR? 😁
No i dont't have 😣
Ask santa to get you one. You'll be able to see the spectrum. They are very fun
stil not working here, thinking of looking into a RTL-SDR. any advice on hardware and software. prefere free software and cheap hardware :-)
have a RTL-SDR and reciving things now reinstall the esphome rf transmitter to see if it sends data
it look like nothing is send, when pressing te remote there is data. when pressing the button within esphome nothing is displayed.
looks like somthing is wrong, all connectings are right, the device is recieving data, but not sending. I tryed the default c1101.h and the alterd one where gdo2 is used.
Can you post your yaml? Also, do you have the cc1101.h file untouched as in this repo?
Btw, you did confirm now with the rtl-sdr that the cc1101 is not sending, right?
i confirmed that my c1101 isn't sending.
below my cc1101.h file and yaml from the yaml file, i only pasted the sensor section, the rest is for configuration.
cc1101.h
#define CC1101TRANSCIVER_H
#include <ELECHOUSE_CC1101_SRC_DRV.h>
int CC1101_module_count = 0;
#define get_cc1101(id) (*((CC1101 *)id))
class CC1101 : public PollingComponent, public Sensor
{
int _SCK;
int _MISO;
int _MOSI;
int _CSN;
int _GDO0;
int _GDO2;
float _bandwidth;
float _moduleNumber;
int _last_rssi = 0;
void setup()
{
ELECHOUSE_cc1101.setGDO(_GDO0, _GDO2);
ELECHOUSE_cc1101.addSpiPin(_SCK, _MISO, _MOSI, _CSN, _moduleNumber);
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.setRxBW(_bandwidth);
ELECHOUSE_cc1101.setMHZ(_freq);
ELECHOUSE_cc1101.SetRx();
}
public:
float _freq;
CC1101(int SCK, int MISO, int MOSI, int CSN, int GDO0, int GDO2, float bandwidth,
float freq)
: PollingComponent(100)
{
_SCK = SCK;
_MISO = MISO;
_MOSI = MOSI;
_CSN = CSN;
_GDO0 = GDO0;
_GDO2 = GDO2;
_bandwidth = bandwidth;
_freq = freq;
_moduleNumber = CC1101_module_count++;
}
void beginTransmission()
{
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.SetTx();
noInterrupts();
}
void endTransmission()
{
interrupts();
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.setSidle();
}
void setRX()
{
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.SetRx();
}
void setBW(float bandwidth)
{
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.setRxBW(bandwidth);
}
void setFreq(float freq)
{
ELECHOUSE_cc1101.setModul(_moduleNumber);
ELECHOUSE_cc1101.setMHZ(freq);
}
bool rssi_on;
void update() override
{
int rssi = 0;
if (rssi_on)
{
ELECHOUSE_cc1101.setModul(_moduleNumber);
rssi = ELECHOUSE_cc1101.getRssi();
}
if (rssi != _last_rssi)
{
publish_state(rssi);
_last_rssi = rssi;
}
}
};
#endif
yaml
# --- Start of custom sensors ---
sensor:
- platform: custom
lambda: |-
auto my_sensor = new CC1101(
D5, // SCK
D6, // MISO
D7, // MOSI
D3, // CSN
D1, // GDO0
D2, // GDO2
200, // bandwidth_in_khz
433.92 // freq_in_mhz
);
App.register_component(my_sensor);
return {my_sensor};
sensors:
id: transciver
internal: true
remote_transmitter:
- pin: D2 # This is GDO2
carrier_duty_percent: 100%
remote_receiver:
- pin: D1 # This is GDO0
# on the esp8266 use any of D1,D2,D5,D6,D7,Rx
# Don't use D3,D4,D8,TX, boot often fails.
# Can't be D0 or GPIO17 b/c no interrupts
dump: all
button:
- platform: template
name: overkapping aan
on_press:
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: '0011000100001110101001111000'
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: '0011000100001110101001111000'
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: '0011000100001110101001111000'
protocol: 1
- lambda: get_cc1101(transciver).endTransmission();
- lambda: get_cc1101(transciver).beginTransmission();
- remote_transmitter.transmit_rc_switch_raw:
code: '0011000100001110101001111000'
protocol: 1
- lambda: get_cc1101(transc
Did you see this? https://community.home-assistant.io/t/new-sonoff-rf-bridge-board-need-flashing-help/344326/134
It seems like there is a bug in esphome regarding transmission, and the post also has a workaround :)
im having the same issues with the same module.
Update:
So I can see in the log of the receiver esp that it is receivng the RAW code, seems to spit out a random value, however my relay is still not activating.
One more data point: I have a cc1101 v2 as well, but a d1 mini, not lite. My cc1101 v2 DOES transmit with dbuezas’ yaml and .h file - although I struggled until getting an RTL-sdr.
A year later so not sure if this is still an issue, but wondering if you gave your esphome component, looks like you named yours ‘118-Rf-tranceiver’ homeassistant access. That tripped me up for a while. Without permission to home assistant, when you press the button, the component won’t be notified. To grant homeassistant permission, in home assistant, go to settings, devices & services, esphome, click ‘configure’ on your device, click ‘Allow the device to make Home Assistant service calls.’
Guys, im still fighting this.
I am able to receive, but I cannot send. I have tried with dbuezas's yaml too.
Any ideas?