This morning my S5 would not rotate. Tried all the possible cures posted here and other places except I did not do a factory reset, nothing helped.
What DID work was that I powered it down, removed the battery, removed the SD card, cleaned everything out with a microfiber cloth and a cotton swab, then reassembled. Works fine now.
Wanted to post to hopefully help someone else out.