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.
My raw data:
-394 619 -728 299 -360 659 -688 333 -336 657 -700 326 -700 333 -699 296 -715 299 -703 301 -735 296 -368 625 -11983 301 -392 652 -667 327 -398 622 -694 323 -363 668 -654 336 -719 287 -712 335 -692 331 -695 293 -702 264 -461 597 -11980 294 -414 617 -698 297 -377 647 -701 338 -333 689 -661 325 -714 290 -731 293 -723 301 -692 333 -736 269 -395 587 -12016 298 -355 688 -682 303 -360 649 -681 362 -334 647 -697 356 -689 322 -676 318 -652 331 -683 337 -732 264 -397 630 -11967 291 -518 524 -686 296 -423 587 -712 328 -367 614 -732 293 -724 290 -749 290 -720 298 -717 285 -1749 293 -12091 162 -555 496 -853 130 -427 621 -1767 194 -1955 128 -722 336 -656 365 -636 361 -669 355 -626 392 -11856 360 -335 679 -666 352 -326 667 -685 336 -316 684 -680 368 -646 362 -643 357 -637 386 -665 349 -653 360 -652 0
My bin bit raw data:
0000111111000000011100001111111000000011100011111110000000111000000011100000001110000000111000000011100000001110000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000011111110000000111000011111100000001110000111111100000001110000000111000000011100000001110000000111000000011100000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000011111100000001110000111111000000011100011111110000000111000000011100000001110000000111000000011100000001110000111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111000011111110000000111000011111100000001111000111111000000011110000000111000000011100000001110000000111000000011100001111110000000000000000000
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