The phone's sensors fall asleep when the screen is turned off

Yes depending on how you need to have it work. You might modify Extension with Rush. Keep the app running. Doze mode. Service. Notification. Source code . This free extension does work with the GPS receiver (what I use successfully) and it should do what you hope to. It should work with accelerometers too. You have to modify it to work even when the app screen is not showing and you are doing other things on your phone.

This extension Background Tasks extension [3.8 A] 🥳 should also work .

How do you use them? Please read the threads and modify and experiment. Adapting these stool to work with any specific Project is complex. Experiment and learn a lot.