Using the new CC1101 component

The CC1101 was added as a component less than a month ago and most of the posts I find here relate to the legacy external component version where you link the github (dbuezas/esphome-cc1101). Since it is no longer compatible it feels like a good time for a full rebuild.

Does anyone have a working YAML for use with the CC1101?

I have automations where if event esphome.rf_code_received is fired with code: “abcdef” then it runs this functionality works with my YAML below.

I was able to reuse some of my old YAML for the legacy variant but do not have the ability to transmit. Also the code comes in the HEX while I somehow translated it to decimal using the same lamda but that should be a minor fix.

#     CC1101 Top view
#   -----------------------------------
#   | 1 GND   2 VCC         -----     |
#   | 3 GDO0  4 CSN        |     |    |ANTENNA
#   | 5 SCK   6 MOSI       |     |    |ANTENNA
#   | 7 MISO  8 GDO2        -----     |
#   -----------------------------------
#   1 - GND  - Ground
#   2 - VCC  - 1.8v-3.6v
#   3 - GDO0 - Module Out
#   4 - CSN  - Chip Select
#   5 - SCK  - SPI Clock
#   6 - MOSI - SPI IN
#   7 - MISO - SPI Out
#   8 - GDO2 - Module Out

esphome:
  name: esp32-cc1101
  friendly_name: esp32-cc1101

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "123456789"
 

ota:
  - platform: esphome
    password: "123456789"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Cc1101 Fallback Hotspot"
    password: "123456789"

captive_portal:
    
spi:
  clk_pin:  GPIO14                   # D14 - Pin5
  miso_pin: GPIO12                   # D12 - Pin7
  mosi_pin: GPIO13                   # D13 - Pin6

cc1101:
  cs_pin: GPIO27                     # D27 - Pin4
  frequency: 433.92MHz

remote_transmitter:
  pin: GPIO26       # Must match GDO0     # D26 - Pin3
  carrier_duty_percent: 100%
  id: transmitter0   # Adding for ir_rf_proxy
  on_transmit:
    then:
      - cc1101.begin_tx
  on_complete:
    then:
      - cc1101.begin_rx

remote_receiver:
  pin: GPIO25      # Must match GDO2      # D25 - Pin8
  dump: all
  id: receiver0      # Adding for ir_rf_proxy
  on_rc_switch: 
    then:
     - homeassistant.event: 
          event: esphome.rf_code_received
          data:
            code: !lambda 'return x.code;'

# IR_RF_Proxy Testing
infrared:
  # IR transmitter instance
  - platform: ir_rf_proxy
    frequency: 433.92MHz
    name: IR Proxy Transmitter
    id: ir_proxy_tx   # Corresponding ID added to remote_transmitter
    remote_transmitter_id: transmitter0
  # IR receiver instance
  - platform: ir_rf_proxy
    frequency: 433.92MHz
    name: IR Proxy Receiver
    id: ir_proxy_rx   # Corresponding ID added to remote_receiver 
    remote_receiver_id: receiver0

Your yaml for cc1101 looks just ok, but you don’t have anything that transmits here.
I can’t figure out what is your approach here, but did you notice the new proxy component?

1 Like

I have not seen the new proxy component that sounds like what I am looking for. My previous method was a primitive way to expose the results into Home Assistant as an “event” so it can be used in an automation.

I was able to add the IR/RF Proxy but do not see any exposed entities in home assistant. I will need to play with it more.


infrared:
  # IR transmitter instance
  - platform: ir_rf_proxy
    frequency: 433.92MHz
    name: IR Proxy Transmitter
    id: ir_proxy_tx   
    remote_transmitter_id: transmitter0 # Corresponding ID added to remote_transmitter
  # IR receiver instance
  - platform: ir_rf_proxy
    frequency: 433.92MHz
    name: IR Proxy Receiver
    id: ir_proxy_rx   
    remote_receiver_id: receiver0  # Corresponding ID added to remote_receiver 

Shouldn’t your comment be on the remote_receiver_id line??

Agreed, updating the comment line and the original YAML to include the ID.

