Computers and mobile devices are enemies of a good night’s sleep, interrupting slumber with text alerts and disrupting natural sleep rhythms with their glowing blue screens. But a new generation of apps and devices may also be the way to improve sleep.

Manufacturers are coming out with gadgets like cellphone alarm clocks that wake people at the most opportune point in their sleep cycle and heart rate monitors that people strap on at night, part of a broader movement to improve health by quantifying behavior.

While a person can count calories consumed or miles walked without the help of a digital tracking device, it’s nearly impossible to track sleep without assistance. Studies have shown that people do not accurately recall night waking, and that the more sleep deprived they are, the more they underestimate their impairment.

Doctors often focus on diet and exercise and overlook sleep, though it affects things like workplace productivity, driving skills, sociability and weight. Some researchers say the new technology can help focus attention on the problem.

“These devices are really exciting because it’s a way of engaging people with interest about their sleep, which has been a challenge on the health behavior front,” said Aric Prather, an assistant professor of psychiatry at the University of California, San Francisco, who researches the relationship between sleep and stress. “Things improve when the data is at the front of their consciousness.”

Yet sleep scientists also warn that the devices could have little more than a placebo effect — or, worse, endanger patients by masking a sleep disorder that needs medical attention.

“A lot of the marketing and claims are not substantiated” by peer-reviewed scientific studies, said Hawley Montgomery-Downs, director of the sleep research laboratory at West Virginia University.

Studies show that consumer sleep trackers typically can’t replicate the experience of patients spending the night in a hospital sleep lab, where electrodes attached to their heads measure things like blood oxygen level and eye movement. Known as polysomnography, this comprehensive recording of the biophysiological changes taking place during sleep is considered the gold standard for sleep studies.

Is Fitbit fit?

Montgomery-Downs studied the Fitbit, a wristband that analyzes sleep and exercise by measuring movement, and determined that it overestimated sleep time and quality by mistakenly tracking wakefulness as sleep.

Still, Dr. David Claman, director of the sleep disorders center at UCSF Medical Center at Mount Zion, said data from sleep-tracking devices could be useful.

“As a sleep specialist, I can’t give a person a clean bill of health based on the apps that are available,” Claman said. “But if the device says there’s too much movement, I do find that to be a helpful justification to go along with a more detailed sleep study evaluation.”

The devices can also encourage changes in behavior by healthy people who simply want to sleep better, he said, particularly by giving people a more accurate idea of how long they’re sleeping. “A lot of people are more sleep-deprived than they realize,” he said.

The most basic sleep trackers are cellphone apps that record when users fall asleep and wake up. Some, like Sleepbot and Sleep Cycle, also use the phone’s microphone and accelerometer to record noise and movement, so people can confirm that a siren woke them up at 3 a.m. These apps also incorporate an alarm clock that wakes people within a half-hour period at the lightest point in their sleep cycle.

Wristband devices like Fitbit, Jawbone UP and Basis can measure how soundly people sleep based on data about things like how much they move at night. The gadgets offer online charts for tracking sleep patterns over time.

Jawbone has a “Today I Will” feature that allows people to set goals. Among device owners who have used the feature, 72 percent have been going to bed early enough to achieve their goals, and they have been 26 percent more likely to get seven to eight hours of sleep than those who have not set goals, said Monica Rogati, the head of data for Jawbone.

Other sleep trackers, like the Aura sleep system and Beddit, are not worn but are placed under the bed sheet. Beddit sends data to a smartphone via Bluetooth in the morning. Depending on the data collected, a Beddit user may be urged to avoid caffeine and naps in the late afternoon or to avoid excessive sleeping on vacation.

Training the brain

More advanced devices combine sensors with health information. The Sleep­Rate system uses cognitive behavioral therapy, licensed from Stanford University, to treat insomnia. SleepRate users wear a heart rate monitor while their cellphone microphones monitor nighttime sounds. Based on data analysis after five days, people showing signs of insomnia are presented with a personalized sleep regimen.

The suggestions are basic, but a randomized control trial found they were effective in 85 percent of cases, according to the company. They include waking at the same time every day; stopping invigorating activity half an hour before bedtime and using the bed only for sleep and sex.

“It’s all behavioral, and it’s all trying to train the brain to go to sleep when it’s time to go to sleep,” said Uli Gal-Oz, chief executive of SleepRate.

The future, sleep scientists say, could bring the analysis of aggregate data from thousands of people who use these devices, which could reveal more than a typical study does about how we sleep.

Jawbone, for instance, has discovered from its Jawbone UP data that users who slept with partners went to bed an average of 35 minutes earlier than those who slept alone. The company also found that UP users who kept a laptop in their bedrooms logged 27 fewer minutes of sound sleep, compared with users who didn’t keep a computer by their bedsides.

Rogati said the potential for learning more about global and individual sleep patterns is enormous.

“It could really shed light on trends and risk factors,” she said, “leading toward personalized medicine.”