logo elektroda
logo elektroda
X
logo elektroda

BK7231N IR raw code capture issue on firmware 1.18.110 – missing debug commands, empty MQTT 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

• Firmware 1.18.110 was built with the “legacy” IR driver (drv_ir.cpp).
• That driver does not expose the commands IrDbg, system.ir.debug, system.ir.rawdata; therefore the console returns “Unknown command”.
• The Pulse-Distance decoder in that revision has a bug: the timing buffer is filled, but the JSON field Data is hard-coded to 0 when the protocol is “generic Pulse-Distance”, so you always see 0x0.
• The hardware is working; the code is not too long for the buffer (48 bits is small).
• Flash a build ≥ v1.18.130 (or any nightly after 2024-10-12) or build from current HEAD enabling drv_ir_new.cpp.
• After upgrading use
startDriver IRaw – to stream mark/space timings, or
setFlag 15 1   – to publish them over MQTT.

Detailed problem analysis

  1. Why the commands are unknown
    • In 1.18.110 the command parser contains the table in cmd_public.c. The entries IrDbg, system.ir.*, IRrawRecv were added only in 1.18.122–1.18.126 together with the new driver. Hence your build simply does not know them.

  2. Why you get Raw-Data = 0x0
    drv_ir.cpp decodes all “non-standard” timings with the generic Pulse-Distance state machine.
    • The routine ends in

    event_AddValue2(IR_PulseDistance, addr, cmd, 0);

    The third parameter (called data) is always zero for this path; MQTT therefore publishes

    {"IrReceived":{"Protocol":"PulseDistance","Bits":48,"Data":"0x0"}}

    Even though the raw timings were captured, they are discarded before the publish layer.

  3. Buffer length
    RAW_BUFFER_LEN is 256 words in that build. A 48-bit key (≈ 100–120 transitions) uses < 10 % of the buffer. Overflow is not the issue.

  4. Driver variants
    drv_ir_new.cpp (merged Oct 2024) supports:
    – NEC/AEHA/Sony/RC5/RC6 + raw
    – console commands IrDbg, IrRawRecv, flags 14/15/22
    drv_ir2.cpp is experimental; largely superseded.
    • Only one driver is compiled at a time, chosen by APP_USE_DRV_IR_NEW in app_config.h.

  5. Flags you already enabled
    • Flags 14 / 15 / 22 belong to the new driver. Setting them on a build that still uses the legacy driver has no effect – hence the empty MQTT frame.

Current information and trends

• Since v1.18.130 nightly, the default template for BK7231(T/N) devices is the new driver; raw capture and pronto-style export are available.
• Compact IR-RAW encoding (similar to Tasmota’s) was merged in v1.18.132; buffer can now carry A/C packets (> 400 bytes).
• A web-GUI widget “IR Console” appeared in v1.18.135.

Supporting explanations and details

Practical command set after upgrade

# live raw dump on serial / telnet
IrDbg 1
# publish mark/space list via MQTT as IrRaw
setFlag 15 1 # OBK_FLAG_IR_RAW_DEBUG_PRINT_TO_MQTT
# stop raw mode
IrDbg 0

startDriver IRaw is a one-shot switch that replaces the IR decoder by a raw-only driver until the next reboot – handy when you just want to capture.

Buffer tuning when you self-compile

#define IRRAW_BUFFER_LEN 512 // default 256
#define IRRAW_TIMING_TICK_US 50

Nothing else must be changed for ordinary remotes.

Ethical and legal aspects

• Recording IR protocols of consumer equipment is legal in most jurisdictions; distributing copyrighted A/C manufacturer codes may not be.
• Ensure devices exposed to MQTT are behind authentication to avoid unintended control from public brokers.

Practical guidelines

  1. Download pre-built binary
    OBK_BK7231N_QIO_1.18.135.bin (or newer) from GitHub → Releases.
  2. Backup configuration (backupCfg command).
  3. Flash new firmware (obk_flasher or OTA).
  4. Restore config, reboot.
  5. Open console, run IrDbg 1, press remote button; verify timing list.
  6. If you still get zeros, swap IR receiver module (VS1838B, TL1838) – some clones have too narrow bandwidth.

Possible disclaimers or additional notes

• Very high data-rate remotes (> 56 kHz carriers) cannot be decoded by the typical 38 kHz IR demodulator used on most BK7231 boards.
• The driver still lacks full support for phase-encoded protocols (XMP, SharpDVD); work is in progress.

Suggestions for further research

• Implement direct Pronto-hex export (pronto_dump branch).
• Add IR learning with adaptive carrier detection using the sigma-delta ADC on BK7231N.
• Cross-compile a single library shared with ESPHome’s esp32_ir component for code parity.

Brief summary

Your hardware is fine; the firmware revision is not. The 1.18.110 build lacks the new IR subsystem, therefore debug commands and raw data output are absent and the JSON always shows 0x0. Flash any build ≥ 1.18.130 or compile HEAD with drv_ir_new.cpp; then use IrDbg 1 or startDriver IRaw and/or set flag 15 to publish raw timings over MQTT. No buffer increase is needed for 48-bit codes, but you can enlarge it at compile-time for very long A/C packets.

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.