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.

OPC Router Connection - Google Cloud Platform GCP - IoT Core

Cloud IoT Core MQTT Connection

The connection takes place in the following steps, which we will explain in detail below.

  1. Cloud IoT registration and creating a registry
  2. Certificate creation and device configuration
  3. Configuration of the MQTT Client for data transfer

Registering the Cloud IoT Core and Creating a Registry

  1. 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:
    GCP IoT Core New Project

    GCP IoT Core New Project

  2. After creating the project, the activation of the IoT API is suggested. Please activate the API here:
    Google Cloud IoT API Activate

    Google Cloud IoT API Activate

    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):

    Google Cloud IoT API Search

    Google Cloud IoT API Search

  3. Next you have to switch to the IoT Core area:
    Google Cloud IoT Core

    Google Cloud IoT Core

  4. Here you create a registry (detailed settings see screenshot):
    GCP IoT Core Registry Create

    GCP IoT Core Registry Create

    Details:

    Google Cloud IoT Create Registry

    Google Cloud IoT Create Registry

    To close the dialog, you need to create a topic:

    Google Cloud IoT Create Topic

    Google Cloud IoT Create 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:

OPC Router Google MQTT Cloud Profile

OPC Router Google MQTT Cloud Profile

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.

OPC Router Google Create Certificate

OPC Router Google Create Certificate

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:

Certificate - general view

Certificate – general view

Certificate details

Certificate details

Certificate export wizard

Certificate export wizard

Certificate key export

Certificate key export

Certificate key format

Certificate key format

Certificate file name

Certificate file name

Finish certificate export

Finish certificate export

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:

Google IoT Core Registry

Google IoT Core Registry

Google IoT Core Create Device

Google IoT Core Create Device

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.

GCP MQTT Connection

GCP MQTT Connection

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):

OPC Router MQTT Transferobject

OPC Router MQTT Transferobject

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:

OPC Router Connection Google IoT

OPC Router Connection Google IoT

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.

Live view of the connection

OPC router connection to Google Cloud with temperature data in JSON document

Open the Google Cloud Shell:

Open Google Cloud Shell

List available topics via “gcloud pubsub topics list“:

Google Cloud Shell Topic List

Google Cloud Shell Topic List

Subscribe topic with “gcloud pubsub subscriptions create mySubscription –topic projects/opc-router-project/topics/ValueChanged“:

Google Cloud Shell Create Subscription

Google Cloud Shell Create Subscription

See incoming data with “gcloud pubsub subscriptions pull –auto-ack mySubscription“:

Google Cloud Shell IoT Datarequest

Google Cloud Shell IoT Datarequest

Connect Google IoT Core via Drag & Drop!

With the OPC Router you graphically connect your production systems with the Google Cloud Platform via MQTT.

Request your download and test the MQTT connection!