I got it from my old phone (redmi 3s prime) and was wondering if I could connect it to an Arduino or a raspberry pi ,since I don't know what type of communication protocol it uses.
If you want to connect any new chip to any other chip (in this case the microcontroller of the Arduino), the first way to go is the datasheet of that new chip. Chips, that you can buy in a shop, mostly have some kind of product number/ID written on them. Then you can google for it and read in the datasheet, how it needs to be connected and used.
It is different with most parts, that are used in highly integrated and complex devices like a smartphone. These parts are mostly custom made. They often have no writing on them and there is no datasheet for them available (since they were made by the manufacturing company solemly for the manufacturer of the smartphone or for any of the rather small number of customers, that such companies have). With no documentation, your only way to use this sensor would be to reverse engineer it. This can be a very very difficult and complex task, which needs rather professional equipment and very high knowledge. As you are asking this here, I guess, that you don't have such a knowledge (such people normally don't ask such questions, as they already know about the complexity). I myself also cannot state to have this level of knowledge.
Unfortunately you are stuck with throwing the sensor away. It's not worth the hassle of trying to use it.