logo elektroda
logo elektroda
X
logo elektroda

OpenBeken BK7231N IR raw code capture issue on v1.18.110, drv_ir.cpp, MQTT shows 0x0, missing raw data

User question

I'm still struggling to get some raw IR codes.
The bk7231N device GPIOs are correctly configured as it receives some IR information.
Built on Jun 4 2025 10:35:45 version 1.18.110 but not a nightly or alpha.
commands like set IrDbg 1 do not work. nor does set system.ir.debug 2 of set system.ir.rawdata 1. They just return this error:
Info:CMD:[WebApp Cmd 'set IrDbg 1' Result] Unknown command

The device receives the IR remote but only says this:
Debug:IR:IR decode returned true, protocol 1
Debug:IR: Raw-Data=0x0
Debug:IR: 48 bits
Debug:IR: LSB first
Debug:IR:IR decode returned true, protocol PulseDistance (1)
Info:IR:IR MQTT publish IR_PulseDistance 0xD21 0xD0A 0 (48 bits) took 4ms
Debug:IR:IR fire event took 0ms

I've enabled some flags 14, 15, 22 to print raw IR, including to MQTT.
But on MQTT I also get empty IR raw data, like this:
{"IrReceived":{"Protocol":"PulseDistance","Bits":48,"Data":"0x0"}}
{"IrReceived":{"Protocol":"UNKNOWN","Bits":0,"Data":"0x0"}}

Does this build not include the correct IR drivers? I see in the code repository there are three different IR drivers, drv_ir.cpp, drv_ir2.cpp and drv_ir_new.cpp.
Or is the remote code possibly so long that it doesn't fit in the buffers? Should I build it myself, with different parameters, or is there a known good build that supports IR better?

Artificial Intelligence Response

Direct answer to the question

• The public 1.18.110 “stable” image you are running was built with the legacy ­drv_ir.cpp receiver, compiled without the raw-pulse or extended debug code.
• Because of that, console commands such as IrDbg, system.ir.debug, system.ir.rawdata, and the MQTT “raw pulse array” (Flag-22) are simply not present, so the firmware can only report a decoded value (PulseDistance) and that value is always zero in this driver revision.
• To capture real raw IR timings you must either
– flash a current nightly/release candidate that is built with drv_ir_new.cpp (IRremoteESP8266-based) and OBK_FLAG_IR_LOG_PULSES_AS_ARRAY, or
– build OpenBeken yourself and enable the IR-RAW/DEBUG options (and, if required, enlarge the raw buffer).
• 48-bit “PulseDistance” frames fit in the default 120-entry buffer, so the missing data is not due to length; it is purely a firmware-build / driver issue.


Detailed problem analysis

  1. Firmware / build details
    Built on Jun 4 2025 10:35:45 – v1.18.110 is an official pre-compiled “stable” that still uses the first-generation IR driver (drv_ir.cpp).
    • This driver supports basic receive + decode but does not expose
    – raw mark/space logging,
    – MQTT pulse array,
    – the console helpers you tried (IrDbg, system.ir.*).
    • Starting with commit 1864be8 (2024-11-14) OpenBeken switched to drv_ir_new.cpp, integrating the upstream IRremoteESP8266 2.x library; all new debug commands, flags 14/15/22 and the large raw buffer live in that branch.

  2. Why you see Data=0x0
    • In the legacy driver results->value is filled only when the PulseDistance decoder recognises exact leader/bit timings; any mismatch returns zero while still reporting “decode OK”.
    • Your remote is accepted as “generic PulseDistance, 48 bits” but the timings are outside the table → hex value is cleared → MQTT sends { "Data":"0x0" }.
    • The true raw timings were never stored (no buffer) so there is nothing to publish.

  3. Buffer length consideration
    • Default RAW_BUFFER_LENGTH in IRremoteESP8266 = 120 marks/spaces → supports up to ~58 bits (+header+stop).
    • Your 48-bit frame is well within this limit, so buffer overflow is not the root-cause.
    • If you later need to capture very long frames (air-conditioner remotes 200->400 entries) set
    #define RAW_BUFFER_LENGTH 300 (or more) before building.

  4. Driver variants in the tree File Status Features (Rx) Notes
    drv_ir.cpp Legacy / size-optimised (stable) NEC/Sony/PulseDistance decoding NO raw logger, small code size
    drv_ir2.cpp Tx-only helper Sends fixed codes Not used for receive
    drv_ir_new.cpp Current mainline (nightly ≥ 1.18.18x) Full IRremoteESP8266 Rx/Tx, raw Needs 36 kB flash / bigger RAM section

