Shares of InvenSense (INVN) -- which makes motion sensors for smartphones, tablets, smartwatches, and other devices -- soared from from its IPO price of $7.50 in late 2011 to the mid $20s by Aug. 2014. But since then, the stock has tumbled back to around $8 due to slowing sales growth and its loss of the Apple (AAPL -0.57%) Watch to rival STMicroelectronics (STM -1.78%).

Source: InvenSense.

InvenSense's revenue rose just 4% annually last quarter, compared to 24% growth in the previous quarter and 74% growth a year earlier. Orders from Apple and Samsung still accounted for about 60% of its sales, indicating that peaking sales of premium mobile devices could hurt its top line growth. Non-GAAP net income fell 13.5%, indicating that lower-margin agreements with Apple or Samsung could weigh down its earnings growth.

InvenSense believes that its diversification into the Internet of Things (IoT), which connects everyday objects to the cloud, will get its growth back on track. Analysts also expect InvenSense's annual earnings to grow 18% over the next five years, which gives it an low 5-year PEG of 0.9. InvenSense's beaten down price and valuation make it a tempting buy, but investors might want to consider two slightly safer plays instead.

STMicroelectronics
Despite winning the Apple Watch, STMicroelectronics stock shed over 40% of its value over the past 12 months due to sluggish growth in the chipmaking sector and concerns about China. However, STMicro has a more diverse portfolio than InvenSense, and pays a hefty dividend.

STMicro's Sense, Power, and Automotive (SP&A) segment sells automotive and industrial semiconductors as well as mobile motion sensors. The Embedded Processing Solutions (EPS) EPS unit sells semiconductors for imaging, microcontrollers, memory, and other devices. To streamline its sales growth, the company recently restructured its business into three simpler units -- the Automotive & Discrete Group, Microcontrollers & Digital ICs Group, and the Analog & MEMS Group.

The Apple Watch uses STMicro's sensors. Source: Apple.

In 2015, SP&A sales, which accounted for 64% of its sales, fell 8% annually. EPS revenue fell 5%, while total sales slipped 7% to $6.9 billion. Those numbers look weak, but the company's exposure to the growing connected car market could get its growth back on track. Last year, about 70% of cars with ADAS (advanced driver assistance systems) used STMicro components. Rising demand for the Apple Watch, stronger sales of smart home devices, and a recovery in industrial demand could also boost long-term sales. That's why analysts expect STMicro's sales to fall 1.9% this year but rebound 3.8% in 2017.

STMicro's annual earnings are expected to improve 49% over the next five years, giving it a 5-year PEG ratio of 0.6. That's much lower than InvenSense's PEG ratio and indicates that the stock is undervalued based on its long-term earnings growth potential. Over the past 12 months, STMicroelectronics spent 129% of its free cash flow on dividends. That high payout ratio indicates that its forward yield of 7.1% could be trimmed if sales don't improve, but the company hasn't indicated that it will reduce that payout in the near future.

NXP Semiconductors
STMicro's larger rival NXP Semiconductors (NXPI -3.34%) has weathered a milder 23% decline over the past 12 months. NXP faced many of the same headwinds which knocked down STMicro, but it beefed up by acquiring rival chipmaker Freescale last year. By doing so, NXP became the world's largest manufacturer of automotive electronics.

Last year, NXP's automotive sales (including a month of Freescale's revenue) rose 17% annually and accounted for 22% of its top line. NXP expects that percentage to rise to 36% during the first quarter, and it could become a major growth engine as sales of connected cars rise. Sales of secure connected devices, secure interface and infrastructure, and high-performance mixed signal devices all posted double-digit sales growth in 2015, although secure identification solutions sales dipped 2%. Prior to closing its acquisition of Freescale, NXP had expected all those segments to post year-over-year declines. Looking ahead, the combined company's bigger size could enable it to utilize economies of scale to undercut smaller rivals like STMicro.

Source: NXP.

Analysts expect the "new" NXP to post 57% sales growth this year and 8% sales growth in 2017. Its annual earnings are expected to improve 25% annually over the next five years, giving it a low PEG ratio of 0.5 and making it fundamentally cheaper than InvenSense and STMicro. NXP doesn't pay a dividend, but it spent $474 million (nearly half its free cash flow) on buybacks in 2015.

Better bets, but still wobbly ones
I believe that STMicro and NXP are better buys than InvenSense, because both companies have more diversified portfolios, lower valuations, and more shareholder-friendly programs. However, both STMicro and NXP are still wobbly bets which could be hurt by sluggish demand for semiconductors and slowdowns in certain sectors. Therefore, investors should do their due diligence before investing in either company.