You need to activate Developer Mode first (tap the Build number entry in the About phone menu in Settings seven times) and then choose Developer options from the Settings menu. Choose Stay awake and as long as your phone or tablet is plugged in, the screen won't go to sleep after a certain period of time.