logo elektroda
logo elektroda
X
logo elektroda

[bk7231n / cbu / mcu] Milfra MFA05F Motion Sensor Light Switch, teardown and dpId

gokeeper 4281 38
ADVERTISEMENT
  • #31 21224168
    roywalker777
    Level 3  
    Posts: 4
    >>21221857 Does anyone have a device with original firmware? We need to see what is being sent back and forth over the UART...
  • ADVERTISEMENT
  • #32 21243160
    DexEdson
    Level 4  
    Posts: 5
    >>21221857 My PIR sensor didn't work either until I played with the datapoints 101 and 102. Sometimes it just stops working again though and I have to reset
  • ADVERTISEMENT
  • #33 21243180
    divadiow
    Level 38  
    Posts: 4882
    Help: 427
    Rate: 869
    >>21156301

    can someone do this and post the file from their MFA05F please
  • #34 21243224
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12433
    Maybe you need to script a dp 101 or 102 send (with required value - which one?) in autoexec.bat?
    Helpful post? Buy me a coffee.
  • #35 21296271
    amymariegerlach
    Level 5  
    Posts: 5
    Can someone help me please. I bought a couple of these switches to replace some cheap hubspace motion switches that were malfunctioning in my home. I successfully flashed openbeken onto the first one but I unchecked the auto config button in the easy UART flasher because I kept receiving errors, thinking I would be able to configure the device like I normally do with Tasmota devices, through the device access point. I have logged into the access point and configured my SSID info. I'm not really computer smart and don't know how or where to paste the data that is found in the beginning of this thread (dpIds, device status from tuya website, and autoexec.bat). I'm in the online app for my device and can view all of the different tabs but again don't know what to paste or where to put it to define this switch. I've found the template in screen shot 2 below but it looks like no pins or flags are transferring over and the device is still not configured even though I have "green" in the last photo.

    in case it matters...I did update to the newest firmware via OTA


    OpenBK7231N user interface with buttons for configuration, restart, and launching the web application. OpenBeken device configuration page with various settings. Screenshot of the Tuya device configuration interface.
  • ADVERTISEMENT
  • #36 21297604
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12433
    You need to also copy autoexec.bat:


    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #37 21300900
    amymariegerlach
    Level 5  
    Posts: 5
    Thanks for the link.

    OK, I got the autoexec.bat file pasted into the correct location and my switch has been partially configured (see 1st pict)

    User interface for configuring OpenBK7231N device.

    I say partially because the template still has all of the generic info and nothing showed up in the pins section (pict 2)

    Device configuration template with empty fields and Tuya chip identifier.

    Am I needing to insert the other two files from the first post, the dplds, and the device status from tuya website? If yes, where do they go?
  • #38 21305821
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14451
    Help: 650
    Rate: 12433
    You only need autoexec.bat. This is TuyaMCU device, so no pins are used except the UART1 port, which is used for MCU communication.
    Helpful post? Buy me a coffee.
  • #39 21313159
    psyko_chewbacca
    Level 7  
    Posts: 9
    Rate: 2
    Am I the only one that has reliability issues regarding PIR motion detection with these units?

    Whatever sensitivity setting I choose (Low, Med, High), the switch will sometimes (more often than not) take a very long time to toggle ON the relay.
    Switch is in a windowless room and light sensor is supposedly deactivated.

    Overall not a whole lot impressed, it kinda defies the purpose if I need to press the button to turn ON the light 75% of the time.

Topic summary

✨ The discussion centers on the Milfra MFA05F motion sensor light switch, which uses a BK7231N chip on a CBU board with a Tuya MCU. Initial issues with device functionality were resolved by configuring the MQTT server and setting local time via the tuyaMcu_sendCurTime command, as the PIR sensor operates only during certain times (DPIDs 101 and 102). The user shared the full autoexec.bat script and device template, which was accepted into the OpenBeken device database. Flashing the device requires holding the MCU reset (RST) pin to ground during power-on to enable serial flashing, as the MCU and WiFi module are tightly integrated. Attempts to separate PIR sensor data from relay control were complicated by hardcoded MCU firmware, with no direct datapoint logging for motion detection in ESPHome or Tasmota. Sensitivity settings exist but require MCU communication. Some users reported intermittent PIR reliability and delays in relay activation. The device template includes key DPIDs for switch, relay status, PIR sensor, and brightness sensor. The community suggests sending periodic state queries and enabling TuyaMCU queue flags for stability. The original MFA05 with an ESP board is noted as simpler to flash and modify, but the MFA05F with BK7231N and Tuya MCU is more complex due to integrated MCU control.
Generated by the language model.

FAQ

