Ethernet 433MHz gateway with ESP32-POE (using ESPHome)

In my other post, I mentioned using ESP32-POE as a hard-wired alternative to the standard Wifi-based ESP8266 and ESP32.

I’ve been getting more and more 433MHz devices at home, so wanted to set up a 433MHz gateway to handle sending / receiving codes via RF. I ended up implementing this using the Olimex ESP32-POE, along with a 433MHz receiver (RXB6) and 433MHz transmitter (STX882).

My overall goal was to use this 433MHz gateway within HA to send RF codes to our fireplace, as well as receive codes from various button switches scattered around the house. I bought a bunch of different button switches from here:

Part of the fun was decoding the RF codes sent by these various button switches. I used Universal Radio Hacker, which is a great piece of software, along with a cheap USB dongle connected to my Windows 10 laptop.

Thanks to ESPHome, I was able to implement a single button press (i.e. click), as well as longer button press (i.e. hold), for each button. One example of using this is controlling music in one of our rooms. A single button press starts playing music (using Squeezebox), or skips to the next song (if already playing). A long press (i.e. hold) stops playback. My wife and son love these buttons since they are so simple to use and convenient to mount wherever a simple action is required. Of couse, these actions are also available via the usual mechanisms (i.e. HA frontend, Google Assistant, etc.)

In any case, below is the YAML from my ESPHome setup. I’ve only included one of these button switches (rounded one with a single button), to keep it simple. I’ve also included the fireplace (Mertik Maxitrol) as well as one of our doorbells (Arlec).

esphome:
  name: esp32_poe_2
  platform: ESP32
  board: esp32-poe

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12

logger:

api:

ota:

remote_transmitter:
  pin: GPIO32
  carrier_duty_percent: 100%

remote_receiver:
  pin: 
    number: GPIO33
    inverted: True
    mode: INPUT_PULLUP
  filter: 200us # default = 10us
  idle: 4ms # default = 10ms
  on_rc_switch:

binary_sensor:

# Arlec Doorbell

  - platform: remote_receiver
    name: Arlec Doorbell
    raw:
      code: [ -1080, 1080, -360, 1080, -360, 1080, -360, 1080, -360, 360, -1080, 360, -1080, 1080, -360, 360, -1080, 360, -1080, 1080, -360, 1080, -360, 360, -1080, 360, -1080, 360, -1080, 360, -1080, 360, -1080, 360, -1080 ]
    filters:
      - delayed_off: 1000ms

# Fireplace

  - platform: remote_receiver
    name: Fireplace On
    rc_switch_raw:
      code: '1010011110011'
      protocol:
        pulse_length: 380
        sync: [45, 1]
        zero: [1, 2]
        one: [2, 1]
        inverted: true
    filters:
      - delayed_off: 1000ms

  - platform: remote_receiver
    name: Fireplace Off
    rc_switch_raw:
      code: '1010011110111'
      protocol:
        pulse_length: 380
        sync: [45, 1]
        zero: [1, 2]
        one: [2, 1]
        inverted: true
    filters:
      - delayed_off: 1000ms

  - platform: remote_receiver
    name: Flame Up
    rc_switch_raw:
      code: '1010011111011'
      protocol:
        pulse_length: 380
        sync: [45, 1]
        zero: [1, 2]
        one: [2, 1]
        inverted: true
    filters:
      - delayed_off: 1000ms

  - platform: remote_receiver
    name: Flame Down
    rc_switch_raw:
      code: '1010011111101'
      protocol:
        pulse_length: 380
        sync: [45, 1]
        zero: [1, 2]
        one: [2, 1]
        inverted: true
    filters:
      - delayed_off: 1000ms

# Round 1 Key Button

  - platform: remote_receiver
    id: round_1_key_button
    name: Round 1 Key Button
    rc_switch_raw:
      code: '110011010000010110101000'
      protocol:
        pulse_length: 300
        inverted: true
    filters:
      - delayed_off: 100ms
    on_click:
    - min_length: 50ms
      max_length: 350ms
      then:
        - homeassistant.event:
            event: esphome.button_pressed
            data:
              entity_id: binary_sensor.round_1_key_button
              button_press_type: 'single'
    - min_length: 350ms
      max_length: 5s
      then:
        - logger.log: 'Hold'
        - homeassistant.event:
            event: esphome.button_pressed
            data:
              entity_id: binary_sensor.round_1_key_button
              button_press_type: 'hold'

switch:

# Arlec Doorbell

  - platform: template
    name: Arlec Doorbell Switch
    icon: "mdi:bell"
    id: arlec_doorbell_switch
    turn_on_action:
      - remote_transmitter.transmit_raw:
          carrier_frequency: 433MHz
          code: [ 1080, -1080, 360, -1080, 360, -1080, 360, -1080, 360, -360, 1080, -360, 1080, -1080, 360, -360, 1080, -360, 1080, -1080, 360, -1080, 360, -360, 1080, -360, 1080, -360, 1080, -360, 1080, -360, 1080, -360, 1080 ]
          repeat:
            times: 60
            wait_time: 5ms

  - platform: template
    name: Arlec Doorbell
    icon: "mdi:bell"
    turn_on_action:
    - switch.turn_on: arlec_doorbell_switch
    - delay: 500ms
    - switch.turn_off: arlec_doorbell_switch
  