Played around some more and somewhat verified my “structure” against a YAML I found infrared-proxies/xiao-ir-mate/xiao-ir-mate.yaml at eedf5e349b5ea1e5d3e30ef324b78dd49fd50e5e · esphome/infrared-proxies · GitHub but have not found how to interact with it.

For the sake of completeness, I had to use copilot to help me with the transmit part. With this setup you can transmit with actions esphome.esp32_cc1101_send_rf_rcswitch or send as raw but rcswitch is much more reliable.
Event esphome.rf_code_received should still work unless I broke something but this will only show you a good rcswitch decoded message.

To the best of my understanding the proxy is not ready for use yet so this is how I interface with it.

#     CC1101 Top view
#   -----------------------------------
#   | 1 GND   2 VCC         -----     |
#   | 3 GDO0  4 CSN        |     |    |ANTENNA
#   | 5 SCK   6 MOSI       |     |    |ANTENNA
#   | 7 MISO  8 GDO2        -----     |
#   -----------------------------------
#   1 - GND  - Ground
#   2 - VCC  - 1.8v-3.6v
#   3 - GDO0 - Module Out
#   4 - CSN  - Chip Select
#   5 - SCK  - SPI Clock
#   6 - MOSI - SPI IN
#   7 - MISO - SPI Out
#   8 - GDO2 - Module Out

esphome:
  name: esp32-cc1101
  friendly_name: esp32-cc1101

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "123456789"

  actions:
    - action: send_rf_rcswitch
      variables:
        code: string
        protocol: int
        repeats: int
      then:
        - remote_transmitter.transmit_rc_switch_raw:
            transmitter_id: transmitter0
            code: !lambda "return code;"
            protocol: !lambda |-
              int p = protocol;
              if (p < 1) p = 1;
              if (p > 8) p = 8;
              return esphome::remote_base::RC_SWITCH_PROTOCOLS[p];
            repeat:
              times: !lambda "return repeats;"
              wait_time: 0s

    - action: send_rf_raw
      variables:
        timings: int[]
        repeats: int
      then:
        - remote_transmitter.transmit_raw:
            transmitter_id: transmitter0
            carrier_frequency: 0Hz
            code: !lambda |-
              esphome::remote_base::RawTimings v;
              v.reserve(timings.size());
              for (auto &x : timings) v.push_back((int32_t) x);
              return v;
            repeat:
              times: !lambda "return repeats;"
              wait_time: 0s

ota:
  - platform: esphome
    password: "123456789"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Cc1101 Fallback Hotspot"
    password: "123456789"

captive_portal:
    
spi:
  clk_pin:  GPIO14                   # D14 - Pin5
  miso_pin: GPIO12                   # D12 - Pin7
  mosi_pin: GPIO13                   # D13 - Pin6

cc1101:
  cs_pin: GPIO27                     # D27 - Pin4
  frequency: 433.92MHz

remote_transmitter:
  pin: GPIO26  # Must match GDO0     # D26 - Pin3
  carrier_duty_percent: 100%
  id: transmitter0
  on_transmit:
    then:
      - cc1101.begin_tx
  on_complete:
    then:
      - cc1101.begin_rx

remote_receiver:
  pin: GPIO25  # Must match GDO2      # D25 - Pin8
  dump: 
    - raw
    - rc_switch
  id: receiver0
  on_rc_switch: 
    then:
     - homeassistant.event: 
          event: esphome.rf_code_received
          data:
            code: !lambda 'return x.code;'

# Webserver
#web_server:
#  port: 80

Future plans would be to migrate my WT32-ETH01 board with cc1101 over to this so I could have an ethernet based 433mhz sensor and Bluetooth proxy

ethernet:
    type: LAN8720
    mdc_pin: GPIO23
    mdio_pin: GPIO18
    clk_mode: GPIO0_IN
    phy_addr: 1
    power_pin: GPIO16

spi:
  clk_pin: GPIO14
  miso_pin: GPIO4
  mosi_pin: GPIO15

sensor:
  - platform: cc1101
    id: transceiver
    cs_pin: GPIO12
    gdo0: 
      number: GPIO2
      allow_other_uses: true
    gdo2: 
        number: GPIO35
        allow_other_uses: true
  
bluetooth_proxy:
    active: true