James Park, chief executive officer of Fitbit Inc. Michael Nagle | Bloomberg | Getty Images

has built its business around tracking users' steps and heart rate. But with the company's stock price down 62 percent in the past year and Apple threatening its market leadership, Fitbit's future might be predicated on its success in the medical sector. Fitbit is building tools to help diagnose and monitor sleep apnea, a disorder that affects some 18 million American adults, the company told CNBC. Sleep apnea is characterized by pauses in breathing and shallow breath and comes with an increased risk of heart failure, obesity and strokes. One of the biggest concerns is that a lot of people don't realize they have it. "We'd perform a useful public service by alerting users to the fact that they have a problem," said Conor Heneghan, Fitbit's lead research scientist, in an interview. Heneghan works on Fitbit's research and development team, which is focused on testing out new biomedical sensors and exploring potential applications. Sleep apnea is also a big potential market, with revenue expected to increase to $6.7 billion by 2021 from $4.6 billion last year, according to Research and Markets.

Fitbit, which makes products such as the Flex 2 fitness tracker and Blaze smartwatch, is looking for new ways to keep pace with chief rival in the competitive wearables market. Apple Watch overtook Fitbit in the first quarter of 2017, according to a report from the market research firm Strategy Analytics. Fitbit's shipments sank 35 percent in the first quarter from the prior year to 2.9 million devices. Helping diagnose and treat sleep apnea is a major target for tech companies, ranging from small start-ups to bigger companies like Fitbit, because it can be detected with existing sensors. Fitbit plans to track heart rate and fluctuations in oxygen levels. More specifically, Heneghan's team is looking into using optical technologies that shine a light into the skin. Blood that is highly oxygenated is red, but gets bluer with less oxygen. The technology tracks dips in oxygen levels during the night, a possible indicator of sleep apnea. "We're leveraging the fact that Fitbit has experience in optical electronics, and making them small and power efficient," said Heneghan. Fitbit isn't the only wearables company exploring applications beyond health and fitness. Apple is working on an effort to non-invasively track blood glucose, CNBC reported in April. And Jawbone, maker of the UP bands, is now shifting from consumer trackers to clinical health products. For millions of people with chronic illnesses, whether it's diabetes, heart disease or sleep apnea, these devices become dramatically more useful if they can collect and interpret medical information. The major challenge is getting clearance from the U.S. Food and Drug Administration, which requires both time and resources.