Sleep is a conserved biological process in the animal kingdom. Understanding the neural mechanisms underlying sleep state transitions is a fundamental goal of neurobiology, important for the development of new treatments for insomnia and other sleep-related disorders. Yet, brain circuits controlling this process remain poorly understood. A key technique in sleep research is to monitor in vivo neuronal activity in sleep-related brain regions across different sleep states. These sleep-related regions are usually located deeply in the brain. Here, we describe technical details and protocols for in vivo calcium imaging in the brainstem of sleeping mice. In this system, sleep-related neuronal activity in the ventrolateral medulla (VLM) is measured using simultaneous microendoscopic calcium imaging and electroencephalogram (EEG) recording. By aligning calcium and EEG signals, we demonstrate that VLM glutamatergic neurons display increased activity during the transition from wakefulness to non-rapid eye movement (NREM) sleep. The protocol described here can be applied to study neuronal activity in other deep brain regions involved in REM or NREM sleep.