Approximation sensor in the Xiaomi smartphone: how to configure and calibrate

Modern Xiaomi smartphones are equipped with many sensors that make using the device comfortable, but one of the most important and often ignored is the proximity sensor. It is this small module that is responsible for locking the screen during a conversation when you hold the phone to your ear, preventing accidental tapping of the cheek or ear. If you notice that the screen goes out too early, does not turn off at all or, conversely, turns off only after you have already removed the phone from your face, then it is time to engage in its fine-tuning.

Problems with the correct operation of the sensor can occur for various reasons, from the banal contamination of the upper part of the case to software failures after updating the firmware MIUI or HyperOS. Many users do not even suspect that the system has hidden tools for fine sensitivity adjustment that allow you to correct the situation without contacting the service center. In this article, we will discuss all available diagnostic and configuration methods, including working with the engineering menu.

It's critical to understand that in most modern Xiaomi models, the physical sensor is paired with a speaker or hidden under the screen, so software calibration is the only safe way to solve problems without disassembling the device. Incorrect settings can cause the phone to stop responding to the approach of objects, which will make conversations extremely uncomfortable. Let's figure out how to get this component back to work.

Principle of operation and types of sensors in Xiaomi

To effectively configure any mechanism, you need to understand how it works. Xiaomi, Redmi and POCO use two types of distance sensors: classic infrared and ultrasonic, and newer virtual algorithms. Infrared sensors emit invisible light and read its reflection from the object, calculating the distance to it. This is a reliable and time-tested technology that is found in most budget and medium-sized models.

In more expensive flagship models, where space is needed in the upper frame of the case, manufacturers often abandon a separate hole using ultrasonic sensors or software algorithms based on an accelerometer and a gyroscope. Ultrazuk allows you to determine the distance through glass or a thin layer of plastic, which makes it possible to create devices with a frameless design. However, such systems are more difficult to calibrate and can fail when using high-thick protective glasses.

⚠️ Warning: Using thick protective glasses or films covering the top of the screen can completely disrupt the infrared sensor, as IR rays simply cannot pass through the material or will be reflected from its inner surface.

Understanding the type of sensor you have in your device helps you choose the right strategy for solving problems. If you have a model with a sensor removed (a prominent black window next to the speaker), the problems are most often due to pollution. If the sensor is hidden under the screen, then the main emphasis should be on software calibration and compatibility checks of accessories.

How do you know the type of sensor?
In the specifications on the official website, look for abbreviations: IR Proximity Sensor (infrared) or Ultrasonic Proximity Sensor (ultrasonic), and the type can be identified visually: if there is a black glass window next to the speaker, it is an IR sensor.

Diagnostics of malfunctions through the engineering menu

The first step before any setup is to be thoroughly diagnosed, with MIUI’s shell featuring a special engineering mode that is accessed through the standard Phone app, which allows you to test the performance of all sensors in real time, eliminating guesswork and allowing you to see the exact numerical values that the processor receives.

To enter the testing mode, you need to dial a special USSD-Type on the keyboard ##6484## or ##4636## (code may vary depending on the region and firmware version). CIT (Customer Integration Test. In the test list, look for "Proximity Sensor" or "Proximity Sensor." Click on it to go to Verification mode.

  • πŸ“± Close the top of the screen with your palm: Distance should change from 5.0 (or far) to 0.0 (near).
  • πŸ“± Remove your hand: the value should instantly return to its original state.
  • πŸ“± Check the reaction at different distances: Hold your hand slowly by watching the trigger threshold.

If the sensor is correct (clearly switches between near and far) in this menu, the problem is likely to be the settings of a particular application, such as a messenger or phone book. If the reaction is sluggish, values do not change or jump randomly, hardware cleaning or software calibration is required, and this menu often displays Raw data, raw data that is useful for engineers, but the average user just needs to monitor the status of Near/Far.

πŸ“Š How your sensor is acting now?
The screen goes out too soon
It doesn't go out when you talk.
It works perfectly.
It only works in certain applications.

Classic Calibration through Engineering Code

The most effective way to fix a software failure is by forced calibration, which causes the system to re-remember the zero point (when there is nothing in front of the screen) and the trigger point. Unlike a simple restart, calibration records new reference values in the memory of the sensor controller.

To start the calibration process, use the engineering menu described above again, but this time we will use a separate mode. Enter the code ##6485## (or find Calibration in the CIT menu). You will need a paragraph related to calibrating the proximity sensor (often called Proximity Sensor Calibration). Follow the instructions on the screen: usually the system asks you to remove your hand from the screen first, and then close the sensor.

1. Make sure there are no obstacles in front of the screen.

2. Press the Start or Calibrate button.

3. Wait for the message "Place hand over sensor".

