Hi everyone,
I’m feeling a bit stuck with my project and could really use some help. My goal is to use Home Assistant to control my ceiling fan. I want the fan to automatically turn on when the temperature rises above a certain threshold.
To start, I created a basic setup with one button to test communication with the fan. I used an EvilCrow device to record the RF signal, which generates a Flipper SubGHz RAW file. I then used Universal Radio Hacker to convert the signal to bits. Both the RAW file and the converted binary work perfectly in the EvilCrow UI to control the fan’s light.
However, when I try to use the RAW signal with ESPHome and configure a button to send the signal, it doesn’t work. I’m unsure how to extract the correct preamble and command from the code. Any advice would be greatly appreciated!
My ESPHome testing config:
esphome:
name: cc1101-light-control
friendly_name: CC1101 Light Control
includes:
- cc1101.h
libraries:
- SPI
- "SmartRC-CC1101-Driver-Lib"
esp32:
board: esp32dev # Use the correct board type for your ESP32
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
power_save_mode: none # ESP32 has better power management
# Optional manual IP
manual_ip:
static_ip: 192.168.1.15
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable logging
logger:
level: VERBOSE # Set the logging level to VERBOSE for detailed logs
# Enable OTA (Over-the-Air updates)
ota:
platform: esphome
# Define the remote transmitter and the sensor for RSSI
remote_transmitter:
pin: GPIO5 # CSN connected to GPIO5
carrier_duty_percent: 50%
id: rf_transmitter
# Define the RSSI sensor using the custom CC1101 component
sensor:
- platform: custom
lambda: |-
auto cc1101 = new CC1101(18, 19, 23, 5, 16, 58.0, 303.875, rf_transmitter, new Sensor());
// Log that the CC1101 was initialized
ESP_LOGD("cc1101", "CC1101 initialized successfully 😎");
App.register_component(cc1101);
return {cc1101->get_rssi_sensor()};
sensors:
name: "CC1101 RSSI"
# Button to trigger the RF transmission
button:
- platform: template
name: "Light Switch"
on_press:
then:
- lambda: ESP_LOGI("Button", "Light Switch button pressed 🛎️, sending RF signal...");
- remote_transmitter.transmit_raw:
carrier_frequency: 303875kHz # Adjust the frequency if needed
code: [ raw code..]
- lambda: ESP_LOGI("Button", "RF transmission completed 📡.");
- delay: 500ms # Add a small delay after transmission
# Optional Web server for monitoring
web_server:
port: 80
I’ve updated my config to include a function that listens for signals on the same frequency.
When I press the button on my remote, I receive the following in the logs: [I][remote.rc_switch:261]: Received RCSwitch Raw: protocol=6 data='010101111110'.
I tried using that same raw code for my button configuration, but it’s not working.
EPSHome config:
esphome:
name: cc1101-light-control
friendly_name: CC1101 Light Control
includes:
- cc1101.h
libraries:
- SPI
- "SmartRC-CC1101-Driver-Lib"
esp32:
board: esp32dev # Use the correct board type for your ESP32
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: true
power_save_mode: none # ESP32 has better power management
# Optional manual IP
manual_ip:
static_ip: 192.168.1.15
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable logging
logger:
level: VERBOSE # Set the logging level to VERBOSE for detailed logs
# Enable OTA (Over-the-Air updates)
ota:
platform: esphome
# Define the remote transmitter
remote_transmitter:
pin: GPIO5 # CSN connected to GPIO5
carrier_duty_percent: 50%
id: rf_transmitter
# Define the remote receiver with rc_switch for bit reception
remote_receiver:
id: rf_receiver
pin:
number: GPIO16 # GDO0 pin connected to GPIO16
inverted: false
tolerance: 50%
filter: 4us
idle: 4ms
buffer_size: 2kb
dump:
- rc_switch # This will decode signals using the rc_switch protocol
# Define the RSSI sensor using the custom CC1101 component
sensor:
- platform: custom
lambda: |-
auto cc1101 = new CC1101(18, 19, 23, 5, 16, 58.0, 303.875, rf_transmitter, new Sensor());
// Log that the CC1101 was initialized
ESP_LOGD("cc1101", "CC1101 initialized successfully 😎");
App.register_component(cc1101);
return {cc1101->get_rssi_sensor()};
sensors:
name: "CC1101 RSSI"
# Button to trigger the RF transmission
button:
- platform: template
name: "Light Switch"
on_press:
then:
- lambda: ESP_LOGI("Button", "Light Switch button pressed 🛎️, sending RF signal...");
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6 # Use the same protocol you received
code: '010101111110' # Binary code received ('010101111110')
repeat: 5 # You can adjust the number of repetitions as needed
- lambda: ESP_LOGI("Button", "RF transmission completed 📡.");
# Optional Web server for monitoring
web_server:
port: 80
Yes this thread is frustrating. @canadank0 clearly can’t be bothered even reading the responses, or the docs, which say exactly what you are telling him.
Regarding the raw code: I initially used the EvilCrow to capture the signal and successfully tested transmitting it back with the EvilCrow, which worked fine. The code I shared earlier is an exact copy, without any modifications. Honestly, I’m not sure how the code should look in its proper form.
Then @nickrout suggested why not record the code with the ESP, which I didn’t realize was possible. So, I started looking into how to capture the codes. I managed to get raw codes from my remote (UC7078T at 303.875 MHz frequency), but the remote keeps sending inconsistent signals. The same button sometimes sends: 10101111110, or 010101111110, or even 11010111. It’s strange.
Hey @canadank0, I’m afraid you’re missing some key parameters for the protocol section.
I’ve faced similar issues as you, but I figured out the correct parameters for my Hampton Bay 303.875 Mhz ceiling fan and it’s working flawlessly with ESPHome and a cheap RF Transmitter.
Take a look at this post. I believe that, if it doesn’t fully solve your problem, at least it will put you on the right track.
Yes — I’m not sure if you still need this, but here’s how I got it working. I couldn’t reliably decode the RF codes, despite repeatedly flashing my ESP32 with ESPHome and trying different approaches.
I even used ChatGPT for help, which was useful, but the decoding still eluded me. Eventually I switched to an MQTT-based solution and got lucky. I have an EvilCrowRF device that can read and transmit .sub files.
To get the codes into Home Assistant I adapted the ESP8266 project (GitHub - owenb321/hampton-bay-fan-mqtt: MQTT / RF Bridge for Hampton Bay Fan control) for my ESP32 (I asked ChatGPT to optimize the pins and code for ESP32),
flashed it from the Arduino IDE, and watched the serial console. With the ESP32 + CC1101 connected to Wi-Fi and Home Assistant’s MQTT server, I used the EvilCrow to transmit the .sub files and captured the resulting codes.
prot=11 value=1406 bits=12
prot=11 value=1405 bits=12
prot=11 value=1399 bits=12
prot=11 value=1391 bits=12
prot=11 value=1375 bits=12
I asked ChatGPT to convert these codes and add transmit option to my Arduino IDE project. ChatGPT suggested I publish those raw codes to an MQTT topic so my ESP32 (connected to a CC1101) can subscribe and transmit them over RF to the fan.
Topic:
home/hamptonbay/raw/send
Payload (CSV):
11,12,1406
Format is protocol,bits,value[,repeats]. Repeats is optional (defaults to 8).
and that was it, the fan start working with MQTT no issue.
I hope that this explanation helps