Any DSLR model:
In camera mode M (manual) or mode S (shutter preferred), you can select a long shutter speed up to 30 seconds (which is actually 32 seconds), and it will do it. (You cannot set shutter speed in Auto or P or A modes).
Or, you can select Bulb (the slowest shutter "speed" setting), which will keep the shutter open as long as you hold the shutter button down. With Bulb, to avoid shaking the camera, you could use a remote shutter cord (MC-DC2 type for the D5200, Reference manual page 210), or equivalent inexpensive imports on Ebay, some of which have a lock switch to hold it open for you.
Or in the D5200,
the remote shutter mode (ML-L3 remote) has a Time setting, where the first click opens the shutter, and it stays open until the second click, which can be up to 30 minutes (make sure you have fresh battery). Reference manual page 60.