Connecting the Google IoT Core platform (GCP) explained step by step.
The Google Cloud Platform (GCP) is Google’s cloud solution that brings all of Google’s cloud computing services together. Google’s own services, such as Google Search and YouTube, run on the GCP, but end users can also book the cloud services.
For the Internet of Things (IoT) area, the platform offers the “Cloud IoT Core” services, which provide the functionalities to connect large quantities of devices. The connection is possible via an integrated MQTT broker. Here we show the necessary steps for the connection.
Cloud IoT Core MQTT Connection
The connection takes place in the following steps, which we will explain in detail below.
- Cloud IoT registration and creating a registry
- Certificate creation and device configuration
- Configuration of the MQTT Client for data transfer
Registering the Cloud IoT Core and Creating a Registry
- Register with the Google Cloud Platform to get free trial access. With this access you get also access to the GCP Console where you have to create a new project at first:
- After creating the project, the activation of the IoT API is suggested. Please activate the API here:
If the activation proposal does not appear automatically, you can also find the activation via the API search in the console (https://console.cloud.google.com/apis/library):
- Next you have to switch to the IoT Core area:
- Here you create a registry (detailed settings see screenshot):
To close the dialog, you need to create a topic:
Creating a Certificate and Creating a Device
1. The next step is to configure the MQTT connection. Here the connection data of the Google IoT device is stored and the certificate for the corresponding device is generated. By selecting the cloud profile “GoogleIoT” in the OPC Router MQTT plug-in configuration, the input dialog is aligned to the Google-specific MQTT configuration:
2. The data can now be entered in the “Cloudprofile” tab. First, a certificate must be created and exported in order to transfer it to the Google IoT Console when creating the actual device.
3. The created certificate can be accessed via the View button (eye) in the cloud profile and is then displayed in the Windows Certificate Viewer. From here it can be exported. Follow the wizard through the following steps to export the certificate:
4. The certificate can now be used to create a device. Select “Create device” in the registry and enter the device details as shown in the screenshot:
5. In the OPC Router Cloud profile all information can now be completed: Project ID, Registry ID, Region, Device ID and Certificate. After that the connection test can be executed. If the test is successful, the configuration to the Google Cloud is completed and the configuration of the data to be transferred can be started.
Configuration of the MQTT Client for data transfer to Google IoT Core
To transfer data in a connection in the OPC Router, a MQTT transfer object is created, linked to the established connection, and the topic is set up according to Google specifications (see Publishing Telemetry Events):
In the connection any data can be sent to the topic as payload. In the example, data from an SQL database is converted as JSON:
After publishing, the connection is active and data is sent to the Google IoT Core Cloud.
Example: Temperature transmission to the Google IoT Cloud with the OPC Router
In this example, data from a temperature acquisition system is loaded from an SQL database and sent as JSON formatted to the configured Google IoT device. With the GCP console, the received data is displayed again.