# Fireplace

  - platform: template
    name: Fireplace
    icon: "mdi:fireplace"
    optimistic: true
    assumed_state: true
    turn_on_action:
#      - remote_transmitter.transmit_raw:
#          carrier_frequency: 433MHz
#          code: [ 380, -380, 380, -760, 760, -380, 380, -760, 380, -760, 760, -380, 760, -380, 760, -380, 760, -380, 380, -760, 380, -760, 760, -380, 760, -17200 ]
#          repeat:
#            times: 120
      - remote_transmitter.transmit_rc_switch_raw:
          code: '1010011110011'
          protocol:
            pulse_length: 380
            sync: [1, 45]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 120
            wait_time: 10ms
    turn_off_action:
#      - remote_transmitter.transmit_raw:
#          carrier_frequency: 433MHz
#          code: [ 380, -380, 380, -760, 760, -380, 380, -760, 380, -760, 760, -380, 760, -380, 760, -380, 760, -380, 380, -760, 760, -380, 760, -380, 760, -17200 ]
#          repeat:
#            times: 60
      - remote_transmitter.transmit_rc_switch_raw:
          code: '1010011110111'
          protocol:
            pulse_length: 380
            sync: [1, 45]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 60
            wait_time: 10ms

  - platform: template
    name: Flame
    icon: "mdi:fire"
    optimistic: true
    assumed_state: true
    turn_on_action:
#      - remote_transmitter.transmit_raw:
#          carrier_frequency: 433MHz
#          code: [ 380, -380, 380, -760, 760, -380, 380, -760, 380, -760, 760, -380, 760, -380, 760, -380, 760, -380, 380, -380, 380, -760, 760, -380, 760, -17200 ]
#          repeat:
#            times: 60
      - remote_transmitter.transmit_rc_switch_raw:
          code: '1010011111011'
          protocol:
            pulse_length: 380
            sync: [1, 45]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 60
            wait_time: 10ms
    turn_off_action:
#      - remote_transmitter.transmit_raw:
#          carrier_frequency: 433MHz
#          code: [ 380, -380, 380, -760, 760, -380, 380, -760, 380, -760, 760, -380, 760, -380, 760, -380, 760, -380, 760, -380, 760, -380, 380, -760, 760, -17200 ]
#          repeat:
#            times: 60
      - remote_transmitter.transmit_rc_switch_raw:
          code: '1010011111101'
          protocol:
            pulse_length: 380
            sync: [1, 45]
            zero: [1, 2]
            one: [2, 1]
          repeat:
            times: 60
            wait_time: 10ms

# Round 1 Key Button

  - platform: template
    name: Round 1 Key Button Switch
    icon: "mdi:remote"
    id: round_1_key_button_switch
    turn_on_action:
      - remote_transmitter.transmit_rc_switch_raw:
          code: '110011010000010110101000'
          protocol:
            pulse_length: 300
          repeat:
            times: 5
            wait_time: 9ms

  - platform: template
    name: Round 1 Key Button
    icon: "mdi:remote"
    turn_on_action:
    - switch.turn_on: round_1_key_button_switch
    - delay: 250ms
    - switch.turn_off: round_1_key_button_switch

You can see above how the button is implemented as both a binary sensor (via the remote receiver) and a switch (via the remote transmitter). Exposing the button as s switch is overkill, but it means that I can basically simulate pressing the real button by controlling the switch within HA, since the gateway can send the exact codes as sent by the button switches.

image

Here are some photos showing the ESP32-POE and the custom enclosure I designed in TinkerCad. I drilled a few holes in the lid to allow the antennae to protrude. There is a separate compartment for the RF transmitter, and also one for the RF receiver. The lid snaps onto the box nicely.

Overall, it works really well. I’m impressed with how reliable the ESP32-POE is and the fact that it just works out of the box with ESPHome. Along the way, I’ve also learnt a lot about decoding 433MHz protocols.

12 Likes

Hi Petar

Could you share a wiring diagram of how you connected the RXB6 and STX882 to ESP32 and the code used to read and transmit data?

I am attempting to do the same, but unable to get it to work.

Nozomi

Hi @Nozomiboy

I don’t have a wiring diagram but there’s not much to show really. The transmitter’s and receiver’s DATA pins are connected to GPIO32 and GPIO33 on the ESP32 board, respectively.

The image here shows where the GPIO pins are located on the board:

The code used to transmit data is all contained in the ESPHome config I pasted earlier.

Any assistance on how you used Universal Radio Hacker to get the proper raw commands. I am trying to control an awning that is using 433mhz. I used uniersal radio hacker to sample the data which ends up looking like this:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa855 [Pause: 4343 samples]
aa656a65a965559a95a6a995aaa5aa654 [Pause: 6351 samples]

But not sure how to convert that to something esphome expects in the raw.

Hello @pkozul! Could you please share in a bit more detail how you used URH to find the data to use in ESPHome? I’ve read an RF signal, found what I think is the modulation, but I have no idea what to set sync, zero and one to. RC-switch also complains my string is too long. Any insight on your process would be greatly appreciated :blush:

@pkozul would you be open to sharing your case design? :slight_smile:

Hi, did you ever figure out how to do that?

I figured out that my awning was using rolling codes and gave up at that point. Went with the HACK solution of wiring an esp32 to the buttons on the remote. It works and is reliable, even power the remote section from the USB so no battery to worry about.