How to flash Xiaomi’s temperature and humidity sensor: a complete guide with errors and solutions

Xiaomi’s temperature and humidity sensors are among the most popular smart home devices due to their accuracy, compactness and integration with the Mi Home ecosystem. However, standard firmware often limits functionality: there is no support for local servers (such as Home Assistant), data is transmitted only to the Xiaomi cloud, and updates come with a delay. Custom software firmware solves these problems, but the process requires accuracy – an error can turn the sensor into a β€œbrick”.

In this article, we will analyze all methods of firmware for models LYWSD03MMC, LYWSD02, CGG1 and others: from official updates through Mi Home to installing alternative firmware like ATC MiThermometer or Custom Firmware for Xiaomi Devices (CFW). We're going to focus on bypassing downgrade protection, which blocks the installation of older versions of software on new devices. If you've never flashed through sensors, don't worry: the instructions are tailored for beginners, with explanations of each step.

1.What Xiaomi sensors can be flashed and why it is necessary

Not all Xiaomi sensors support custom firmware, and here is a list of models for which alternative software is available, and the key reasons for their firmware:

  • πŸ”Ή LYWSD03MMC (The most popular firmware adds support for Bluetooth Low Energy (BLE) Directly connect to Home Assistant or ESPHome without the cloud.
  • πŸ”Ή LYWSD02 β€” fixes the sensor β€œfalling asleep” bug after 10 minutes, improves measurement accuracy.
  • πŸ”Ή CGG1 (sensor with display – unlocks hidden calibration settings and increases the frequency of data updates.
  • πŸ”Ή MJWSD05MMC β€” add-on MQTT Integration with any smart home system.

The main reasons for firmware:

  • πŸ“‘ Local management – data is transferred directly to your server, not to the Xiaomi cloud (important for privacy).
  • ⚑ Increased polling frequency – standard sensors send data every 10 minutes, custom firmware allows you to reduce the interval to 1 second.
  • πŸ”§ Additional features – for example, calibration of readings, logging data on a microSD (for some models).
  • 🚫 Bypassing regional restrictions – some sensors block work outside China without firmware.

⚠️ Attention: Xiaomi sensor firmware with Telink chip TLSR8266 (for example, LYWSD03MMC) It requires a mandatory turn off of the protection from writing (write protection), without which any attempt to flash the device will end up with a Flash write error.

πŸ“Š What kind of sensor Xiaomi is using?
LYWSD03MMC
LYWSD02
CGG1
MJWSD05MMC
Other
I don't know.

2. Preparation for firmware: what will be needed

Before you start, gather everything you need, and the absence of at least one component can interrupt the process and "brick" the sensor.

  • πŸ–₯️ Computer on Windows 10/11 Linux (MacOS will require additional drivers).
  • πŸ”Œ USB-TTL base-mount CP2102 or FT232RL (for example, HC-05 Important: Adapter must support 3.3V β€” 5V burns the sensor.
  • πŸ”§ soldering or tweezers – to connect the adapter to the sensor contacts (you need skills with small details).
  • πŸ“ Firmware – official (from the Xiaomi site) or custom (for example, from a repository) ATC MiThermometer).
  • πŸ› οΈ Programs: Flash Tool (for example, TLSR Flash Tool for Telink chips. Python 3.x (for firmware scripts. Drivers for USB-TTL adapter.

Also prepare the workplace:

  • πŸ’‘ Good lighting – contacts on the sensor board are miniature.
  • πŸ”‹ Uninterruptible power supply – if the computer turns off during firmware, the sensor may fail.
  • πŸ“± Spare smartphone with the Mi Home application - to check the performance after firmware.

β˜‘οΈ Checklist before firmware

Done: 0 / 6

3. Step-by-step instruction: firmware through USB-TTL

This is the most reliable method, but it requires a physical connection to the sensor, and the instructions are universal for most models on a Telink chip. TLSR8266.

Step 1: Connection USB-TTL adapter

Disassemble the sensor case (take care of the latches with a flat screwdriver). GND, TX, RX and 3.3V. Connect them to the adapter according to the scheme:

Sensor β†’ Adapter


GND          β†’       GND




TX           β†’       RX




RX           β†’       TX




3.3V         β†’       3.3V (VCC)

Important: Don't confuse TX and RX β€” If there's no marking on the board, use the multimeter to check the voltage.

Step 2: Disabling protection from the record

Telink chips are locked from the recording by default to unlock:

  1. Connect the sensor to the adapter (no power!).
  2. Close your contacts. P25 (or GPIO25) land (GND) tweezer.
  3. Serve the food (3.3V) β€” sensor will go into firmware mode.

Step 3: Firmware through TLSR Flash Tool

Download and launch. TLSR Flash Tool (e.g., from here). Specify in the settings:

  • Port port (COMX) β€” Check in Device Manager.
  • The speed (Baud Rate) is 115200.
  • Firmware file (.bin).

Press Start and wait until it is completed (usually 1-2 minutes). If the process is stuck on Erasing Flash, check the connection. P25 ce GND.

What to do if the sensor is not detected?
1. Check the drivers USB-TTL Adapters (must be installed correctly) 2. Make sure the adapter supports 3.3V (5V 3. Try another port. COM 4 If you are using a virtual machine, pass the port COM guest-OS.

Step 4: Checking the Results

After the firmware:

  1. Disconnect the sensor from the adapter.
  2. Insert the battery and wait for the switch on (can take up to 30 seconds).
  3. Connect the sensor to the Mi Home or check it through Home Assistant (if you have been through custom software).

⚠️ Note: If the sensor doesn't turn on after the firmware is flashed or flashes red, it's likely that the firmware is damaged. Try flashing the original Xiaomi software (download here).

4. Firmware without soldering: alternative methods

Not everyone is comfortable soldering or disassembling the sensor. Fortunately, there are ways to update the firmware without physical intervention β€” but they don't work for all models.

Method 1: Update via Mi Home (official method)

If you only need the latest official firmware:

  1. Open the Mi Home app.
  2. Go to the sensor settings (Device) β†’ Settings β†’ Firmware update).
  3. If the update is available, click Update.

Limitations: Xiaomi often blocks downgrade (installation of the old version), and new firmware can remove useful features (for example, local protocol).

Method 2: Firmware through the air (OTA) custom-based

Some custom firmware (for example, ATC MiThermometer supports Bluetooth update:

  1. Download. APK-file ATC MiThermometer Tool.
  2. Connect to the sensor via Bluetooth.
  3. Select the firmware file (.bin) and press Start. OTA.

Advantage: you don't have to disassemble the sensor, disadvantage: it doesn't work on all models (e.g., the sensor doesn't work on all models, CGG1 supportive OTA).

Firmware methodSupported modelsDifficultyRisk of "bricking"
USB-TTL (ration)LYWSD03MMC, LYWSD02, MJWSD05MMC⭐⭐⭐⭐Medium (in case of errors)
Mi Home (officially)All models.⭐Low.
OTA (Bluetooth)LYWSD03MMC (caste-only)⭐⭐Low.
ESPHome (flashing)LYWSD03MMC (modified)⭐⭐⭐⭐⭐High-pitched

πŸ’‘

If the sensor after firmware is not determined in Mi Home, but works on Bluetooth, try resetting it to factory settings. To do this, hold the reset button (if any) for 10 seconds or use the command through the terminal: AT+RESET (firmware).

5. Common mistakes and their solutions

Even with the correct following of the instructions, problems can arise, and below is a list of common errors and ways to fix them.

  • πŸ”΄ Error: Flash Write Error Reason: Not disabled P25 (Solution: Close the lock. P25 on GND and repeat the firmware.
  • πŸ”΄ Sensor does not turn on after firmware Reason: Wrong firmware (for example, from another model).Solution: Sweat the original software from Xiaomi.
  • πŸ”΄ Error: Device not found Reason: Wrong port COM Solution: Check the adapter connection and reinstall the drivers.
  • πŸ”΄ Sensor gives incorrect data Reason: Damaged calibration data Solution: Restore factory firmware or calibrate the sensor manually (if the firmware supports).

If the sensor has stopped responding to any action, try emergency recovery:

  1. Connect. USB-TTL adapter.
  2. Shut up. P25 on GND.
  3. Serve power and immediately start the firmware of the original software.

πŸ’‘

The most common mistake of beginners is trying to flash the sensor without turning off the protection (P25). Always check that the contact is closed to the ground before starting the firmware!

6. firmware for integration with Home Assistant

If your goal is to connect the sensor to Home Assistant, custom firmware ATC MiThermometer or CFW β€” These firmwares add Bluetooth Low Energy support (BLE), This allows you to read data without the cloud Xiaomi.

Set up Home Assistant

After the firmware:

  1. Add Bluetooth integration to Home Assistant (if not already added).
  2. Install the ESPHome supplement or BLE Monitor.
  3. In the configuration.yaml file, add:
sensor:


- platform: miflora




mac: "XX:XX:XX:XX:XX:XX" # MAC- sensor address




temperature:




name: "Temperature"




humidity:




name: "Humidity"




battery:




name: "Battery"

Replace. XX:XX:XX:XX:XX:XX real MAC-The address of your sensor (can be found via nRF Connect or Bluetooth Scanner).

Advantages of custom firmware for Home Assistant

  • πŸ“Š Data is updated every second (instead of 10 minutes in standard firmware).
  • πŸ”’ No dependence on the Xiaomi cloud – work even when the Internet is disconnected.
  • πŸ› οΈ The ability to calibrate readings directly from the Home Assistant interface.

7.How to get back the original Xiaomi firmware

If custom software is unstable or you want to return the sensor to its original state, run the official firmware.

  1. Download the original software for your model from the official website or from the firmware repository.
  2. Connect the sensor to USB-TTL Adapter (don’t forget to close the door) P25 on GND).
  3. Launch it. TLSR Flash Tool and select the downloaded.bin file.
  4. Press Start and wait until it is completed.

Once the firmware is in place, the sensor will return to factory settings to reconnect it to the Mi Home:

  1. Remove the device from the app.
  2. Press the reset button on the sensor (if any) or remove/insert the battery.
  3. Add the sensor again through Add the device β†’ Temperature and humidity sensor.

⚠️ Note: Some new models (e.g, LYWSD03MMC firmware v2.0.0_0040 If you try to flash the old version, you will see a Version downgrade not allowed error, in which case you will have to use a patched firmware with bypass protection (see forums). 4PDA or GitHub).

8. Frequently Asked Questions (FAQ)

❓ Can I use the sensor without USB-TTL adapter?
Yes, but only if your model supports it. OTA-Bluetooth updates, for example, LYWSD03MMC For most sensors, soldering is essential, and the alternative is to use ready-made stitched sensors (sold on AliExpress with the "Custom" tag). FW").
❓ Which firmware to choose: ATC MiThermometer or CFW?
ATC MiThermometer is easier to install and better documented, but has limited settings. CFW It is more flexible (you can adjust the survey interval, the data format), but requires manual compilation. ATC.
❓ Why does the sensor show the wrong temperature?
This is a typical problem when using uncalibrated firmware. Solutions: Return the original firmware and check the readings. If the problem persists, the sensor is damaged (for example, after soldering, AT+OFFSETHUMI=x for humidity adjustment).
❓ Can I run the sensor through my phone?
Partly. OTA-firmware on Bluetooth is enough smartphone and applications ATC But for a complete flashing (for example, with a replacement bootloader) you need a computer and a computer. USB-TTL adapter.
❓ What to do if the sensor after the firmware does not turn on?
It's probably broken. Try: Swipe through the original Xiaomi software. Check the power (battery, contacts). If the sensor flashes red, close it. P25 on GND If you want to do that, you can call the service (but repairs can cost more than a new sensor).