Using a Sonoff RF Bridge with ESPHome & Portiche Firmware with no hardware hacking

I ordered a sun awning with a tubular motor expecting it to have a four core flex attached (open, close, earth, neutral). When it arrived it had a motor fitted with integrated 433mhz receiver and only a three core flex attached.

That blew my plans of using a Sonoff duo to control it out of the water.

Instead it led me down the rabbit hole of RF.
I searched for reasonable priced RF bridges and the sonoff one seemed great at only £8.
The trouble is most people seem to have had to chop it to bits and patch wires and resistors all over to get it to do what they want. I didn’t like the idea of that.

Here’s what I did to get it working with a Dooya motor.

Flashing the bridge:
The bridge contains two main chips with seperate firmware. An esp8266 and also an RF specific chip.

I wanted to use esphome as I use this elsewhere and wanted to make use of the time based cover component.

The problem is the RF chip is locked down to sonoff signals so it needs to be flashed also. I couldn’t find a way to do this through esphome but tasmota provided a simple solution.

I opened up the bridge by removing the four screws underneath. Gentle bending up the large led panel, gives you access to an RF switch and the headers.

I turned off the RF switch and connected my usb serial interface to the headers closest to the LEDs legs. Holding the only button I plugged in the usb interface and provided power to the bridge.

Using espflasher I uploaded tasmota.bin to the bridge.

The bridge then set up a hotspot, which I connected to on my phone and configured my WiFi details.
Scanning for devices on my network I was able to find the op used by the bridge and load it in my browser.
I then configured the bridge as a Sonoff RF Bridge (25). It reboots.

Flashing the RF chip:
Tasmota makes it easy to flash the RF chip, however this can’t be done if you are using the usb socket to power it during the flash, instead you need to keep the 3v3 and gnd wires from the serial interface connected for powering the bridge during this next step.
Also it’s necessary to put two bridge wires in place (I didn’t solder just wedges them in place) gpio4 to c2d and gpio5 to c2ck. This allows the firmware to be sent from the esp to the RF chip
The RF firmware can be found here: https://github.com/arendst/Tasmota/tree/master/tools/fw_SonoffRfBridge_efm8bb1

With the bridge wires in place, go to the tasmota web interface and click firmware update, upload the RF firmware and click update. A few seconds and it’s done.
Now all the temporary wires can be removed and the RF switched can be turned back on. The bridge can be reassembled and powered by usb.

Now in the tasmota interface load the console.
Type rfraw 177, press enter

Press the open button on the RF remote 4 or 5 times.
The raw RF data will be shown on the console.
Copy and paste this into notepad.

Repeat for the other buttons.

An online tool called bitbucket convertor is used to convert this data into codes you can send to control the motor. Follow their instructions for this bit.

Now you can replace tasmota with ESPHome using the firmware update system we used earlier.

Here’s my esphome config.

esphome:
  name: rfbridge
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: "myssid"
  password: "my password"

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Rfbridge Fallback Hotspot"
    password: "another password"

captive_portal:

ota:
  password: "and another"
api:
  password: "and another"

#this is important as the RF chip talks to esp on these pins at this baud rate
uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 19200
#need to disable uart logging as it will interfere
logger:
  baud_rate: 0

#this allows ha to when RF signals are received, I'm not using this for anything yet.
rf_bridge:
  on_code_received:
    then:
      - homeassistant.event:
          event: esphome.rf_code_received
          data:
            sync: !lambda 'char buffer [10];return itoa(data.sync,buffer,16);'
            low: !lambda 'char buffer [10];return itoa(data.low,buffer,16);'
            high: !lambda 'char buffer [10];return itoa(data.high,buffer,16);'
            code: !lambda 'char buffer [10];return itoa(data.code,buffer,16);'

# the interesting bit, controlling the awning motor
cover:
  - platform: time_based
    name: "Sun Awning"
    device_class: awning
    assumed_state: true
    has_built_in_endstop: true

    open_action:
      - rf_bridge.send_raw:
          raw: "output from bitbucket converter with spaces removed"
    open_duration: 60s

    close_action:
      - rf_bridge.send_raw:
          raw: "output from bitbucket converter with spaces removed"
    close_duration: 60s

    stop_action:
      - rf_bridge.send_raw:
          raw: "output from bitbucket converter with spaces removed"

Compile and upload and all working perfectly. A cover is available for control in ha.
This took me a few hours because.i.was having to put together pieces of instructions from about 6 different sites. I hope this helps someone else.

8 Likes

Just wanted to give a shout out: I have been in the exact same situation as you, but with a ventilator in our kitchen instead.

After a bit of trial and error I now have access to send my old Raw codes found using the method described here: Sonoff RF Bridge 433 - Tasmota

I use the following bit of code in Esphome (in case other need it):

api:
  services:
    - service: send_rf_code
      variables:
        sync: int
        low: int
        high: int
        code: int
      then:
        - rf_bridge.send_code:
            sync: !lambda 'return sync;'
            low: !lambda 'return low;'
            high: !lambda 'return high;'
            code: !lambda 'return code;'
    - service: send_rf_raw
      variables:
        raw: string
      then:
        - rf_bridge.send_raw:
            raw: !lambda 'return raw;'

Thanks!

1 Like

@samnewman86 Thx for this clear explanation, worked perfectly for my Sonoff RF Bridge that had already Tasmota with the Portisch firmware. After I uploaded the ESPHome bin everything kept working only no more mqtt needed :slight_smile:
Ps. I first had to rol back to the tasmota_minimal.bin to be able to upload the ESP firmware.

1 Like

Hi to all,

Sorry to re-use an old post but this one is the more relevant !

I followed exaclty the same path as @ samnewman86 :

Stock RF Bridge (No hardware hack)
Flashed Tasmota with FTDI usb adapter
Flashed RF chip with success
At this point I can execute “rfraw 177” in console and receive codes from an RF remote.

Frome there, I upload my ESPHOME again using the FTDI usb adapter.
It gets an IP, the API connect to HomeAssistant … but I cannot read any codes !
I press buttons on my remote and the RF red led does not come up and I don’t receive any events.

Anything I forgot ?

Thanks !

the switch was set to its original position?

Yes finally figured that need to sniff with RTL_433 on my raspberry Pi and then send the raw codes to RF Bridge.

For some reason, raw sniffing is not working on the bridge Thanks !

Did you try Tasmota or Portisch on Sonoff RF bridge R2 ?

Does Portisch improve things very much when compared to the code used by EspHome?