Connecting the Google IoT Core platform (GCP) explained step by step.

Please note that the Google IoT Core will no longer be available after August 16, 2023. Please visit our article for further information.

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. Generating project and registry
  2. Creating a MQTT plugin, as well as generating certificate and device
  3. Transfer data to the device
  4. Monitoring

Generating project and registry

  1. Login to the Google GCP Console: https://console.cloud.google.com/
  2. Click on “CREATE PROJECT”:
    Google Cloud Platform – Create Project

    Google Cloud Platform – Create Project

  3. Put in a name (1) and click on “CREATE” (2):
    Google Cloud Platform – Project Name

    Google Cloud Platform – Project Name

  4. Click on “Go to APIs overview”:
    Google Cloud Platform – API's overview

    Google Cloud Platform – API’s overview

  5. Click on “ENABLE APIS AND SERVICES”:
    Google Cloud Platform – enable APIS and services

    Google Cloud Platform – enable APIS and services

  6. Search for “IoT” (during this time the view changes):
    Google Cloud Platform – API-Library

    Google Cloud Platform – API-Library

  7. After changing the view and entering the search term completely (1), choose “Google Cloud IoT API” (2):
    Google Cloud Platform – Google Cloud IoT API

    Google Cloud Platform – Google Cloud IoT API

  8. Click on “ENABLE”:
    Google Cloud Platform – Google Cloud IoT API enable

    Google Cloud Platform – Google Cloud IoT API enable

  9. Open the menue:
    Google Cloud Platform – open menu

    Google Cloud Platform – open menu

  10. Scroll to the section “BIG DATA” and choose the menue entry “IoT Core”:
    Google Cloud Platform – IoT Core

    Google Cloud Platform – IoT Core

  11. Click on “CREATE REGISTRY”:
    Google Cloud Platform – create Registry

    Google Cloud Platform – create Registry

  12. Put in a registry ID (1), choose the region (2) and open the dropdown list of the topic (3):
    Google Cloud Platform – Registry-ID

    Google Cloud Platform – Registry-ID

  13. Click on “CREATE A TOPIC” in that opened dropdown list:
    Google Cloud Platform – Create a topic

    Google Cloud Platform – Create a topic

  14. Put in a topic ID (1), choose the encryption “Google-managed key” (2) and click on “CREATE TOPIC” (3):
    Google Cloud Platform – Topic ID

    Google Cloud Platform – Topic ID

  15. Show the advanced options:
    Google Cloud Platform – advanced options

    Google Cloud Platform – advanced options

  16. Activate the protocols “MQTT” and “HTTP” (1), disable the stackdriver logging (2) and maybe you have to scroll down:
    Google Cloud Platform – MQTT and HTTP

    Google Cloud Platform – MQTT and HTTP

    The CA certificate will be entered manually (1) and after that click on “CREATE” (2):

    Google Cloud Platform – CA Certificate

    Google Cloud Platform – CA Certificate

  17. Finally choose the menue entry “Devices” to create a device later:
    Google Cloud Platform – Devices

    Google Cloud Platform – Devices

Creating a MQTT plugin, as well as generating certificate and device

1. Do following steps in the OPC Router:

  • Click “Plugins” (1)
  • Click “MQTT” under “Cloud / IoT” (2)
  • Click on the Button to create a MQTT plugin (3)
    OPC Router – Creating MQTT Plug-in

    OPC Router – Creating MQTT Plug-in

2. Put in the following data on tab “Router configuration”:

  • Name (1)
  • Cloud profile (2)

The Cloud Profile makes it easier for you to enter the Google-specific connection data for the MQTT connection.

After that click on tab “Google IoT”:

OPC Router – Router configuration

OPC Router – Router configuration

3. Click on the Plus button to create a certificate:

OPC Router – Google IoT configuration

OPC Router – Google IoT configuration

4. Click on the Create button:

OPC Router – create a certificate

OPC Router – create a certificate

5. Click on the Eye button:

OPC Router – Eye Button

OPC Router – Eye Button

6. Click on the tab “Details”:

OPC Router – Details

OPC Router – Details

7. Click on the button “Copy to File…”:

OPC Router – Details

OPC Router – Details

8. Click on the next button:

Certificate Export Wizard – Click next

Certificate Export Wizard – Click next

9. The private key shouldn’t be exported (1) and then click on the Next button (2):

Private key shouldn't be exported

Private key shouldn’t be exported

10. Choose the file format (1) and click on the Next button (2):

Certificate Export Wizard – Format selection

Certificate Export Wizard – Format selection

11. Click on the button “Browse…”:

Certificate Export Wizard – File to Export

Certificate Export Wizard – File to Export

12. Put in a file name (1) and click on the Save button (2):

Certificate Export Wizard – Save as

Certificate Export Wizard – Save as

13. Click on the Next button:

Certificate Export Wizard – Click on Next

Certificate Export Wizard – Click on Next

14. Click on the Finish button:

Certificate Export Wizard – Finish

Certificate Export Wizard – Finish

15. Confirm by clicking the OK button:

Certificate Export Wizard – Export successful

Certificate Export Wizard – Export successful

16. Close the dialogue by clicking the OK button:

Certificate – Details

Certificate – Details

17. Click on “CREATE A DEVICE”:

Google Cloud Platform – Create a device

Google Cloud Platform – Create a device

18. Put in a device ID (1) and show the advanced options (2):

Google Cloud Platform – Device ID

Google Cloud Platform – Device ID

19. Allow the device communication (1), use the default settings of the registry for the “Stackdriver Logging” (2) and maybe you have to scroll down:

Google Cloud Platform – Stackdriver Logging

Google Cloud Platform – Stackdriver Logging

Choose the input method “Upload” (1), use the format “RS256_X509” (2) and click on “BROWSE” (3):

Google Cloud Platform – Authentication

Google Cloud Platform – Authentication

20. Choose the certificate (1) and click on the Open button (2):

Google Cloud Platform – Open Certificate

Google Cloud Platform – Open Certificate

21. Click on “CREATE”:

Google Cloud Platform – Create Authentication

Google Cloud Platform – Create Authentication

22. Open Google GCP Shell to view the transferred data later:

Google Cloud Platform – Open Shell

Google Cloud Platform – Open Shell

23. Put in the following data:

  • Project ID (1)
  • Registry ID (2)
  • Region (3)
  • Device ID (4)

After that check the connection (5) and click on the tab “Connection properties” (6):

OPC Router – Check connection

OPC Router – Check connection

24. The three tabs “Connection properties”, “First will”, “Last will” don’t need to be modified und you agree with the OK button:

OPC Router – Connection properties

OPC Router – Connection properties

OPC Router – First will

OPC Router – First will

OPC Router – Last will

OPC Router – Last will

25. Finally here is the finished MQTT entry:

OPC Router – Finished MQTT entry

OPC Router – Finished MQTT entry

Transfer data to the device

Here is an example for the transfer of temperature data:

Example for transfer of temperature data

Example for transfer of temperature data

Monitoring

As shown in step 22 of the section “Create MQTT plugin and create certificate and device”, open the Google GCP shell and use the following commands:

  1. Determine topic list: gcloud pubsub topics list
  2. Subscribe to watch topic: gcloud pubsub subscriptions create –topic
  3. Read last transferred data record: gcloud pubsub subscriptions pull –auto-ack
Monitoring

Monitoring

Connect Google IoT Core via Drag & Drop!

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