How to make Xiaomi keyboard: full instructions for flashing and modification

Owners of the Xiaomi ecosystem often face the desire to unify their devices, but the brand’s standard periphery may seem limited in functionality.The question of how to make Xiaomi a keyboard from a regular Bluetooth device or how to completely reflash the existing model is becoming increasingly relevant for enthusiasts.

There are two main ways to do this: software emulation via a smartphone and hardware flashing of the controller. The first option is available to everyone and does not require soldering, the second makes the device a unique tool for automation. We will examine both methods, paying special attention to technical nuances and risks.

Before you start modifying hardware, you need to clearly understand the architecture of the connection. Bluetooth Low Energy (BLE) protocols used in smart home devices have their own encryption and data transfer features. Incorrect interference can lead to the device becoming a β€œbrick”, so carefully study each step of the instructions.

Software emulation of the keyboard through a smartphone

The safest way to turn a Xiaomi phone into a full-fledged keyboard for a PC or TV is to use specialized emulator applications, which do not require opening the cases and allows you to test various key configurations without risking damage to the electronics.

To implement it, you will need an Android smartphone and an application that supports the HID (Human Interface Device) profile. Popular solutions like Serverless Bluetooth Keyboard & Mouse or Remote Mouse allow you to stream clicks over Bluetooth. It is important to note that for stable operation, you need to provide the application with appropriate permissions in the system.

⚠️ Note: When using third-party keyboards via Bluetooth, make sure you do not enter sensitive data (passwords, bank codes) on untrusted devices, as traffic may be vulnerable.

Set up the emulation takes only a few minutes. After installing the application, go to Settings β†’ Connected devices β†’ Pair a new device on the receiving gadget (PC or TV).

  • πŸ“± Download the emulator app from Google Play or APK-repository.
  • πŸ”— Turn on Bluetooth on both devices and pair.
  • βš™οΈ Configure the key layout in the application interface for your needs.
  • πŸ”Œ Check the multimedia keys and volume.

However, this method has its limitations related to input lag. This is not critical for office work, but in games or fast typing, the delay can be anywhere from 50 to 150 ms, which is palpable for the user.

πŸ“Š What modification method do you prefer?
Software (no risk)
Hardware (solding and firmware)
Ready-made solutions Xiaomi
I don't need it.

Hardware flashing of the keyboard controller

Those who want to make a real Xiaomi-like keyboard with Mi Home support or custom macros will need hardware intervention. JD640 or BK3231, quiz UART-interface.

The process starts with disassembling the device and finding test points on the board. You will need a USB-TTL adapter (for example, based on the CH340 chip) to connect to TX, RX and GND contacts. The main task is to find the dataset on the controller and find the appropriate firmware damper.

sudo flashrom -p ch341a_spi -w custom_xiaomi_firmware.bin

This command (conditional, depending on the programmer) demonstrates the principle of writing new code to the device memory. After successful firmware, the keyboard can begin to be defined in the system as a device with Vendor ID from Xiaomi, which will allow you to use specific drivers.

  • πŸ” Find contacts. UART on the board (usually marked as TX, RX, GND, VCC).
  • πŸ’» Connect the programmer while observing polarity (VCC plug in!).
  • πŸ’Ύ Consider the current firmware to create a backup before writing a new one.
  • ⚑ Write a modified binary file with support for the desired functions.

The complexity of the method lies in the variety of controllers. There is no one universal firmware for everyone, so often enthusiasts have to adapt the open source code of QMK or ZMK to a specific hardware.

β˜‘οΈ Checklist for reflashing preparation

Done: 0 / 1

Using Mi Home to Automate Entry

If your goal is not physical flashing, but the integration of the keyboard into the smart home, then the Mi Home app will be a key element. Xiaomi’s standard keyboards (such as the BM30 or LYY9004 model) support the creation of scenarios where pressing a certain keyboard combination triggers action in the smart home.

To set up, go to the device profile in the app and select the Smart Scenarios section, where you can trigger the press of any button, for example, Fn + F1 can turn on the light in the living room, and Fn + F2 can start the robot vacuum cleaner.

However, standard functionality is limited. To expand the capabilities, users often use a bundle of Home Assistant and integration Xiaomi Gateway 3. This allows you to throw keystroke events into the local network, bypassing cloud servers.

