I’ve struggled with insomnia nearly all of my adult life.

Typically, I’m able to fall asleep within an hour or two, but often it takes much longer, and the anxiety about not sleeping has made it so much worse. I’ve accepted that this is something I just have to live with.

A few years ago, I started wearing a sleep mask and turning on cable news so that the mindless banter in the background would distract me from my thoughts long enough to pass out. This isn’t the wisest strategy, but it has, occasionally, worked. Lately, I’ve started listening to meditation apps that play sounds of waves crashing or fire crackling.

If any of this resonates with you, you might be interested in a new book by Henry Nicholls called Sleepyhead: The Neuroscience of a Good Night’s Rest. Nicholls, a science journalist in England, chose the topic of sleep in part because of his personal experience with narcolepsy, a rare neurological disorder that impacts the brain’s ability to control sleep-wake cycles. So he decided to write a book about how to sleep better.

Nicholls surveyed the latest medical research on sleep, interviewed many of the researchers involved, and underwent intense sleep therapy to treat his own condition.

I spoke to him recently about what he learned and about some of the practical things you can do to get a better night’s sleep.

A lightly edited transcript of our conversation follows.

Sean Illing

What’s the key to a good night’s sleep?

Henry Nicholls

The simplest thing is to work on something called “sleep stability,” which is very common advice in insomnia clinics and something my physician, Dr. David O’Regan, recommended as part of my cognitive behavioral therapy course for insomnia.

Sleep stability means pinning your bedtime to the same time every night, even on weekends, and waking up at the same time every morning, even on weekends. The key is to settle into a groove or a cycle that your body understands and responds to. Once you do this, it’s really quite amazing. You’ll sleep better, feel better, have more energy, and worry less.

You have to figure out what the earliest time you need to get up during the week for work is, and then build a routine around that. You subtract the number of hours of sleep you need from the time you have to get up, and that is your bedtime. And you do not go to bed before that time ever, unless you’re just exhausted and can’t help it.

Sean Illing

How much sleep is enough?

Henry Nicholls

Everyone varies, and this is why you need to find out how much your brain needs. And you do that by keeping a sleep diary over a week or two, and just taking an average of how many hours you are actually sleeping. So not lying in bed, but subtracting the time it took you to fall asleep and any time you lay awake in the night. That’s the amount of sleep your brain got that night.

And you average that out over a couple of weeks, and that tends to be a good reflection of how much sleep you need. That helps you work out when you’re going to go to sleep or not. And it also tells you whether you are average in the population.

But it varies by age. Children need much more sleep, teens still need a lot of sleep, and, as an adult, you’re probably looking at somewhere between six and nine hours of sleep in order to be healthy. Again, though, it depends on your particular brain — not everyone needs the same amount of sleep in order to function well.

Sean Illing

So this conventional myth that everyone needs eight hours is just that — a myth?

Henry Nicholls

It’s a useful goal, but it’s not true that everyone needs eight hours of sleep a night. This is something I learned during my cognitive behavioral therapy, and books like Colin Espie’s Overcoming Insomnia and Sleep Problems make the case pretty convincingly.

A lot of people get obsessed with this goal of getting eight hours of sleep every single night, and because they’re someone who just doesn’t need that much sleep, or they can’t reliably sleep that long, they get anxious about it and that actually creates issues with insomnia.

Sean Illing

Over the years I’ve tried over-the-counter sleep aids, but I’ve generally resisted this out of fear that it’ll create a dependency. The only thing I take now is melatonin, which seems safe. What did the sleep specialists you spoke to say about people using melatonin or other over-the-counter or prescription meds to help with sleep?

Henry Nicholls

Well, I think the approach to sleep should be really simple stuff first. I’m not a physician, so I can’t give advice about which medications to take and when, but the consensus among the specialists I spoke to was that you should try to get your sleep stability right first, and make sure that you’re getting consolidated sleep and not waking up all the time.

To do that, you have to implement basic sleep hygiene, which is not drinking caffeine after midday, or exercising too late, or drinking alcohol before bed, and just eating sensibly.

Do these things and you’ll be less likely to wake up with your brain looking for another fix. And if doing natural things like this doesn’t work, then it might be wise to consult with a specialist or a doctor.

Sean Illing

Is bad sleep better than no sleep? In other words, is it better to just get up and do something productive rather than lying in bed for hours frustrated about not being able to fall asleep?

Henry Nicholls

If you’re not sleeping and getting anxious about not sleeping, just get out of bed and leave the bedroom. Sleep specialists have established that staying in bed while you’re anxious or not sleeping is one of the most common contributors to chronic insomnia, because it trains the brain and creates bad associations. So you have to break that.

The bedroom should be for sleeping. If you’re lying in bed for more than 15 minutes and not sleeping, just get out. And don’t take your mobile device into your bedroom because you’re going to use it and the light from it has a delaying effect upon the secretion of melatonin from the brain, which will delay the onset of sleep.

Sean Illing

What’s the most practical advice you give to people who ask you how to improve their own sleeping habits?

Henry Nicholls

In addition to what I said earlier about sleep stability, I’d also stress the importance of light. Both of those things have to do with the body clock and the way the brain orchestrates all the cells and the metabolism of every single cell in your body. Three American scientists won the 2017 Nobel Prize for their work on this.

They discovered that we have these molecular pathways that are responsive to light and allow the body to synchronize to the comings and goings of the sun. When that is working at its most effective, and all the cells are working as a team, overall health is much better. I think most people don’t understand the importance of light and how we consume it. Artificial light is completely at odds with our biology.

Exposure to natural light is really important in terms of keeping our body in tune with its 24-hour rhythm. Exposure to the blue lights of dawn and dusk, these are the signals that the brain really pays attention to and uses.

Sean Illing

So minimizing exposure to artificial lights like smartphones and TV screens and increasing exposure to natural lights like dawn and dusk helps sync our internal clock and prepare the brain for sleep?

Henry Nicholls

Definitely. If you can maintain sleep stability, that means you are seeing that same light at the same time every day and your body will pick up on that. And yeah, most people do not appreciate how disruptive artificial light is to the brain. It confuses your brain into thinking it’s daytime when it’s actually bedtime.

So soak up as much natural light as you can, even those last few minutes of blue light after the sun has gone down. And then avoid wandering around in bright artificial light as much as possible. And if you happen to get up in the middle of the night to go to the bathroom, whatever you do, don’t turn on those bright LED lights, because that will make it much harder to fall back asleep.

These are small things, but if you can do them regularly, it will make a huge difference in your life. It certainly has in mine.