Hi there, have you tried go to Settings | Advanced features | S Pen | Air actions | 3 dot menu (upper right corner) | Reset S Pen
For this to work, the S Pen needs to be inserted before you tap Reset S Pen, and can take a few minutes to complete. This is also what you would have to do if you replace your S Pen with a new one.
Also Exposure to magnetic or metal objects, as well as some third-party covers and screen protectors may cause issues with the S Pen. Make sure your screen covers or screen protectors are clean.