BK7231 RF receiver driver tutorial - how to use SYN590R or similar to control multiple devices
How to flash and configure RF remote receiver with open source firmware? How to use it to control relays and external devices, with and without Home Assistant? How to add custom remotes? Here's a short guide to RC (Radio Control) driver in OpenBeken, all basics covered. With this tutorial you'll be able to transform your simple RF relays controller into all-in-one RF control hub for many other Wi-Fi appliances, such as smart bulbs, LED strip controllers, external relay modules and much more.
Device used for presentation
The driver presented here can work with many devices and receivers, for presentation we used a popular Tuya 4-channel 220V AC Wi-Fi Remote Control Relay Switch Module 433 MHz RF from Aliexpress:
This board features CB3S (BK7231) Wi-Fi module, which can be flashed with OpenBeken.
The device comes with a single remote, more remotes can be bought separately:
This device features SYN590R (590R), which is connected directly to one of Wi-Fi module pads. It's not connected via external MCU, like on some devices, so in order to utilize it, Wi-Fi chip firmware must have a special driver for it. Luckily, there is such a driver in OBK!
For the flashing part, see our BK7231 flasher page. Our flasher, which is a recommended solution for Beken and other OBK-supported chips, can also detect device configuration:
Import the template and proceed to RF setup:
Basic guide for OBK RC driver
So, in order to run RC (Radio Control) driver in OBK, you need to set the RCRecv pin (check PCB trace or extract Tuya config if possible) and start the driver with startDriver RC command. Then you will get events and codes in OBK console:
We may add more information or hex format for codes in the future, but the core functionality will remain the same.
Then, to handle events, use the event handler in autoexec.bat:
addEventHandler2 RC 591946 0 POWER TOGGLE
First argument is always RC, second is remote control code, third is held state - first press has 0 value, further repeats (when the button is held) have a value of 1 there.
If you don't know how to create autoexec.bat, see guide:
https://www.youtube.com/watch?v=kXi8S12tmC8
Comparison with Tasmota
For the comparison purposes, we've hooked ESP32 flashed with Tasmota to the same receiver:
This way, both Tasmota and OBK can see the same signal:
OBK currently uses decimal format for RF code, but a little conversion can clearly show us that the codes are matching, so both solutions are interchangeable.
Sample device config (autoexec.bat)
Sample autoexec.bat was based on OBK documentation. It's designed to showcase control of both the same RF device (relays), and other devices directly via their IPs.
The procedure to create autoexec.bat is simple - we just test the remote with OBK console open to see what the code is, and then write the code down.
Autoexec.bat can be rerun without restarting OBK device in many cases, so it's easy to develop quickly.
// addEventHandler RC 1234 toggleChannel 5 123
// on first receive
// addEventHandler2 RC 1234 0 toggleChannel 5 123
// on hold
// addEventHandler2 RC 1234 1 toggleChannel 5 123
addEventHandler2 RC 591944 0 ToggleChannel 1
addEventHandler2 RC 591940 0 ToggleChannel 2
addEventHandler2 RC 591948 0 ToggleChannel 3
addEventHandler2 RC 591938 0 ToggleChannel 4
addEventHandler2 RC 591937 0 PowerAll 1
addEventHandler2 RC 591950 0 PowerAll 0
// sample of external device control
addEventHandler2 RC 591946 0 SendGet http://192.168.0.58/cm?cmnd=Power0%20Toggle
And here is short presentation - first control of the relays device itself:
Then usage of RF device as a gateway to control another device via HTTP GET - the LED strip controller is under the table, it's the device with 192.168.0.58 IP, as you can see in autoexec.bat:
Home Assistant support
We're also working on Home Assistant support - it should be released within upcoming days. The published RF format will match Tasmota standard, as can be seen there: https://tasmota.github.io/docs/RF-Protocol/
Summary
The following method should work with many RF receivers, including STX882 and so on. It allows you to reuse cheap 433 MHz RF hardware as a flexible automation input without relying on cloud services or vendor firmware. Thanks to event handlers and HTTP/MQTT integration, RF buttons can trigger virtually any action in your local network. The solution scales well, from simple relay toggling to complex multi-device scenes and automations. Combined with MQTT Home Assistant support, OpenBeken turns RF receivers into a powerful and fully open smart-home control layer.
Do you have any devices with RF inputs? Let us know!
Comments
One thing to note is that the remotes that come with these type of devices are Princeton protocol RF remotes. OBK driver recognizes Roger protocol as well and we didn't test beyond that right now but it... [Read more]
great work guys! regarding this standard mini breaker/switch with RF on P8 https://obrazki.elektroda.pl/5081148700_1765829028_thumb.jpg https://obrazki.elektroda.pl/8964425900_1765829028_thumb.jpg... [Read more]
By the way, do you remember those switches where 480RA RF receiver is connected to buttons controller MCU, and not to Wi-Fi module? Like there: https://www.elektroda.com/rtvforum/topic4110013.html I... [Read more]
well, yes, though it seems I do have one of those switch types but it does contain remote_io in the config - Bingoelec W601 T34 . On the other hand, the two other devices I posted about here do... [Read more]
Ah, I think the board on photos has USB port, so it's 5 V powered, it's just that I found the 230V-powered version and put the schematic of that. Thanks for updating template! RC driver should be... [Read more]
just confirming, is RCRecv an assignment that requires a channel or is the channel field just not auto-hiding like it does for some? [Read more]
Channels are not used. This should be hidden. Please hide, if you can. The RF receiver has a single instance and works on only one pin, multiple pins are not supported yet. [Read more]
https://obrazki.elektroda.pl/5983467900_1766003086_bigthumb.jpg also IOR_BL0937_SEL_n was missing and IOR_LED_WIFI_n was there twice descriptions ok too? https://github.com/openshwproje... [Read more]
Yes, sure, merged. You may also run docs update now, or I'll run it later. [Read more]
just trying to work out why these are getting generated https://obrazki.elektroda.pl/8815955100_1766005052_thumb.jpg [Read more]
Probably the xml has name with prefix IOR_ and it doesn't like it and tries to create it without this prefix. Solution: remove manually IOR_ prefix from xml before running getcommands.js [Read more]
found it https://github.com/openshwprojects/OpenBK7231T_App/pull/1905/files#diff-88e5c3500e4bdb2c9a6393afa90653737ecfcaab139d663370f3c95d6d18b5e3 [Read more]
Maybe again a point to advocate for a PR I made some time ago to put all "IOR", description, number of channels... in a separate file and generate the source code for new_pins.h and so on (first PR 1773... [Read more]
all sounds very good! [Read more]
I currently think that's adding extra dependency for a little gain. Wouldn't it be better to just .... fix getcommands.js to handle missing/extra IOR_ prefix correctly? I would like to avoid forcing... [Read more]
The "problem" I saw is, that you need to change code in different locations, and every change has the (small) chance you break of forget something. Especially for the forgetting part a one-stop-change... [Read more]