I am using Mİ 8 SE and I have had this problem myself. Sensors do not work by accidentally deleting persist.img file while TWRP is installed. I made this solution very simple and all the sensors work well
Just as you are downloading Mi 8 Se stabil Rom. Then find the persist.img file in the Rom...