4. Close the sensor tightly with your palm (without touching the screen).

5. Wait for the message "Calibration Success."

It is important to do this in good light, but not in direct sunlight, which can blind the infrared sensor. Also make sure that the battery is charged at least 20%, as in rare cases, when the charge is low, the system can block changes to the system settings. Once the procedure is completed, the phone can automatically restart.

β˜‘οΈ Checklist before calibration

Done: 0 / 4

Setting Sensitivity in Hidden Menus

Some Xiaomi and Redmi firmware versions have the ability to manually adjust the sensitivity threshold, especially for users who wear high-sided cases or use non-standard safety glasses, and if standard calibration doesn't help, change the trigger threshold.

Access to these settings is often hidden in the developer section or in the same CIT engineering menu. Find the Proximity Sensor Threshold or similar. Value usually ranges from 0 to 255 (for 8-bit sensors) or in centimeters. Increasing the threshold makes the sensor more sensitive (it will respond to objects further), and decreasing it less sensitive.

ParameterRecommended valueThe effect
Min Threshold0 - 10Basic background cut-off level
Max Threshold200 - 240Maximum sensitivity
Filter Window3 - 5Smoothing out of value surges

Be careful when you change these parameters. Too high can cause the phone to think it's near the ear, even when you're lying on the table. Too low, the sensor won't work at all. The golden rule is, change the values in small steps (5-10 units) and immediately test the result in a real call.

⚠️ Warning: Do not set maximum sensitivity values unless absolutely necessary.This will lead to false positives when you just hold your phone in your hand or watch a video, accidentally closing the top corner of the device.

Third-party applications for sensor control

If the built-in MIUI tools don’t work, specialized apps from the Google Play store come to the rescue, allowing you to gain more detailed control of the sensor, keep logs of value changes, and even forcibly reconfigure the sensors, bypassing some of the system’s limitations.

One of the most popular tools is the Proximity Sensor Reset/Fix or Sensor Test app. These programs often have automatic calibration features that work on more complex algorithms than the standard Xiaomi menu. They can average readings over a certain period of time, which helps cut off random interference.

  • πŸš€ Automatic calibration: the application will conduct a series of tests and select the optimal values.
  • πŸ“Š Real-time graphics: Data visualization helps you understand how the sensor responds to your actions.
  • βš™οΈ Forced reset: a function for cases where the sensor is β€œslip” in one state.

Note that some advanced features may require root rights. On modern smartphones with a locked bootloader, obtaining such rights is difficult and can lead to a loss of warranty.

πŸ’‘

Before installing third-party calibration apps, take a screenshot of the current settings in the engineering menu to be able to return to the original values in case of failure.

Hardware causes and their elimination

Physical factors can't be discounted, too. Often, software-based tuning doesn't work just because the problem is iron. The most common cause is pollution. Dust, skin fat, and dirt accumulate in the micro-hole of the sensor, creating an opaque film that distorts infrared radiation.

Use a soft microfiber slightly moistened with isopropyl alcohol to clean. Do not use water, wipers or aggressive chemicals, as they can damage the oleophobic screen covering or penetrate the inside of the case. Gently wipe the top of the screen in circular motions, paying special attention to the area of the conversational speaker.

Another common cause is poor-quality security glass. Cheap glass can have an opaque edge or simply be too thick in the sensor area. If you installed protection recently and problems started right after that, try to carefully remove the glass and check the sensor's performance. In some cases, cutting a small hole above the sensor in the already pasted glass helps, although it does not look aesthetically pleasing.

If neither cleaning nor software methods help, it may be that the sensor module itself or the plume connecting it to the motherboard has failed, and in such cases, especially if the phone has been hit or moisture has been hit, only replacing the component in an authorized service center will help.

πŸ’‘

90% of proximity sensor problems are solved by thoroughly cleaning the top of the screen and recalibrating through the engineering menu.

Why is the sensor not working after the MIUI update?
Firmware updates often change the algorithms for processing sensor data. The new version may be less optimized for your specific sensor instance, or factory calibration, in which cases, resetting to factory settings (with data saved) or waiting for a patch from developers helps.
Can a magnet in a case affect the sensor?
The magnet itself does not affect the infrared sensor, but magnetic bookcases often have a Hall sensor that can conflict with the proximity detection system if the implementation in Xiaomi's firmware is not performed correctly.
What to do if the screen goes out in your pocket?
This is a classic sign of too high sensitivity or contamination. Try to reduce the sensitivity threshold in the engineering menu or turn on the In-Pack mode (if available in your version of MIUI), which ignores the proximity sensor when the screen is locked.
Does the temperature affect the sensor?
Yes, at extremely low or high temperatures, the infrared emitter can drift, causing false positives, let the phone warm up or cool down to room temperature to stabilize the sensor.