The Internet of Things (IoT) -- which includes connected cameras, wearables, smart home appliances, drones, cars, and other gadgets -- is expected to be a massive growth industry over the next few years. Research firm IDC expects global IoT spending to rise from $800 million this year to nearly $1.4 trillion by 2021.

That bullishness convinced many tech companies to invest heavily in IoT-related technologies. Two top chipmaking plays in that sector include Sierra Wireless (SWIR) and Cypress Semiconductor (CY), which respectively rallied 31% and 34% this year.

A visual depiction of the Internet of Things.

Image source: Getty Images.

Investors might be reluctant to buy either stock at these levels, but one of these chipmakers is still a better long-term investment than the other.

What do Sierra and Cypress do?

Sierra sells 2G, 3G, and 4G embedded modules and gateways for M2M (machine-to-machine) communications. It controls about a third of the worldwide market for M2M embedded modules according to ABI Research.

Sierra often expands via acquisitions of smaller wireless hardware makers, including AnyData, Maingate, Mobiquithings, GenX Mobile, Numerex, and GlobalTop Technology's GNSS (global navigation satellite system) unit.

Cypress sells embedded analog and memory chips for the industrial, automotive, enterprise, and consumer markets. It provides three categories of chips -- MCU (microcontroller units), specialty memory chips, and connectivity chips.

Cypress' memory business mainly comes from its acquisition of Spansion in 2015. The bulk of its connectivity business -- which sells IoT chipsets -- came from its purchase of Broadcom's (AVGO 1.04%) wireless IoT business last year.

How fast are Sierra and Cypress growing?

Sierra's revenue rose just 1.3% to $615.6 million last year due to slower OEM orders amid a tougher macroeconomic environment. On the bottom line, Sierra reported net earnings of $15.4 million, or $0.48 per share, compared to a net loss of $2.7 million in 2015.

That growth seems anemic, but Sierra sprung to life again over the past year with four straight quarters of double-digit annual sales growth. That rebound was attributed to accelerating OEM orders, the growth of its Enterprise Solutions and Cloud businesses, and the accretive benefits of its recent acquisitions.

Analysts expect Sierra's revenue and earnings to respectively grow 11% and 50% this year. For fiscal 2018, analysts expect 17% sales growth and 8% earnings growth.

A depiction of the Industrial Internet of Things.

Image source: Getty Images.

Cypress' non-GAAP revenue rose 19% to $1.94 billion last year, as its non-GAAP net income rose 142% to $170.5 million, or $0.49 per share. However, much of that gain was attributed to its purchase of Broadcom's IoT business, and Cypress was actually unprofitable on a GAAP basis.

Analysts expect the Broadcom deal, along with rising demand for its automotive and industrial IoT chips, to respectively boost its revenue and earnings by 20% and 75% this year. For fiscal 2018, analysts expect 7% sales growth and 37% earnings growth.

Comparing gross margins

Sierra and Cypress' gross margins have headed in opposite directions throughout most of the year.

SWIR Gross Profit Margin (Quarterly) Chart

Source: YCharts

This was mainly due to some automotive customers transitioning from an older, higher-margin platform toward a newer, lower-margin one over the past few quarters.

Cypress, however, has been expanding its margins by boosting its utilization of Fab 25, a lower-cost plant which it acquired from its merger with Spansion. Cypress also divested its Minnesota Fab to cut costs, pivoted its portfolio toward higher-margin products, and focused on the "higher density and more predictable" segments of the NOR and NAND flash memory markets.

The dividends and valuations

Sierra doesn't pay a dividend. Cypress pays a forward dividend yield of 2.9%, but it hasn't raised that payout since 2012. It spent 61% of its free cash flow on that dividend over the past 12 months.

Both stocks are fairly cheap relative to their earnings growth. Sierra trades at 19 times forward earnings, while Cypress has a forward P/E of 13.

The winner: Cypress Semiconductor

Sierra is still a solid IoT play, but Cypress' better diversified business, higher growth rates, expanding margins, lower valuation, and dividend all make it a better buy at current prices.

However, investors should still be mindful of potential competition from bigger rivals like Texas Instruments, which focuses on many of the same end markets as Cypress Semiconductor, or potential slowdowns in the high-growth automotive and industrial markets.