Sending RF Signals with Sonoff RF Bridge

I previously published an article on using the Sonoff RF bridge to expand your smarthome. That article focused on receiving and processing RF signals from devices. However, the Sonoff RF Bridge can also send RF signals to your devices and I’ll show you a couple of ways to do it.

Sending Sonoff RF Signal

Why send RF signals?

Hopefully, you learned the value of receiving signals from my previous Sonoff RF Basic article. The ability to interpret signals from RF devices like remotes, door/window sensors and motion detectors allows you to create automations using inexpensive RF devices.

However, there are also potential smarthome devices that receive RF signals. I have an inexpensive LED strip like this one that receives commands via an RF remote. Wouldn’t it be nice to have a script or automation controller like Home Assistant be able to control the lights?

Another use is for remote light switches. I have a bathroom light switch located in an inconvenient location. I’m considering buying a remote RF light switch kit so I can place the wall switch where I want it. I want all my lights controllable by Home Assistant, so I’d need to be able to send RF signals.

There are many other devices controlled by RF signals. If they are 433Mhz, then you can probably control them using the instructions below.

What you need to send RF Signals

  • Sonoff RF Basic flashed with Tasmota
  • MQTT Broker – (optional – can be done using web commands or through the Tasmota console, but this is how I’ll do it). Here are instructions to get started with MQTT using Docker.
  • MQTT Client – (If you aren’t using MQTT to communicate with Tasmota, you don’t need this). I’ll be using Mosquitto pub (MQTT Setup article for more details).
  • RF Device. I’ll be using the aforementioned LED strip in this example.
See also  Top Home Automation Trends for 2024

Method 1: The easy way to capture and send signals

The Sonoff RF Basic flashed with Tasmota has 16 RF signal memory slots. you can simply learn in the signal and then press the button (or use a Sonoff command via the console, MQTT, or web request).

Step 1: Capture RF Signals into a button

For this and many of the next steps, it is important to learn how to send commands to Tasmota using MQTT, and specifically in my case, mosquitto_pub. You can translate these instructions to the other ways to send commands using this Tasmota reference.

The MQTT topic format for sending commands via MQTT to Tasmota is:

cmnd/%topic%/<command> <parameter>

First, you have to find out what Topic your Tasmota is using. For this, you can go to the Tasmota web UI and select the “Information” button and look for “MQTT Full topic”. In my case, the Tasmota topic of note is:

cmnd/sonoffRF/

To tell Tasmota to learn a command we have to use the rfkey<x> command. The x represents which of the 16 keys we want to learn the command into. We would send this command using mosquitto_pub in the following manner:

mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfKey1" -m "2"

Let’s break this command down:

  • Replace mqttuser and mqttpassword with the appropriate parameters that you use for your MQTT broker. If you don’t use a username and password, you can delete these.
  • Replace <mqttbroker> with the IP/hostname of your MQTT broker
  • cmnd/sonoffRF/RfKey1 represents the topic that says to use slot number 1 for this command. You can replace this with any number between 1 and 16.
  • -m “2” is the payload that tells the Sonoff RF Bridge that you want to learn in a code to the key you specified in the topic.
See also  Home Assistant: Migrating to Z-Wave JS

Once you enter this command, the Sonoff RF Bridge will beep once and then one of the lights will flash red real fast. Press the button on your remote that you want to learn in. The bridge will beep twice when the code is learned in.

Sonoff Red Light Blinks in Learning Mode
Sonoff Red Light Blinks in Learning Mode

Step 2: Send RF Signals

Now that we’ve learned the RF signal we can send the signal one of two ways. The first way is to simply press the button in the Sonoff UI and it will send the signal. The second way is to send the Sonoff RF Bridge a command using MQTT:

mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfKey1" -n

Replace the parameters appropriately. The -n option simply sends a null payload as no attribute is needed for this command. Now you can send an RF command using MQTT!

Method 2: The scalable way to capture and send signals

The problem with the “easy” way is that you can only learn in 16 different commands at a time. If you want to use more than that, you can have the Tasmota send RF commands with the data you specify, as opposed to having it memorize different commands.

This method requires you go to the Tasmota web UI and look at the console. As you send an RF signal you’ll see a line in the console that looks similar to:

tele/sonoffRF/RESULT = {"RfReceived":{"Sync":12180,"Low":430,"High":1240,"Data":"D10610","RfKey":"None"}}

Make note of the data that follows the Sync, Low, High, and Data parameters. using these parameters you can send the command using a series of MQTT commands:

mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfSync" -m "12200"
mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfLow" -m "430"
mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfHigh" -m "1250"
mosquitto_pub -u "mqttuser" -P "mqttpassword" -h <mqttbroker> -t "cmnd/sonoffRF/RfCode" -m "#D10601"

Not the “#” character that precedes the RfCode payload. This will send the same RF signal Tasmota saw when the RF button was pressed.

See also  The State Of My Smart Home (2024)

While this method takes a few more commands and requires you to record data, it does allow you to send as many different RF commands as you want!

Final thoughts

Now you know how to both send and process RF signals using the Sonoff RF Basic flashed with Tasmota. This allows me to process and control many different RF devices from Home Assistant using MQTT.

If you are interested in sending IR signals instead of RF signals, be sure to check out my review of the BroadLink RM4 Mini. BroadLink also makes devices that control RF and IR devices.

Do you have any plans to use RF devices in your smarthome? Tell me about it and what you thought of this article in the comments or on Twitter!

This page contains affiliate links. If you purchase an item using an affiliate link I will receive a small commission at no cost to you. Affiliates do not influence my recommendations. Read my disclosures for more information.

Share this:

Sending RF Signals with Sonoff RF Bridge

by HomeTechHacker time to read: 5 min