Industry 4.0: From the Internet of Things to Smart Factories