How to Perform Proximity Sensor Calibration on any Samsung Phone [Fix]
Last year, Samsung unveiled their new flagship device Galaxy Note 3 along with a smart watch called ‘Galaxy Gear’. The device sports a powerful hardware and being a phablet series phone, it includes a S-Pen stylus as well. On software side, it runs on Android 4.3 on board. Samsung has provided a latest TouchWiz version and included several new features like smart pause, smart scroll etc.in it. One of the noticeable change (not for normal users) that they’ve implemented in Android 4.3 is a new KNOX bootloader. Just like ‘binary count’ on older Samsung devices, this new bootloader triggers the flag and sets KNOX count to 1 if any unofficial activity is performed on the device. But unlike binary count, developers still haven’t got any luck resetting the KNOX counter to 0. Therefore, users are afraid to try any unofficial stuff on their Android 4.3 running Samsung device (I feel really sorry for Note 3 users as it ships Android 4.3 on board).
Few weeks ago, Samsung started rolling out this update for their previous flagship devices including Galaxy S4, Galaxy Note 2 and Galaxy S3. And as expected, they implemented the same bootloader for these devices and thus, in other way restricted users to try out some unofficial things like root and all. For hardcore Android users, It was like – if you flash an official Android 4.3 firmware, you’re screwed up because if you perform any unofficial activity, your warranty gets void instantly. But thanks to those developers @XDA Forums that DeKnoxed the official firmware (removed the KNOX bootloader), recompiled it and made it available in the form of a Custom ROM.
I was also searching for this kind of stuff for my Galaxy Note 2 (since I’ve 2 months of warranty left for my phone and I didn’t want to lose it because of this crappy bootloader). I flashed those ROMs and observed some weird thing. I noticed that my proximity sensor was no longer functioning. It was working only for first time i.e. if I make a call, it was turning off the display but wasn’t turning it on again. I got tensed and thought that it might be caused by my phone’s screen (as I had dropped and cracked it earlier). I searched for this problem on the internet and saw that many people were having this bizarre problem after updating their phone to Android 4.3. Luckily, I found some working solutions on the famous XDA community, out of which few were temporary and one was permanent. In this article, I am going to share all those solutions with you. I hope you’ll find this guide helpful in calibration process of your device’s proximity sensor.
You’ll definitely need to follow this guide if your Samsung phone’s proximity sensor is not working anymore.
- Rooted Android running Samsung smartphone / tablet.
- USB Debugging must be enabled in your phone. To enable the same, navigate to – Settings –> Developers Options and tick the USB Debugging option. If you don’t find Developers Options in Settings then open About device option and tap build number 7 times. This is particularly required for Android 4.3 ROMs.
- If you don’t want to use PC in the whole procedure then you’ll require an app called Terminal Emulator. It’s available for free on the Play Store.
Normally, proximity calibration can be done using two main methods. Out of which one is temporary and another is permanent. Temporary method is short and easy as compared to the permanent one.
There is one more method which is quick simple as compared to these two. The method is – you’ve to blow the air in 3.5 mm headphone jack of your phone. This method may or may not work but you should at least give it a shot. Obviously, there is no need to follow other 2 methods if blowing air gets your job done in the first place.
Method 1
This is a short and quick method to calibrate the proximity sensor. But it doesn’t stick permanently as proximity sensor loses the calibration after rebooting the phone. And therefore you’ll have to apply this method upon each restart. It may not be handy in some cases but being a short method, it does the job pretty quick. So, lets begin!
- Firstly, download ADB files on your computer. You can get them by clicking on the link mentioned below.
- Now, as stated in Pre-Requisites, enable USB Debugging in your phone and then using a USB cable, connect it to the PC.
- Extract ADB_Fastboot.zip on your PC and open the extracted folder.
- Double click on runme.lnk file and type the following command –
adb devices
If your device is connected properly then command prompt will display some random numbers after entering the above command.
Note: Your computer may prompt for USB Debugging on a phone. In that case, select Ok and optionally tick ‘Always allow from this computer‘
- Now, type the following commands one by one and hit enter after each command.
adb shell su echo 0 > /sys/class/sensors/proximity_sensor/prox_cal echo 1 > /sys/class/sensors/proximity_sensor/prox_cal
- Remove your phone from computer and make a call to check the proximity calibration. It should be working fine.
Note: This same process can be performed without using a computer. To do so, you’ll need to download and install Terminal Emulator App from Play Store. Open it and type “su” (without quotes) and hit the enter. Grant Superuser permission if required. Now, type those 2 echo commands (mentioned above) to calibrate the sensor.
Method 2
As stated above, if you use Method 1, it may or may not stick permanently as you’ll need to perform calibration on every restart (which is inconvenient). Now, with Method 2, you can calibrate the sensor permanently.
It’s bit a lengthy and little complicated process to follow but does the thing perfectly. Similar to Method 1, we’ll be using ADB shell method for the calibration. You may use terminal emulator app as well.
Note: Try to keep ambient as dark as possible. It may not work with bright surrounding.
- At first, download ADB package on your PC and extract them in a folder.
- Enable USB Debugging in your phone (refer Pre-Requisites) and connect it to PC.
- Open extracted folder on PC, you’ll find five files inside it. Right click on runme.lnk and select “Run as administrator”.
- Generally, to calibrate the proximity sensor, we require two values namely ‘Offset’ and ‘Normal State’. We need to find these values individually & add them together. And then we’ll convert the output of an addition to its equivalent hexadecimal value. So, let us find Offset and Normal State values first.
- Finding Offset – To find the offset value, enter the following command in the command prompt (i.e. runme.lnk). Instead of typing the whole command, you can simply copy / paste it in the CMD.
adb shell su cat /sys/devices/virtual/sensors/proximity_sensor/prox_cal
Note down the values it returns. For e.g. if you get 5, 64, 100 then 5 is your offset value. You can ignore the other two.
- Finding Normal State – To find normal state, enter the following command
cat /sys/devices/virtual/sensors/proximity_sensor/state
Entering the above command will return a single value. Note it down. For e.g. if it returns 64 then it’s your Normal State value.
- Now, we need add Offset and Normal State values together. In my case offset and normal state values are 5 and 64 respectively. Therefore, addition of 5 and 64 becomes 69. Next step is to convert 69 into its equivalent hexadecimal value.
- After converting 69 into hex, we get 45. You may get different values like 4A, 6B, 2C etc.
- Now, by using ADB shell, we’ll write 45 in /efs/prox_cal. To do so, one by one, enter each given command in the same command prompt window.
echo -en $ '\x45' > /efs/prox_cal chown system:system /efs/prox_cal chmod 644 /efs/prox_cal sync reboot
While typing the third command, replace 45 with your own hexadecimal value.
- Wait for phone to reboot. By this time, you have successfully calibrated the proximity sensor of your Samsung smartphone. To check the calibration, open dialer app and dial ‘*#0*#’. As soon as you type this, menu with several options will get opened. Select Sensor option from that.
- Now, hover you hand above the proximity sensor, it should turn your screen into the green color & as soon as you remove your hand, it should return back to normal state.
Screenshot showing Sensor Testing Menu
Tip – The same method can be done using a Terminal Emulator app.
Congratulations! You’ve successfully performed the proximity sensor calibration on your phone. Now, reboot your phone as many times as you want because now you need to not worry about the calibration thing again and again. Method 2 will stick permanently no matter what you do with your phone.
Let us know if you face any difficulties while performing the procedure mentioned above. To contact us, simply drop a comment below and we’ll get in touch with you.
SOLUTION — SOLUTION — SOLUTION — SOLUTION
FOR EVERYBODY, THE 1st SOLUTION BUT NOT THE SECOND, HERE IS THE KEY:
1. Connect by adb
2. RW-remount of / with the command:
$ mount -o remount,rw /system
3. Create the Autorun-Script as mentioned in method 1 above:
$ nano /etc/init.d/90calibrate
Fill in the following text: (within the lines)
——-
#!/system/bin/sh
echo 0 > /sys/class/sensors/proximity_sensor/prox_cal
sleep 1
echo 1 > /sys/class/sensors/proximity_sensor/prox_cal
——
Save with CTRL+O
4. Set file-permssions to “execute”
$ chmod 777 nano /etc/init.d/90calibrate
5. Reboot with command
$ reboot
You can say thank you to martin.koell@gmail.com 🙂
It Works but VERY VERY IMPORTANT!!!!!!
echo -en ‘\x45’ > /efs/prox_cal
THERE IS AN ERROR DON’T write the “$”. Correct use is:
su
echo 0 > /sys/class/sensors/proximity_sensor/prox_cal
echo -en ‘\x78’ > /efs/prox_cal
chown system:system /efs/prox_cal
chmod 644 /efs/prox_cal
sync
There is no need to reboot – you can check the values directly in *#0*#.
Check the Offset you have, the high Threshold and the low threshold. Your pone MUST be under the low threshold if there is nothing near the proximity sensor.
For example my ADC is about 200, my low THD was 180 and my Offset was 90.
To increase low THD I needed to increase it at least for over 200 so I choose 210, this means 30 more than actual. Offset was 90 + 30 = 120, convert to hexadecimal (Windows calculator does it easyly in the programmer view) = 78.
So I changed the echo command above to x78.
on my note 4 versión 2 worked for me – thank you.
BUT IMPORTANT: Don’t writek the ‘$’
echo -en ‘\x60’ > /efs/prox_cal
I used first *#0*# to see values. My value without ttapping sensor were 150, tapping sensor was 255, untapping was 170. But actual low threshold was 165 so it kept Green (it only went to White taking of fast the tap).
As I knew that tapped it went to 255 so I wanted to add 90 (255-165) to my threshold.
90 in hexadecimal is 60. Now it Works great.
Thanks a lot
i have tried the terminal emulator running the first command… it reported back no device found… note that none of the samsung s4 sensors are working… the corning glass though is shattered from the lefthand top corner to the bottom… spiderweb at the top and just cracks lower down… the screen though is responsive all over… any help please? the current android version is lollipop 5.0 1… got this device as a gift as the previous owner did not want it with the cracks etc
My cell phone has been censored active always plz solve my problem
Worked on S4 i9505 with 4.2.2 and on slimkat 4.4.4 Thanks a lot man
Method 2 worked for me, but you have to be sure to be on root if using android terminal as it may not be readily apparent
THANKS!!
I tried method one and it didn’t not work…that’s the blowing method……tried the temporary method got the same result…I tried the permanent method …when I entered the first come I got a result saying….”tmp-mksh:cat/sys/device/virtual/sensors/proximity_sensor/proxy_cal: not found” what does that result mean???
Thanx a lot.
Blowing air method worked..
Thanx a lot.
M919 4.4.4 both methods do not work. Matter-fact, all the sensors on “my phone” does not function. Any ideas as to why? before on 4.3 after doing Method 1, all the sensors would work and be recognized on the sensor tests. After 4.4.4 upgrade, nothing works for me. Method 1 or Method 2. Any help on this? anyone?
This worked a treat, thanks! One point I struggled with was getting a permission denied error for su. I had to enable root access for ‘Apps and ADB’ in cyanogenmod settings before I could issue the commands you specified. Once I changed that everything worked perfectly 🙂
1|shell@t0lte:/ $ su echo -en $ ‘\x0F’ > /efs/prox_cal
su echo -en $ ‘\x0F’ > /efs/prox_cal
/system/bin/sh: can’t create /efs/prox_cal: Permission denied
1|shell@t0lte:/ $ su
su
Permission denied
how to enable root access for ‘APPS AND ADB’?
Works perfectly, I remember doing this a long time ago when 4.3 just came out. I actually had sent my phone in to Samsung because this was an issue. Good tutorial.
didn’t work for me on my s3 I9300
no method worked my problem is PROXIMIY:1 ADC:0(0.0.0)
i installed a custom rom to resolve this problem
in the stosk rom 4.3 and other stock roms 4.2.2 and earlier idn’t work the problem remains
but on custom rom 4.4.2 it works proprly no problem
I have flashed Dn3 rom v5.5 on my Note 2.. It works fine just the air gestures are not working.. I tried in *#0*# the screen turns green whenever I hover my hand.. But the Air gestures doesn’t work.. Is this a proximity sensor problem?? Help me plzz
Dear Viraj, that problem led me to format twice and change the ROM, then I found out about the way to test the sensors then your site to calibrate, to my surprise the 2nd way did not work: I got 0 and 96 so added to 96 thats 60, and did not work, so I tried the 1st way and it worked, I returned back to the 1st and it gave me different numbers 55 and 95 = 150 that’s 96, and also did not work and the 1st worked again, what do you think I am doing wrong, I want it to be permanent, Thanks
Thank you so much! My prox sensor was messed up on an earlier rom, upgraded to a KitKat rom and the sensor was totally messed up. Method 1 didn’t work, but method 2 worked flawlessly.
The returned values were 0,120,80 before running this
Now they are
u0_a244@hlte:/ $ su
al/sensors/proximity_sensor/prox_cal <
5513212,5513332,5513292
al/sensors/proximity_sensor/prox_cal <
5513212,5513332,5513292
al/sensors/proximity_sensor/state <
84
What went wrong?
Note3 running 4.4.2 rooted and custom ROM
Hello.
I have galaxy pop shve220.
when i dial *#0*# and click sensor it randomly changes color to green and white by itself without placing finger on proximity sensor.
Can somebody help me with this problem.
When i dial *#0*# and click sensor it randomly goes green and white itself Without placing finger on proximity sensor.
Can somebody help me with this Please……
Thanks for the solution, my screen was not responding after CM 11 update on my phone Canadian Note 3. Your method works but the directories are different.
su
echo 0 > /sys/devices/virtual/sensors/proximity_sensor/prox_cal
echo 1 > /sys/devices/virtual/sensors/proximity_sensor/prox_cal
Hello viraj,
My phone is rooted and i did per-requisites as adviced but i am not able to use adb shell neither via terminal app..plz advice what other option do i have.been googling forums and all and echo method works for many guys but how i get to that …i always get error couldn’t create directory in terminal aap.. i tried 2 apps to check if my device is rooted and it says yes it is..btw i am using s3 firmware 4.3
Same for me: My phone was showing offset “0,15″ and my normal state was “0″. I press “0″ instead of 45 and it worked! Thanks!
hello , my device is note 2 and i tried the method one nothing happen & when i try method 2 and write the command to fin values the terminal says not found !!!!
when i dial *#0*# sensors i found that prox sensor and light sensor 0,0,0
without numbers and sensor doesn’t work . is it a hardware issue or can you tell me to do something about it ??
by the way my device is rooted
thanks
I have Samsung Tab s 8.4 LTE
Could the Accelerometer Sensor be re-calibrated?
My x-anagle, y-angle, z-angle are 1, 1, 89 of my Accelerometer Sensor.
I’would like to re-calibrate it, is any method can do it?
Many thanks.
Please refer this guide: http://forum.xda-developers.com/showthread.php?t=2593443
thank you extremely much. thank you
this problem was crazing me
Glad it helped you 🙂
Is any method could re-calibrate “Accelemeter senson” after android 4.3?
because my x-angle, y-angle, z-angle are not 0, 0, 90 in Accelerometer sensor.
No such file or directory when I enter “cat /sys/devices/virtual/sensors/proximity_sensor/prox_cal”.
Works on my S4, Thanks!!!
You’re welcome!
I have problem with gesture sensor on S4……… not working at all ………. Can any body help me ??
can some one help me.. from adb shell i cannot type su because it says that su: not found
How did you resolve it, “SU” not found
please root your phone first
My phone was showing offset “0,15” and my normal state was “0”. So I putted “0” instead of 45 and surprisingly it worked! Did not think it would work, but it did… Thanks!
Method 2 worked for me perfectly. This has ended months of frustration with erratic screen lockouts during phone calls. I’ve done everything from blow compressed air into the earphone piece and enter console commands over and over, but Method 2 settings have stuck. Thank you.
Method 1 worked on my Note 2, thanks a bazillion!
Just want to say thanks it fixed my problem with note 3, on 4.4.2
For any one that tried method 2 and doesn’t work, try doing method 1 and then do the following:
$ chown system:system /efs/prox_cal
$ chmod 644 /efs/prox_cal
$ sync
$ reboot
it works for my note 3.
I tried method 2, but after i modify the /efs/prox_cal file, the offset is then broken:
cat /sys/devices/virtual/sensors/proximity_sensor/prox_cal
944054268,944054388,944054348
Instead, just use method 1 and the command above.
thank you so much!
your additional steps worked for me!!! thanks
What a flaw from Samsung…
I never installed the stock 4.3, but all-of-a-sudden I’m seeing the same behavior after flashing some 4.4.4 custom ROM or another. I was going through a few and strolling through options to see which one I would try for a while, so it’s hard to say exactly when it happened. I found a lot of people in the Note2 forums having the same problem, and even a flashable in the Omni forum that was supposed to fix it. Nothing worked and it persisted between ROMs, even stock variants. THIS FIXED IT! I spent days working on this and this is what finally did it. THANK YOU!!!!
Glad it worked for you!
Thank you . It worked !!
Hi! I need to know how to enable ‘*#0*#’ option. It does not work on my samsung galaxy s3, running CM11 4.4.2. There is no response when i press these charaters.
It works only on stock Samsung firmware.
Any other option available? BTW i followed this article and used the method 2 option, and the sensor works fine. Thanks
No.
Elixir/Elixir2 works for testing the proximity sensor.
Manually reboot the device and check if it has calibrated the sensor.
Hi Android Legend,
I have tried Method 1 using both PC and then directly from my Android.
I have copied and extracted the file in my computer. Click “runme” and MS-DOS prompts Windows pops out, I’ve write down the command ” adb devices” and it replied “Access Denied”. I have earlier granted the “runme” Administrator privilege and my Android (which is Samsung S4 Active) is in Debugging USB Mode too.
1) Could it be I have missed out other procedures? Currently I am using Windows 7 64 Bit.
2) Then I’ve tried the 1st Method using Android directly, I’ve installed the apps – Terminal Emulator and write down the “su” command all I get is a respond “…/system/bin/sh: su: not found
127|u0_a210@android:/ $…”
#need help to calibrate my proximity sensors and gyroscope
THANK YOU!
You need to root your phone.
how to root the phone??
my samsung S5’s screen rotation and gyroscope doesn”t work atall, Verizon has blocked the *#0*# code, what do I do?
How did you resolve it, am having the same issue
Well i took your advice and blew into the headphone jack, and it worked. Thanks
Welcome ☺
hey I am having a problem for hearing while on call, i flashed DN3 rom for my note2 and then flashed an audio fix zip (which i suppose is the reason for the problem), I wiped everything and then flashed the tom again (this time without the audio zip) still having the same problem, whenever i am on call , am unable 2 hear clearly, first i thought that my speaker is damaged, but i am facing the same problem on earphones also, music and videos are working fine on my earphones as well as speaker, A member on xda suggested me this post, Should i try it ??
By the way i checked my proximity sensor in the sensor option, whenever i wave my hand it turns green, this means they are working fine, should i try this method, please help
Yes, you may try this. There is no harm in performing this method.
Sorry for my ignorance, but how do you find the hex value?
First find the Normal state and then use an online calculator or something else to convert that value into hexadecimal.
Dear Viraj,
Unfortunately my offset value is 0 (pretty sure, both the phone reports it when I check with *#0*#, or your method 1 returns this value as well). I saw your comment that it should not be 0. Do you have any suggestions, what should I do?
I already dismounted the phone, cleaned the sensor area (actually, I didn’t see dirt or dust there), and tried your method 1, but neither of these attempts helped.
I did not experiment with method 2 yet, because of the 0 offset.
Thank you in advance,
Derag
Try with the second method and see if it works.
Thank you very much, it worked!! Actually, at the first try it did not work, some hours later I repeated everything. Interestingly this time the normal state value was higher on the phone than at the first try, I don’t know why (offset was still 0), but with this value it worked like charm …
It may be because of ambient light intensity. But anyways I am glad that it worked for you.
Recently I have been having issues with my incall sound. I can’t hear anything from other end. But when I calibrate my proximity sensor it works..but sometimes not..any idea what the problem could be…please help…also I am running a custom rom from the beginning and the problem has arised now
I’ll recommend you taking your phone to Samsung Service center and clean up that particular portion (area around proximity sensor) from there.
I used method 2 on my VZW GS4 running slimkat and this worked perfectly! My offset returned a value of 0 and normal state returned 46. Hexadecimal value turned out to be 2E. Followed the instructions and it works perfectly! I cannot thank you enough! Proximity sensor responds to my hand about 1.5 inches away.
Glad that it worked for you 🙂
thanx a lot . it worked for me i got values as 0 and 12 and i used those…but range for activation is 1-2 cms frm prox sensor…its fair enough….thank you again
Did you check if calibration is done properly? If yes then don’t bother about ADC values. They depend upon the surrounding (intensity of an external light) while calibration is done. So those values need not to be same for every other device.
Hi, thanks to useful help (sry my English is not good)
I tried many numbers but no one work correctly, these are my screen shot,the correct numbers are like my brother’s note3
plz help me to make correct my phone, very very very thanks
my Device is Note 3 (sm900) 4.4.2
It would be better if you try to find them using ADB commands only.
Nice. You can also downgrade your bootloader to remove knox. Unfortunately I tipped knox but my warranty is already over so it means nothing. Stupid me for taking the ota. I didn’t take the ota on my s3, that was much better because now I can install a 4.3 with knox removed. Never take an ota without researching first
Hi Viraj.. Thanks for this post. But it doesn’t seem to be working for me. i downloaded the adb package on my computer and when i ran those commands as instructed i got errors like syntax incorrect and ‘cat is not recognized as an internal or external command. I downloaded the terminal emulator app on my phone and the second method seemed to work. but again there was a problem. when i typed the command to get the offset value, i got my offset value as 0. And i got the normal value as 118. so 0+118 is 118. Wouldn’t this cause a problem? Please advice. I didnt proceed further from here. Thanks
Firstly, offset value shouldn’t be zero.Secondly, while finding offset values in Method 2, enter ‘adb shell’ before you enter any other commands. This should solve the error you’re getting.
Refer the updated article above.
If you’ve any questions then feel free to ask me.
When i enter ‘adb shell’ in my terminal emulator it says “error:device not found”. When i enter “su” it says “su: not found”.
Kindly advice
Before you use any of the method, you’ve to root the device and enable USB debugging option. Refer the pre-requisites section..
This doesn’t appear to be working for me with my Galaxy S3. Either method. When I go into the list of sensors, there is no proximity sensor listed. I have accelerometer_sensor, barometer_sensor, gyro_sensor, and magnetic_sensor. No proximity. Suggestions?
THANK YOU! Was driving me bananas! (d2spr, SlimROM 4.4)
thanx man, very usefull, i have calibrate my sensor with second method but please add a line: calibration must set under darkness or else will not work under bright light. sorry for my bad english but here in romania we speek romanian 😉 please stick this under xda forum.
Oh yeah! Forgot to add that condition. Anyways glad that it helped you.
dude. this is too high tech for me. I helped my roommate buy a Galaxy S3 on line (unlock at&t version). The phone was turing the screen black while on calls or receiving and would only work again until the call end it.. So, we were glad to know it was under warranty. We sent it to samsung in Texas and came back with a NEW proximity sensor. NOW we have different issue. When he dials a number or gets a phone call the screen still goes black when he answers BUT at least now it turns on when he presses the home button. SO i came to the conclusion that it is the software that has the issue. The phone was running android 4.something. when we got it from ebay, and when it came back from samsung it is running 4.3 BUT with a brand new proximity sensor so it must be the samsung crapy software on top of android 4.3.
I have a question, do you think 4.4 will fix the issue? (whenever AT&T feels like give it to us)
ALSO, what I told my roommate to do is this:
de-select the option to turn the screen off when on a call (the screen stays on) and to AVOID touching the screen while on a phone call, told him to just press the wake on/off button before putting it on the ear (since the phone call does not end when press it unlike the iphone that does.) That solved the problem to have a black screen the moment he press call or accepts a call.
PLEASE let me know if AT&T will give us 4.4 and if so when. Thanks.
I am sure that this fix will definitely work for you. Just give it a try.