Skip to Content
Hands-On Industrial Internet of Things
book

Hands-On Industrial Internet of Things

by Giacomo Veneri, Antonio Capasso
November 2018
Intermediate to advanced
556 pages
14h 42m
English
Packt Publishing
Content preview from Hands-On Industrial Internet of Things

Sending data through MQTT

Let's get the MQTT client from the official GCP GitHub repository. In this simple example, we are going to use Node.js:

  1. First, we need to clone the Node.js client from the official repository. From the root path where we have stored our certificate, enter the following command:
$ mkdir my-iiot-device$ cd my-iiot-device$ git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples$ cd nodejs-docs-samples/iot/mqtt_example/$ npm install
  1. We can then start publishing. The following code sends an MQTTS payload to the IoT core that was just configured on europe-west1, identifying itself as my-iiot-device:
$ node cloudiot_mqtt_example_nodejs.js \    --projectId=iiot-book \    --cloudRegion=europe-west1 \ --registryId=iiot-book-registry ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Internet of Things

Internet of Things

S. Velliangiri, Sathish A.P. Kumar, P. Karthikeyan
Industrial Internet Application Development

Industrial Internet Application Development

Alena Traukina, Jayant Thomas, Prashant Tyagi, Veera Kishore Reddipalli

Publisher Resources

ISBN: 9781789537222Supplemental Content