Keyboard modelType of connectionSupport for Mi HomePossibility of macros
Xiaomi Wireless KeyboardBluetooth 3.0No.Only through the LA.
Mi Smart Keyboard FolioPogo Pin / BTPartially.Through applications
Xiaomi BM30Bluetooth 5.0Yes.Yes (scripts)
Yeelight Mechanical KeyboardUSB / BTYes.Complete (RGB + Macro)

It is important to understand the difference between on-premises and cloud-based scripting, and if the Internet goes down, cloud scripting won’t work, so it’s better to use on-premises integrations for mission-critical functions (such as calling an alarm).

Why is the keyboard not visible in the Mi Home?
The keyboard may not appear in the application if it is connected directly to the PC rather than through the gateway. scripting often requires that the device be connected to the phone or gateway at the time the trigger is set up. Also make sure that the region in the application matches the region of the device.

Creating custom macros and reassignment

Turning a regular keyboard into a professional tool is possible through reassignment of keys at the operating system level. In the Android and Windows environment, there are powerful tools that allow you to emulate the behavior of the branded Xiaomi peripherals.

And on Android, the Button Mapper or MacroDroid app is perfect for this, and it lets you intercept keyboard events and swap them for any other action you want: launching apps, changing volume, emulating swipes, which is especially useful if your keyboard has extra buttons.

In Windows, the analogue is AutoHotkey or PowerToys Keyboard Manager. AutoHotkey can completely change the logic of the device, for example, you can make the keyboard work like a media player control panel when you press the right mouse button.

Example of AutoHotkey script for multimedia emulation


F1::Send {Media_Play_Pause}




F2::Send {Volume_Up}




F3::Send {Volume_Down}




CapsLock::Send {Esc}

This approach allows you to adapt any Bluetooth keyboard to the tasks of the media center or game console, the main advantage is that there is no need for soldering and the ability to roll back changes at any time.

  • πŸ“ Install a scripting manager (AutoHotkey, Tasker, MacroDroid).
  • πŸ”‘ Identify the Key Codes of your keys for precise mapping.
  • 🧩 Create a profile for a specific application or global profile.
  • πŸš€ Test macros for conflicts with system hotkeys.

Eliminating delays and optimizing Bluetooth

One of the major problems with custom keyboard design or emulators is the latency of input, which becomes critical in games or in fast printing, and delays are often caused by energy-saving Bluetooth stack algorithms.

To minimize lags on Android, you can try turning off the β€œBluetooth MAP” option in the developer settings, although this is not always available. On Windows, it is worth checking in which mode the adapter is running: sometimes switching from power saving mode to high performance mode gives a noticeable increase.

⚠️ Attention: Interference between Wi-Fi (2.4GHz) and Bluetooth signals can cause cursor jerks. USB-Wi-Fi and Bluetooth adapters are farther apart or use an extension cord for the adapter.

Also worth paying attention to is the Bluetooth version. Devices with Bluetooth 5.0 and higher support have a more stable communication channel and lower latency compared to the older versions of 3.0 or 4.0. If you build a keyboard from scratch, choose modules with BLE 5.x support.

πŸ’‘

To reduce delays in games, disable background applications that use Bluetooth (earphones, fitness trackers) to free up the communication channel for the keyboard.

FAQ: Frequently Asked Questions

Can I reflash the regular Logitech keyboard in Xiaomi?
Xiaomi rarely reflashes Vendor ID and Device ID because of closed encryption protocols, but it is possible to functionally emulate the work through software drivers that will β€œdeceive” the system, presenting the device as a Xiaomi product line.
Is it safe to use modified firmware?
There's always a risk in using custom firmware, and there's a chance that the Bluetooth stack will be disrupted, which will make it impossible to connect the device, and always make a full backup of the original memory before you start experimenting.
Do Mi Home macros work without the internet?
Basic scenarios tied to the cloud won’t work, but if you’re using a local Home Assistant server with Xiaomi integration, managing smart home devices will work even when the Internet is off, inside the local network.
Which adapter is better for reflashing controllers?
The most versatile and cheapest option is an adapter based on the CH340 or CP2102 chip. They support the required voltages (3.3V) and have stable drivers for Windows, Linux and macOS.

πŸ’‘

Creating a full-fledged Xiaomi keyboard from a third-party device is a complex process that requires knowledge in electronics. For most users, software emulation and macro tuning will be the optimal solution.