{"id":182840,"date":"2021-05-29T08:49:15","date_gmt":"2021-05-29T15:49:15","guid":{"rendered":"https:\/\/m2msupport.net\/m2msupport\/?page_id=182840"},"modified":"2021-05-30T07:39:05","modified_gmt":"2021-05-30T14:39:05","slug":"publish-through-mqtt-bridge-in-google-cloud-platform-gcp","status":"publish","type":"page","link":"https:\/\/m2msupport.net\/m2msupport\/publish-through-mqtt-bridge-in-google-cloud-platform-gcp\/","title":{"rendered":"Publish with gateway through MQTT bridge in Google Cloud Platform (GCP)"},"content":{"rendered":"<p>Devices send data to Google Cloud Platform by publishing to the\u00a0Message Queue Telemetry Transport (MQTT) bridge in the Google Cloud Platform.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/download-iot-cloud-tester\/\">IoT Cloud Tester<\/a>\u00a0 application provides an easy interface publish data to the Google Cloud Platform (GCP).<\/p>\n<h1>To publish with gateway to MQTT bridge in GCP,<\/h1>\n<ul>\n<li><a href=\"https:\/\/m2msupport.net\/m2msupport\/add-a-device-in-google-cloud-platform-gcp-using-iot-cloud-tester\/\">Add a device to the device registry<\/a> in GCP<\/li>\n<li>In the &#8216;Publish&#8217; tab, get the list of devices in the given region\/registry from GCP.<\/li>\n<li>Select the topic.<\/li>\n<li>Configure the MQTT server address and the port. Google&#8217;s MQTT server address is mqtt.googleapis.com and the port is 8883.<\/li>\n<li>Configure the Frequency &#8211; how often the device will publish the data and the Count &#8211; number of times the data will be published. Random data will be generated by the IoT Cloud Tester tool based on the data model associated with\u00a0 the device.<\/li>\n<li>Click the &#8216;Pub\/Sub Monitor&#8217; button to open the window to monitor the data published by the device.<\/li>\n<li>Click on the &#8216;Publish&#8217; button to start publishing data for the selected device(s). Note that the IoT Cloud Tester enables publishing by multiple devices at the same time.<\/li>\n<\/ul>\n<p>In this below example, device &#8216;dev_122814&#8217; is bound to the gateway &#8216;gw_227138&#8217;. So the gateway will actually establish\u00a0 the connection to the MQTT bridge and publish data on behalf of the device.<\/p>\n<p>The device is associated to the data model called &#8216;device-data&#8217; which has temperature and humidity as the data fields. The IoT Cloud Tester application will generate random data to publish based on the constraints defined for the fields in the model.<\/p>\n<p>The data will be published to &#8216;device_environment&#8217; topic on the GCP. So any subscribers to that topic will receive the data published by the device.<\/p>\n<p>The device will publish every 10 seconds (Frequency) for 5 times (Count).<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-182862\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1.png\" alt=\"\" width=\"844\" height=\"723\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1.png 844w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1-300x257.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1-768x658.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish-1-600x514.png 600w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/a><\/p>\n<p>The Pub\/Sub monitor will show the data published by the devices.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-182867\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor.png\" alt=\"\" width=\"836\" height=\"653\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor.png 836w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor-300x234.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor-768x600.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/pub_sub_monitor-600x469.png 600w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/a><\/p>\n<p>The console window will the GCP API calls and associated logs for the IoT Cloud Tester tool.<\/p>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-182870\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub.png\" alt=\"\" width=\"831\" height=\"652\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub.png 831w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub-300x235.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub-768x603.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/console_pub_sub-600x471.png 600w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/a><\/p>\n<p>To connect to Google MQTT server,<\/p>\n<ul>\n<li>MQTT Client Id should be set to the below format &#8211; projects\/projId\/locations\/cloudRegion\/registries\/regId\/devices\/deviceId<\/li>\n<li>\u00a0JSON Web Token (JWT) is generated using gateway&#8217;s private key and set as password for the MQTT connection. The user name for the MQTT connection is not used.<\/li>\n<li>\u00a0For connections through gateway, an attach message with no data to the topic \/devices\/deviceId\/attach is sent.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-183088\" src=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console.png\" alt=\"\" width=\"817\" height=\"587\" srcset=\"https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console.png 817w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console-300x216.png 300w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console-768x552.png 768w, https:\/\/m2msupport.net\/m2msupport\/wp-content\/uploads\/2021\/05\/device_gateway_publish_console-600x431.png 600w\" sizes=\"auto, (max-width: 817px) 100vw, 817px\" \/><\/a><\/p>\n<div class=\"video-responsive\"><iframe loading=\"lazy\" id=\"youTubePlayer\" src=\"https:\/\/www.youtube.com\/embed\/zsZIyACCkFk?hd=1\" width=\"750\" height=\"421\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Devices send data to Google Cloud Platform by publishing to the\u00a0Message Queue Telemetry Transport (MQTT) bridge in the Google Cloud Platform. IoT Cloud Tester\u00a0 application provides an easy interface publish data to the Google Cloud Platform (GCP). To publish with &hellip; <a href=\"https:\/\/m2msupport.net\/m2msupport\/publish-through-mqtt-bridge-in-google-cloud-platform-gcp\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"iot_tutorial_template.php","meta":{"footnotes":""},"class_list":["post-182840","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/182840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/comments?post=182840"}],"version-history":[{"count":13,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/182840\/revisions"}],"predecessor-version":[{"id":183094,"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/pages\/182840\/revisions\/183094"}],"wp:attachment":[{"href":"https:\/\/m2msupport.net\/m2msupport\/wp-json\/wp\/v2\/media?parent=182840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}