Illustration by Miguel Gallardo

It’s 2:49 A.M., more or less my bedtime, and I’m about to put on my Sleep Shepherd hat, a device designed to help the wearer go gentle into unconsciousness ($149.99). The hat is a stretchy black beanie, but where you might normally find a pompom there’s a plastic box the size of a Triscuit. If I were an alien, this would be the port through which I’d receive my instructions from the mother ship. The box has an on-off switch, and I’m going to turn it on so that the mechanism can commune with my head.

The hat measures activity in my cerebral cortex through three sensors sewn into the fabric—one covering each ear and a third handling the forehead. There are also built-in speakers that emit pulsing tones mimicking the frequencies of my brain waves. Gradually, the rhythm will slow down and, supposedly, so will my brain, entrained as if by a hypnotist. The noise sounds like the tone you’d expect to hear before a nuclear disaster. It’s supposed to be soothing, and, truth be told, I don’t mind it. The hat was invented by Michael Larson, a mechanical engineer at the University of Colorado. Larson told me, over the phone, that he came up with it to treat his daughter, who had an autoimmune disease that prevented her from getting enough deep sleep. The contraption apparently did the trick.

In my case, it’s hard to say whether it was the hat or causes non-millinery that ushered me into dreamland each of the nights I wore it: I always woke up to find the hat on the floor. But I don’t really have insomnia. Every so often, I will resort to counting sheep—actually, I count divorced couples I know, and sometimes, at 5 A.M., couples who should get divorced—but, in general, I do not want to fall asleep ever. I have spent my life staying up later than I should. As a child, I was convinced that turning in meant missing out on illicit fun. I tried to train myself to sleep with my forearm upright, my head propped on my palm, so that if my parents walked by my room they’d see that I never slept and therefore didn’t need a bedtime. My favorite TV show, I used to say, was “The Late, Late, Late, Late Show.” When I got older, I liked being up at night because it seemed more productive to work when nobody was calling or e-mailing, and by work I mean Netflix. Besides, I’d always thought, What’s the big deal about being tired as long as your job doesn’t involve flying a plane—or, I suppose I should add, responsibilities like getting dressed?

Unfortunately for me, regularly spending a chunk of the nighttime in a state of suspended consciousness and drool turns out to be a gigantic deal. According to scientists I spoke with, the quality of your slumber has more repercussions on your happiness, intelligence, and health than what you eat, where you live, or how much money you make. Not to be a downer, but chronic sleep deprivation, which Amnesty International designates a form of torture, has been linked to diabetes, cancer, high blood pressure, heart disease, stroke, learning difficulties, colds, gastrointestinal problems, depression, execution (the sleep-starved defense minister of North Korea is rumored to have been shot after dozing in the presence of Kim Jong-un), world disasters (the Challenger explosion, the Three Mile Island meltdown), and non-disasters (the drop in the polls of Donald Trump, who is reported to get only three or four hours of shut-eye a night).

Many scientists have come to believe that while we sleep the space between our neurons expands, allowing a cranial sewage network—the glymphatic system—to flush the brain of waste products that might otherwise not only prevent memory formation but muck up our mental machinery and perhaps eventually lead to Alzheimer’s. Failing to get enough sleep is like throwing a party and then firing the cleanup crew.

A National Institutes of Health study showed that twenty-five to thirty per cent of American adults have periodic episodes of sleeplessness and twenty per cent suffer from chronic insomnia. On the advice of sleep doctors, fatigue-management specialists, and know-it-alls on wellness blogs, these tossers and turners drink cherry juice, eat Atlantic perch, set the bedroom thermostat between sixty-seven and seventy degrees, put magnets under the pillow, curl their toes, uncurl their toes, and kick their partners out of bed, usually to little avail. According to a study by the Centers for Disease Control and Prevention, four per cent of Americans reported having taken prescription sleeping pills in the previous month, and an additional who-knows-how-many use anti-anxiety medications like Valium and Klonopin. Never mind that some studies suggest that a pill can extend your sleep by as little as three minutes a night and reduce the time it takes to nod off by only eight to twenty minutes.

Evidently, it was ever thus. The ancient Romans smeared mouse fat onto the soles of their feet, and the Lunesta of the Dark Ages was a smoothie made from the gall of castrated boars. Charles Dickens apparently believed it was necessary to position himself in the precise center of a bed that faced exactly north, while the Glasgow Herald advised the worried wakeful to lather up their hair with yellow soap before bedtime, wrap their heads in napkins, rinse in the morning, and repeat every night for two weeks. In 1879, a Canadian medical journal recommended hemlock. Presumably, no repeating was required.

Lately, a dreamy abundance of gadgets, fancy pillows, expensive masks, and other non-sex-purposed bedroom paraphernalia have entered the marketplace. They promise a refreshing sleep, or, if that fails, at least an accounting of how much you snore. There would not be enough nights in the wild dark yonder for me to try all these products personally, but fortunately the anguish of others can be a journalist’s good fortune. A bunch of friends, sick and tired of staring at the ceiling, waiting for their mental power switches to flip off, signed on to sample sleep aids and keep diaries during their trials. As if stalled every night in the waiting room of the world’s slowest doctor, these insomniacs had regularly passed their nights memorizing the arrangement of notes on a guitar fretboard, nurturing grudges, hating themselves, thinking about world peace, pretending to be in a submarine, and worrying, Is it Alzheimer’s, or worse?

We will begin with the photonic devices, but first some background. Unless you live in a drawer underneath a lot of socks, your sleep patterns are cued by light and its absence. Photoreceptors at the backs of your eyes pick up light and send corresponding electrical signals to the suprachiasmatic nucleus, in your brain. (If you are not a great speller, you can call it the internal clock.) This master timekeeper regulates and synchronizes a host of other physiological systems, such as temperature and blood pressure, making sure that they all operate on the same roughly twenty-four-hour cycle, known as the circadian rhythm. In an ideal world, by which I mean an un-ideal world without recessed lighting and iPads, the sun sets, it becomes dark, and, presto, your pineal gland starts to release the sleep-inducing hormone melatonin (and a few other hormones). During daylight hours, melatonin production is reduced. Exposure to light, especially to the blue light of digital devices, discombobulates the clockwork.