Current information and trends

• Since January 2025 nightlies include Driver-V2 by default for BK7231N/T.
• New console interface:

 startDriver IRRecv // loads IR subsystem
setFlag 22 1 // pulse array to log
setFlag 15 1 // JSON to MQTT
IRRaw 1 // toggle raw-pulse print on console

• Home-Assistant autodiscovery now exposes an ir_raw sensor (added May 2025).
• Planned (Q3 2025): compile-time “micro build” without IR code to reclaim ~48 kB on very small modules; normal builds will keep drv_ir_new.cpp.


Supporting explanations and details

• How to enlarge raw buffer (example diff):

 // components/irremote/IRrecv.h
#ifndef RAW_BUFFER_LENGTH
#define RAW_BUFFER_LENGTH 300 // default 120
#endif

• Typical raw array published when everything works:

 IR_RAW: {9050,4500, 560,560, 560,1690, 560,560, ... } // μs

• The triad in your log IR_PulseDistance 0xD21 0xD0A 0 corresponds to
– header mark (0xD21 = 3361 µs)
– header space (0xD0A = 3338 µs)
– repeat gap (0) → legacy diagnostics only.


Ethical and legal aspects

• Capturing and reproducing IR codes may infringe on copyright or regional regulations when used to duplicate protected devices (set-top boxes, gated-entry systems).
• Verify that retransmission power stays within IR-LED safety limits (<100 mA continuous, avoid retinal hazard from high-power 940 nm emitters).


Practical guidelines

  1. Flash a nightly with IR-V2
    OpenBK7231N_QIO_IR_1.18.195.bin (or newer).
    • After flashing:

     startDriver IRRecv
    setFlag 22 1
    LogLevel 3 // or 'Debug'
  2. Self-build (Docker example)

    docker run --rm -v %CD%:/src openbeken/builder \
    make BK7231N IR_DRIVER_NEW=1 RAW_BUFFER_LENGTH=300
  3. MQTT message filtering
    • Topic: device/IRRaw → use Home-Assistant template to store and decode.

  4. Troubleshooting checklist
    • Confirm receiver pin: pin 6 -> IRRecv in “Configure Module”.
    • Check console help for IRRaw, IRSend.
    • If log still empty, verify 38 kHz demodulator is powered (Vcc = 3.3 V, OUT idle HIGH).


Possible disclaimers or additional notes

• Nightly builds occasionally change command names; consult CHANGELOG.md.
• Extremely long A/C frames (>100 ms) may still overflow even 300-entry buffer; upstream fix pending.
• Legacy web-app caches old command list; do a forced refresh (Ctrl-F5).


Suggestions for further research

• Investigate adding IRMP multi-protocol core (smaller, good European protocols).
• Study ESP32-RMT style DMA capture to avoid buffer limits on BK72xx.
• Contribute test-vectors of exotic 48-bit PulseDistance remotes to the OpenBeken repository.


Brief summary

The firmware you flashed was compiled without the new IR subsystem; therefore the console commands and raw-pulse output you expect do not exist, and every packet decodes to 0x0.
Install a current nightly (or self-compile) that uses drv_ir_new.cpp with raw logging enabled; your 48-bit codes will then appear as a full mark/space array and publish correctly over MQTT. Increase RAW_BUFFER_LENGTH only if you later need to capture very long frames such as air-conditioner remotes.

Disclaimer: The responses provided by artificial intelligence (language model) may be inaccurate and misleading. Elektroda is not responsible for the accuracy, reliability, or completeness of the presented information. All responses should be verified by the user.