Q. Is one allowed to take sleeping pills just to help one sleep better during Shabbat? Is one allowed also to take wake up pills?
A. Poskim disagree regarding sleeping pills. Shemiras Shabbos K’ (33: 17), Horav Moshe Heinemann Shlit’a and other Poskim maintain that if the lack of sleep will cause the person to be unable to function normally the next day, he may take a sleeping pill on Shabbos. Otherwise, he should not do so.
On question 3220 we wrote: “Ketzos Hashulchan (138: n.31) and other Poskim maintain that one suffering from insomnia or fatigue is permitted to take sleeping pills to stimulate sleep. He argues that it is not considered a ‘Refuah” or healing, which would be prohibited on Shabbos, since lack of sleep is not in itself a sickness and the pills taken are not a cure.”
(See also Minchas Yitzchok 3:21, Eshel Avrohom 327, Tzitz Eliezer 9:17, Be’er Moshe 1:33 and Shalmei Yehudah, p. 176, Shulchan Shlomo 328 and others for different views).
Chazon Ovadia (Shabbat, 3: p. 367) also permits without the fear of becoming ill if one does not take them.
Horav Shlomo Miller’s Shlit’a opinion is similar and one can be lenient including taking wake up pills, which are basically just caffeine as in coffee.
Rabbi A. Bartfeld as revised by Horav Shlomo Miller, Horav Dovid Pam, Horav Aharon Miller and Horav Chanoch Ehrentreu Shlit’a