Introduction to IoT and Google Cloud Platform
IoT (Internet of Things) means to connect things or specific devices to the internet with the help of network devices or routers and access them from a remote location and let them Communicate with each other and exchange the data. This technique also has an autonomous feature, with the help of which any device any be controlled without any human interaction.Google Cloud Platform or simple GCP, is a suite of cloud computing services provided by Google and runs on the same platform that Google uses internally for its end-user products like YouTube and Google search. Some of the GCP services offered by Google are –
- Google BigQuery Service
- Google Cloud DataFlow
- Google App Engine
- Google Cloud DataLab
- Google Cloud SQL
One of the critical services provided by Google in the field of IoT is the Google Cloud IoT Core. Google Cloud IoT Core is a fully managed service which allows us to securely and easily connect, manage and ingest the data from the internet connected devices. Apart from this, it also allows other Google Cloud Platform services to collect, process, manage and visualize the IoT data in real time.
Google Cloud IoT Core
Cloud IoT Core is one of the services provided by Google in the field of Internet of Things. It is helpful when we have connected thousands of devices to the internet, and at that time we need a highly scalable and manageable service, which is cloud IoT core. One of the best features of cloud IoT core is that it automatically takes care of load balancing and scaling of the data.
The two main components of Cloud IoT Core are as follows –
Device Manager – It helps in registering the devices with the services and also provides the mechanism for authenticating the device. It also maintains a logical configuration for each device and can also be used for controlling the device remotely from the cloud.
Protocol Bridge – It is a way for the device to access or to connect to the Google cloud with the help of some of the standard protocols like HTTP and MQTT. With the help of this, we can use out existing devices with minimum firmware changes.
Getting Started with Google Cloud Platform and Cloud IoT Core
Before starting with the Google Cloud Platform console for Cloud IoT Core following are the requirements and the environment to setup –
- Install and initialize cloud SDK, and cloud IoT core requires version 173.0.0 or higher.
- Setup Node.js development environment.
Creating a Device Registry
- Go to google cloud IoT core page in the GCP console.
- Click on Create a registry option.
- Enter the registry id and select the cloud region.
- In the protocol section MQTT protocol.
- Create a telemetry topic from the drop down list and then click on create a topic option.
- Some fields like Device state topic and Certificate value fields are optional so that we can leave them as blank.
- After that click on Create Cloud IoT Core page.
Add a Device to Registry
- On the registry device page, click on the add device option and enter the device id.
- Select allow for the Device Communication and the information for the public key.
- The device metadata field is an option, so we can leave it blank.
- After that click on add button to add a device.
Running a Node.js Sample to Connect to a Virtual Device
- Get the Cloud IoT Core Node.js samples and store in the directory.
- Copy the private key to the current directory.
- Install node.js dependencies by command npm install.
- Create the subscription to the registry’s pub/subtopic.
- Now connect a virtual device to cloud IoT core with the help of MQTT bridge.
Google Cloud Platform IoT Services
The best part of using Google Cloud Platform is that it provides unique offerings for Big Data and Artificial Intelligence and IoT services. Also while building a project, scalability is the major part of the concern, so due to its serverless architecture, GCP met the requirements of the project.
Some of the components for IoT solution with Google Cloud Platform are as follows –
BigQuery – It is a cloud-based IaaS model designed by Google which is used for storing and processing enormous datasets with the help of several SQL queries. It can be said that BigQuery is a type of database which is different from the transactional databases like MySQL and MongoDB.
Cloud IoT Core – It is a completely managed service which allows us to securely and easily connect, manage and ingest the data from the devices connected to the internet. Apart from this, it also allows other Google Cloud Platform services to collect, process, manage and visualize the IoT data in real time.
Pub/Sub – It is a type of asynchronous service to service communication which is used in the serverless and microservices kind of architecture. In this type of model, any service which is published to a topic is immediately be received by all the subscribers of that particular topic. It can be used to enable any event-driven architecture.
Hardware – Google offers a version of Android for IoT devices which is known as Android Things. Android Things helps the developers to configure and push the software updates to the operating system.
Cloud Functions – For routing the data after entering into the Pub/Sub, cloud functions are used. A cloud function is nothing but a java script code which been triggered when an event takes place. And the code will run without any need of infrastructure management because its all taken care by Google itself.
A Centralized Approach
Fully Managed services for connecting, processing and analyzing IoT data .For making strategic decisions based on edge/on-premises computing we advise taking the following steps –