NiceMCU BK7238 development board gets an IR receiver on P21 and an inverted RGB LED on P6, P24, and P26 for remote-driven testing.
OBK scripts use startDriver IR plus addEventHandler2/addEventHandler3 to map RC6 codes like 0x1, 0x2, and 0x3 to colors or commands.
Enabling flag 14 or flag 21 sends IR events to Home Assistant over MQTT as raw RESULT payloads or Tasmota-style messages.
Home Assistant automations can react to those MQTT events, and OBK SendGET can control another device directly without Home Assistant.
The receiver worked only at 5V, and the same method also applies to BK7231T and BK7231N devices.
How can you receive IR events on a Tuya BK7238 device (T1, T5) using a development board or a universal remote? How do you forward IR codes to Home Assistant in Tasmota JSON format? How can you trigger HA automations with any remote? And how can you control another device directly from an IR receiver-without involving Home Assistant?
In this guide, I’ll walk you step-by-step through setting up a simple IR receiver on a BK7238 development board and scripting it to work with Home Assistant. I’ll also show you how to use it for direct device control, bypassing HA entirely.
Configuring the onboard LED For the purpose of this demo, I decided to use onboard RGB LED. The onboard LED resides on P6, P24 and P26, but logic levels are inverted. So, I had to set PWM_n (inverted) roles. Either do it manually in Config->Configure Module or import my template:
Code: JSON
Log in, to see the code
Now, you should get this on your main panel and be able to control the LED:
Configuring the IR receiver First you need to know IR receiver pinout. If you are reusing old receiver from old scrap board, follow the traces on PCB. Check for capacitors and ground plane. Check for silkscreen marking.
If you bought new IR receiver, then check manufacturer/seller datasheet.
Also check working voltage - for me, only 5V worked.
Here is my connection:
I chose P21 as IR input and configured it in Configure Module section:
IR events in OBK Web App Log Point your remote towards the receiver and press some button - observe the log.
As you can see, the 1, 2, 3 buttons on my remote have the following codes:
IR events in OBK You can script IR events directly in OBK. For example, you can use them to control LED. Create following autoexec.bat:
IR events in Home Assistant - raw format First enable flag 14:
Also make sure that you have MQTT configured.
Main panel will tell you if the connection has succeeded:
Then you can listen to device topic in Home Assistant:
IR events in Home Assistant - Tasmota format Just like before, but use flag 21.
Then, again, you can listen to device topic in Home Assistant:
IR automations in Home Assistant There are many ways to do it, let's start with simplest one.
First, let's assume you have some other device to control. Let's say, RGBCW bulb:
It's called obk_n_rgbcw_e27.
Now, let's create automation. First, set trigger to MQTT topic RESULT:
Then, the simplest way would be to set raw payload:
and set action to do:
You may also notice that sometimes IR data contains extra press/hold bit. You can handle both messages in single automation to work around it:
It works well now:
Here are my automation sources in YAML:
Code: YAML
Log in, to see the code
Code: YAML
Log in, to see the code
Direct control of another device without HA It is also possible to control another device directly, without Home Assistant. You can use OBK SendGet command for that. Here is a short sample controlling target light brightness via HTTP GET command:
Toggling light and initial press versus hold At some point you might want to send a TOGGLE command to a light. The correct way to do it is the following:
Summing up This is how you can control devices via IR receiver with OBK. You can either use Home Assistant automations or control them directly - via GET request.
This guide was made with BK7238 board, but the same logic applies for other supported Beken chips, like BK7231T or BK7231N.
Don't forget that OBK has also Berry script integration, which could be used to make more advanced logic.
That's all for now, if you have any question, just feel free to ask - we'll do our best to help.
You can also check our docs here: https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md and our devices list: https://openbekeniot.github.io/webapp/devicesList.html and our YT channel: https://www.youtube.com/@elektrodacom
About Author
p.kaczmarek2 wrote 14232 posts with
rating 12129 , helped 647 times.
Been with us since 2014 year.
nice. im glad there's the IR variant for BK7238. BK7238 seems to be gaining in popularity.
I have a new device with T1/BK7238/TuyaMCU coming to a new post soon.
Gave the new build a spin myself... [Read more]
p.kaczmarek2
10 Aug 2025 22:23
I think we can now try to connect WS2812 LED strip to it, P16 is nicely routed out on NiceMCU [Read more]
FAQ
TL;DR: Set up a BK7238 IR receiver, forward 20‑bit RC6 codes to Home Assistant, and trigger automations; “The third argument, 0, means ‘initial press’.” Use MQTT RESULT with Tasmota JSON or raw, or SendGET for direct device control. [Elektroda, p.kaczmarek2, post #21630993]
Why it matters: This lets Home Assistant users repurpose any IR remote for reliable local automations or direct cross‑device control on Tuya BK7238/T1 hardware.
How do I flash a NiceMCU BK7238/T1 with OpenBeken (OBK)?
Use BK7231GUIFlashTool, then follow the NiceMCU BK7238 quickstart and Tuya T1 datasheet posts for pinout and flashing. After flashing, configure Wi‑Fi and proceed to module configuration in the OBK web UI. The author links both guides and the flasher in the thread. [Elektroda, p.kaczmarek2, post #21630993]
Which IR pin and voltage should I use on BK7238?
Use an IR receiver module powered at 5 V, share ground, and route its signal to a configured GPIO (example: P21). Verify the receiver pinout by tracing PCB ground and checking silkscreen or the part’s datasheet. The author notes only 5 V worked in their build. [Elektroda, p.kaczmarek2, post #21630993]
How do I see IR codes from my remote in OBK?
Start the IR driver, point the remote at the receiver, and watch the OBK Web App Log. You will see entries with protocol, bit length, and hex code for each press. This lets you map buttons to actions or HA triggers. [Elektroda, p.kaczmarek2, post #21630993]
How can I map remote buttons to the onboard RGB LED?
How do I forward IR events to Home Assistant in raw format?
Enable flag 14 in OBK, configure MQTT, and confirm the connection on the main panel. In Home Assistant, subscribe to your device’s RESULT topic and capture payloads for automations. Use the displayed protocol, Bits, and Data fields in triggers. [Elektroda, p.kaczmarek2, post #21630993]
How do I forward IR to HA in Tasmota JSON format?
Enable flag 21 to publish Tasmota‑style JSON. Ensure MQTT credentials are correct. Then trigger automations on device/RESULT with the IrReceived payload.
Enable flag 21.
Verify MQTT connection on OBK main panel.
Create an MQTT trigger on deviceID/RESULT using IrReceived.Protocol/Data.
“You can handle both messages in single automation.” [Elektroda, p.kaczmarek2, post #21630993]
How do I avoid duplicate triggers from long button holds in HA?
Some IR protocols set a press/hold bit that repeats events. Add two MQTT triggers: one for Data like 0x2 and another for 0x10002. This catches initial press and the held variant predictably in one automation. The example YAML shows both triggers used together. [Elektroda, p.kaczmarek2, post #21630993]
Can I control another device directly over HTTP without Home Assistant?
Yes. Use SendGET in event handlers to call a device’s HTTP API. Example: add_dimmer ±10 on each press to http://192.168.0.212. Use addEventHandler3 with the third argument 0 to send “only on initial press” and reduce traffic. [Elektroda, p.kaczmarek2, post #21630993]
How do I send a single POWER TOGGLE only once per press?
Use addEventHandler3 and pass 0 as the third argument to bind only the initial press. Example: addEventHandler3 IR_RC6 0x0 0x1 0 SendGET http://IP/cm?cmnd=POWER%20TOGGLE. “The third argument, 0, means ‘initial press’.” This prevents repeated toggles while holding. [Elektroda, p.kaczmarek2, post #21630993]
Which MQTT topic should I use in HA?
Trigger on your device’s RESULT topic, for example obk8C10262A/RESULT. Match payloads like {"IrReceived":{"Protocol":"RC6","Bits":20,"Data":"0x2"}} in the trigger. Confirm the broker connection on OBK’s main panel before testing automations. [Elektroda, p.kaczmarek2, post #21630993]
Does OBK detect NEC remotes, and what bit length is used?
Yes. Test logs show NEC frames detected and reported as 32‑bit values in the OBK log. A salvaged IR receiver and a random consumer remote produced multiple NEC 32‑bit entries, confirming compatibility for common remotes. [Elektroda, divadiow, post #21631504]
Which IR library does OBK use, and is there an extended build?
Stock OBK uses an Arduino‑IRRemote port. An extended variant based on ESP8266IrRemote is available in releases for broader protocol support. Download it from the OpenBK7231T_App releases page linked in the post. [Elektroda, p.kaczmarek2, post #21630993]
Will these IR techniques work on BK7231T or BK7231N devices?
Yes. The same logic and event handling applies across supported Beken chips, including BK7231T and BK7231N. Configure pins, drivers, MQTT, and flags the same way, then reuse your OBK and HA patterns. [Elektroda, p.kaczmarek2, post #21630993]
How do I configure the onboard RGB LED correctly on NiceMCU?
Assign inverted PWM_n roles to P6, P24, and P26, because the RGB logic is inverted. You can set this in Configure Module or import the provided JSON template. Then control colors from the OBK main panel to validate. [Elektroda, p.kaczmarek2, post #21630993]
Where should I connect a WS2812 strip on NiceMCU BK7238?
Consider P16 for WS2812 data-in, as it is conveniently routed on the NiceMCU board. After wiring, select the appropriate LED driver in OBK and test animations. The suggestion comes directly from the author’s hardware note. [Elektroda, p.kaczmarek2, post #21631513]
IR events don’t show up in HA—how do I fix it?
Verify MQTT credentials and broker URL in OBK, then check that the main panel confirms a connection. Ensure the correct flag is set (14 raw or 21 Tasmota), and that your HA trigger listens on deviceID/RESULT with the exact payload. [Elektroda, p.kaczmarek2, post #21630993]
Comments
nice. im glad there's the IR variant for BK7238. BK7238 seems to be gaining in popularity. I have a new device with T1/BK7238/TuyaMCU coming to a new post soon. Gave the new build a spin myself... [Read more]
I think we can now try to connect WS2812 LED strip to it, P16 is nicely routed out on NiceMCU [Read more]