▲ 15 r/Esphome
ESP32 using CC1101 to control Hunter fan
setup an ESP32 DEV using a CC1101 for receiving/transmitting RF signals to the old hunter fan. The controller board inside is stamped "Rhine UC7042T" and the encoder inside uses a HT-12E. all functions appear to work with the ESP buttons. I used google AI to assist in the code:
my dip switch settings may differ from yours, so the code "001111111101" for example would likely have to change.
web_server:
port: 80
logger:
level: DEBUG
# SPI Bus for CC1101 communication
spi:
clk_pin: GPIO18
mosi_pin: GPIO23
miso_pin: GPIO19
# CC1101 - Set to the Hunter hardware sweet spot
cc1101:
id: cc1101_module
cs_pin: GPIO5
frequency: 302.5Mhz
output_power: 10
modulation_type: ASK/OOK
symbol_rate: 2000
filter_bandwidth: 325kHz
# Remote Receiver - Connected to GDO2 (GPIO2)
remote_receiver:
id: rf_receiver
pin: GPIO2
tolerance: 60%
filter: 150us
buffer_size: 15kb
idle: 40ms
dump:
- rc_switch # Tries to decode the Holtek HT-12E binary string automatically
# Remote Transmitter - Connected to GDO0 (GPIO4)
remote_transmitter:
id: rf_transmitter
pin: GPIO4
carrier_duty_percent: 100%
on_transmit:
then:
- cc1101.begin_tx: cc1101_module
on_complete:
then:
- cc1101.begin_rx: cc1101_module
button:
# =========================================================================
# 1. VERIFIED FAN OFF BUTTON
# =========================================================================
- platform: template
name: "Hunter Fan Off"
icon: "mdi:fan-off"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111111101"
repeat:
times: 45
wait_time: 0ms
# =========================================================================
# =========================================================================
# 2. LIGHT TOGGLE ON/OFF. LONGER TIMES DIMS
# =========================================================================
- platform: template
name: "Hunter Fan light"
icon: "mdi:lightbulb"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111111110" # Pulls down the final data line (Bit 12)
repeat:
times: 10
wait_time: 0ms
# =========================================================================
# 3. LIGHT TOGGLE ON/OFF. LONGER TIMES DIMS
# =========================================================================
- platform: template
name: "Hunter Fan dimmer"
icon: "mdi:lightbulb"
on_press:
- repeat:
count: 3
then:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111111110"
repeat:
times: 40
wait_time: 0ms
- delay: 50ms # Microsecond gap prevents the fan from treating it as a toggle
# =========================================================================
# 4. FAN SPEED LOW (3)
# =========================================================================
- platform: template
name: "Hunter Fan Low"
icon: "mdi:fan-speed-1"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111110111" # Corrected to pull the true Low pin state
repeat:
times: 45
wait_time: 0ms
# =========================================================================
# 5. FAN SPEED MEDIUM (2)
# =========================================================================
- platform: template
name: "Hunter Fan medium"
icon: "mdi:fan-speed-2"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111101111" # Simulates pulling multiple lines low for light function
repeat:
times: 45
wait_time: 0ms
# =========================================================================
# 6. FAN SPEED HIGH (1)
# =========================================================================
- platform: template
name: "Hunter Fan high"
icon: "mdi:fan-speed-3"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111011111" # Simulates pulling multiple lines low for light function
repeat:
times: 45
wait_time: 0ms
# =========================================================================
# 7. FIXED FAN DIRECTION
# =========================================================================
- platform: template
name: "Hunter Fan direction"
icon: "mdi:fan-speed-4"
on_press:
- remote_transmitter.transmit_rc_switch_raw:
protocol: 6
code: "001111111011" # Moves the zero pin over to map Medium
repeat:
times: 5
wait_time: 0ms
# =========================================================================
edit: code tried to escape the window
u/saniko747 — 5 days ago