Your own troubleshooting indicates that when the phone goes into sleep or lock mode, it might interfere with a microphone’s ability to record. You should have a setting in Heidi health to automatically turn off auto lock on the iPhone.