Check if it didn't get any liquid damage. (Sensors are located inside the HP Jack and dock connector + 2 additional on the logic board, inside the phone)
Otherwise it can be some other logic board failure.
But first, try to connect it in service mode and try to restore it with iTunes (press and hold home button and while holding it connect to your computer, then restore)