Not sleeping enough or getting a bad night's sleep over and over makes it hard to control your appetite. And that sets you up for all sorts of health problems, including obesity, heart disease, high blood pressure and Type 2 diabetes.

The link between poor sleep and a greater has been shown in study after study, but researchers typically relied on the memories of the participants to record how well they slept.

Sleep apps on fitness trackers, smartphones and watches have changed all that. In a new study, , researchers tracked sleep quality for 120,000 people for up to two years.

The results showed sleep durations and patterns are highly variable between people. Despite that, the study found people with BMIs of 30 or above -- which is considered obese by the -- had slightly shorter mean sleep durations and more variable sleep patterns.

It didn't take much less sleep to see the effect. People with BMIs over 30 only slept about 15 minutes less than their less weighty counterparts.

There were some limitations to the study. Naps were excluded, other health conditions could not be factored in, and people who use wearable tracking devices are typically younger, healthier and from a higher socioeconomic status than those who do not wear trackers.

"These are quite pricey devices, and remember, they are not approved by the U.S. Food and Drug Administration," said sleep specialist Dr. Raj Dasgupta, the associate program director of the Sleep Medicine Fellowship at Keck Medicine of the University of Southern California.

"The results would need to be validated by the appropriate FDA-approved devices, and because the study is likely on younger people who are more economically well off, does that really apply to older folks we worry about with poor sleep?" said Dasgupta, who was not involved in the study.

However, Dasgupta added, a major plus for the study is that it did monitor people for over two years, and the results corroborated prior research and were "not surprising."

"While we cannot determine the direction of association from our study result, these findings provide further support to the notion that sleep patterns are associated with weight management and overall health," the authors wrote.

"The findings also support the potential value of including both sleep duration and individual sleep patterns when studying sleep-related health outcomes."

LINK BETWEEN SLEEP AND EATING

There is a scientific reason why a lack of sleep is linked to appetite. When you're sleep deprived, research has shown, levels of a hormone called ghrelin spike while another hormone, leptin, takes a nosedive. The result is an increase in hunger.

"The 'l' in leptin stands for lose: It suppresses appetite and therefore contributes to weight loss," he said. "The 'g' in ghrelin stands for gain: This fast-acting hormone increases hunger and leads to weight gain," Dasgupta said.

Another reason we gain weight is due to an ancient body system called the endocannabinoid system. Endocannabinoids bind to the same receptors as the active ingredient in marijuana, which as we know, often triggers the "munchies."

"When you're sleep deprived, you're not like, 'Oh, you know what, I want some carrots,'" said behavioural neuroscientist Erin Hanlon, who studies the connection between brain systems and behavior at the University of Chicago, .

"You're craving sweets and salty and starchy things," she added. "You want those chips, you want a cookie, you want some candy, you know?"

A by Hanlon compared the circulating levels of 2-AG, one of the most abundant endocannabinoids, in people who got four nights of normal sleep (more than eight hours) to people who only got 4.5 hours.

People who were sleep-deprived reported greater increases in hunger and appetite and had higher afternoon concentrations of 2-AG than those who slept well. The sleep-deprived participants also had a rough time controlling their urges for high-carb, high-calorie snacks.

GET BETTER SLEEP

Want more control over your appetite? Depending on your age, you are supposed to get between seven and 10 hours of sleep each night.

Getting less to high blood pressure, a weakened immune system, weight gain, a lack of libido, mood swings, paranoia, depression and a higher risk of diabetes, stroke, cardiovascular disease, dementia and some cancers.

So sleep a full seven to 10 hours a night, stick to a regular bedtime and get up the same time very day, even on weekends, experts advise.

Adding exercise to your daily routine is a great way to improve your sleep and improve your health. After finishing , you'll have less anxiety, lower blood pressure, more sensitivity to insulin and you'll sleep better that night.

You can also train your brain to get more restful sleep with a few key steps:

  • During the day, try to get good exposure to natural light, as that will help regulate your circadian rhythm.
  • Avoid stimulants (coffee, tea) after 3 p.m. and fatty foods before bedtime.
  • Establish a bedtime routine you can follow each night. Taking a warm bath or shower, reading a book, listening to soothing music, meditating or doing light stretches are all good options.
  • Make sure your bed and pillows are comfortable and the room is cool: Between 60 and 67 degrees is best. Don't watch TV or work in your bedroom; you want your brain to think of the room as only for sleep.
  • Eliminate all lights -- even the blue light of cellphones or laptops can be disruptive. Dull sounds, too. Earplugs or white noise machines can be very helpful, but you can create your own with a humidifier or fan.