TL;DR: This FAQ maps 13 dpIDs and explains why “You only need autoexec.bat” for the Milfra MFA05F. It is for OpenBeken users who flashed the BK7231N/CBU switch but lost PIR behavior, LED control, or active-hour logic until time sync and DP 101/102 were set correctly. [#21305821]

Why it matters: The thread shows that this switch can look half-broken after flashing even when the relay works, because the MCU still expects time, UART commands, and valid PIR scheduling.

Wariant Moduł / architektura Jak go flashowano w wątku Główna konsekwencja
Starszy Milfra MFA05 ESP board Opisany jako łatwiejszy do flashowania Prostsza konfiguracja i mniej zależności od TuyaMCU
Nowszy Milfra MFA05F BK7231N + CBU + TuyaMCU tuya-cloudcutter lub serial po zablokowaniu MCU Wymaga autoexec.bat, dpID i synchronizacji czasu

Key insight: The PIR path is controlled by the external MCU, not by direct GPIO. If local time or DP 101/102 are wrong, the sensor can stop triggering even though Wi‑Fi, browser control, and the relay still work. [#21062811]

Quick Facts

  • pir_delay on dpID 49 accepts 5–3600 s in 1 s steps, so motion hold time is configurable over a full 59 min 55 s range. [#21055031]
  • The active PIR window uses dpID 102 start time and dpID 101 end time, each in 0–1440 min steps. A full-day window was set as 1 to 1440. [#21062811]
  • Serial flashing attempts used the connector with TX/RX, GND, and 3.3 V, but one user only succeeded after grounding the board RST point and pulsing CEN. [#21154883]
  • One blocked device reported Tuya firmware 2.1.17, which prevented use of tuya-cloudcutter and pushed the user toward ltchiptool over serial. [#21153165]
  • The shared device template identifies BK7231N, CBU, model MFA05F, and flag value 1024, while the maintainer said the project had 565 devices and wanted to reach 600. [#21063907]

How do I configure the Milfra MFA05F motion sensor light switch in OpenBeken using the autoexec.bat from the thread?

Use the posted autoexec.bat exactly, because this device is driven through TuyaMCU rather than normal GPIO pin mapping. 1. Start NTP and TuyaMCU, then call tuyaMcu_sendCurTime. 2. Define Wi‑Fi state with tuyaMCU_defWiFiState 4. 3. Create channels for relay, brightness switch, PIR switch, PIR delay, and PIR sensitivity, then send dpID states for LED mode and PIR hours. The working example sets PIR delay to 120 s, sensitivity to Mid, and active hours to 1–1440 min. [#21062811]

Why does the PIR sensor on the Milfra MFA05F stop working until tuyaMcu_sendCurTime and the DP 101/102 time window are set correctly?

The PIR stops because the MCU enforces an internal time schedule. The fix was not MQTT itself; it was sending local time with tuyaMcu_sendCurTime and keeping dpID 102 start time plus dpID 101 end time valid. The user confirmed the switch “suddenly stopped working” because local time was missing, and motion resumed after time sync was added. A full-day schedule was sent as start 1 min and end 1440 min. [#21062811]

What are the TuyaMCU dpIDs for the Milfra MFA05F, including relay, PIR, light sensor, sensitivity, delay, and timer functions?

The mapped dpIDs are: 1 relay switch_1, 14 power-on state, 15 status LED mode, 43 light-sensor enable, 44 light-sensor state, 45 light threshold mode, 46 PIR enable, 47 PIR state, 48 PIR sensitivity, 49 PIR delay, 101 PIR end time, 102 PIR start time, and 103 timer raw data. That gives 13 datapoints in the shared dump. Sensitivity supports low, middle, high, and delay spans 5–3600 s. [#21055031]

What is a TuyaMCU device, and how is it different from a normal OpenBeken device that uses direct GPIO pins?

A TuyaMCU device does not expose most functions as direct GPIO roles inside OpenBeken. "TuyaMCU" is a microcontroller-based control layer that handles sensors and relay logic over UART, instead of letting the Wi‑Fi chip drive each pin directly. On this MFA05F, OpenBeken mainly talks through UART1, while the external MCU owns PIR, timing, and mode logic. That is why the maintainer said you only need autoexec.bat, not a normal pin template. [#21305821]

What is the CBU module in a BK7231N switch, and why does it matter for flashing and configuration?

The CBU is the Wi‑Fi module fitted in this switch, and it matters because you flash that module, not the whole motion-control design. "CBU" is a BK7231N-based Wi‑Fi module that runs the network firmware, while a separate MCU still controls relay and sensor behavior through serial communication. That split explains why flashing OpenBeken alone does not automatically expose PIR as a direct sensor. The posted template names the board CBU and chip BK7231N. [#21063907]

How can I flash the BK7231N/CBU version of the Milfra MFA05F with tuya-cloudcutter instead of serial flashing?

Use tuya-cloudcutter only if your unit still supports that cloud exploit path. One user flashed this exact BK7231N/CBU MFA05F with tuya-cloudcutter and moved it to OpenBeken without serial work. Another user later reported firmware 2.1.17, which blocked cloudcutter and forced serial experiments instead. The practical rule from the thread is simple: if cloudcutter works on your firmware, it is easier than fighting the TuyaMCU board over serial. [#21092461]

What steps worked for flashing the MFA05F via serial with ltchiptool by holding the board RST pad to GND and pulsing CEN?

The successful serial method was to keep the board’s RST pad tied to GND during power-on, then pulse CEN to GND until ltchiptool connects. 1. Ground the pad labeled RST. 2. Power the board while RST stays low. 3. Tap CEN to GND a few times until flashing starts. The user said this finally worked after repeated failures, and the board light blinked during reset attempts. [#21154883]

Why does applying the web app template on this MFA05F seem to revert to default, while autoexec.bat still creates the working channels?

It happens because the template is not the main configuration mechanism for this TuyaMCU design. The maintainer explained that this device uses no normal pins except UART1, so the web template can still look generic while autoexec.bat creates working relay, PIR, and delay channels. A user saw the template appear to reset, yet the browser UI still exposed three switches after copying the script. In short, the script matters more than the template here. [#21305821]

How do I set the status LED mode, PIR delay, PIR sensitivity, and active hours on the Milfra MFA05F with tuyaMcu_sendState commands?

Send the settings directly to the MCU using the datapoint numbers from the working script. The thread uses tuyaMcu_sendState 15 4 1 for LED mode, links dpID 49 to a text field and sets 120 s delay, maps dpID 48 to LowMidHigh and sets value 1 for Mid, then sends dpID 102 start time 1 and dpID 101 end time 1440. Those values restored expected LED and PIR behavior on the posted unit. [#21062811]

What does the OpenBeken flag for TuyaMCU queue do, and when should it be enabled on devices like the MFA05F?

The thread recommends enabling the TuyaMCU queue when this switch is working but still depends on several UART commands and state exchanges. The maintainer suggested that the user “may also want to enable TuyaMCU queue in the flags” right after the final working setup was confirmed. The shared template later showed flags value 1024, which matches that recommendation in the posted device entry. Use it on MCU-driven devices where orderly command handling matters. [#21063907]

How can I troubleshoot a flashed MFA05F where the relay works from the browser but the PIR and brightness sensor do not respond?

First, verify time sync and the PIR schedule. 1. Add startDriver NTP, set an NTP server, and call tuyaMcu_sendCurTime. 2. Send valid dpID 101/102 active hours. 3. Explicitly set PIR sensitivity and delay at least once. The failure pattern in the thread was clear: relay control worked from the browser, but PIR and light-sensor behavior failed until time and schedule were corrected. Another user later said PIR sometimes still needed dpID 101/102 adjustments or a reset. [#21243160]

What is the difference between the older Milfra MFA05 with an ESP board and the newer MFA05F with BK7231N CBU and TuyaMCU?

The older MFA05 is easier to repurpose because it uses an ESP-based design, while the newer MFA05F adds a BK7231N CBU module plus a separate TuyaMCU. The thread explicitly calls the older version “easy to flash,” but the newer board needs cloudcutter compatibility or careful serial work. That hardware split also limits sensor access: on the MFA05F, PIR behavior stays inside the MCU unless you keep its UART protocol satisfied. [#21092461]

How could I capture or inspect the UART traffic from the MFA05F running original Tuya firmware to discover missing datapoints or initialization commands?

Keep one switch on original firmware and log the serial exchange between the Wi‑Fi module and the MCU. The thread proposed exactly that after users found missing PIR behavior under Tasmota and ESPHome. One participant asked for a device with original firmware so they could see “what is being sent back and forth over the UART,” and another requested a 2 MB flash backup or config extract to confirm missing datapoints. That is the cleanest path to discover hidden initialization. [#21224168]

What options are there for decoupling the PIR sensor from the relay on the Milfra MFA05F so it can be used with smart bulbs and automations?

You have only hardware-heavy options in this thread. The maintainer said you could remove the MCU, remove the Wi‑Fi module, or cut the MCU connection, then wire the relay and PIR differently. Another user wanted PIR events without relay triggering for smart bulbs, but found the behavior hard-coded in the MCU and saw no motion datapoint logged in ESPHome. The same reply warned that some PIR circuits may need PWM-based sensitivity handling, so the mod can grow complex fast. [#21155031]

Why is PIR motion detection on some MFA05F units unreliable even with the light sensor disabled and sensitivity set to low, medium, or high?

The thread never reached a final root cause, but it points to MCU-side initialization and schedule state. One user reported the light turned on late “more often than not,” even in a windowless room with the light sensor supposedly disabled. Others said PIR did not work until they changed dpID 101/102, and one unit sometimes needed a reset afterward. The best thread-backed explanation is incomplete MCU state, not a simple OpenBeken GPIO issue. [#21243160]
Generated by the language model.
ADVERTISEMENT