Reading the data from the IoT Thing

To read the data from the device, you can either use the same Raspberry Pi 3 or another computer. I am going to use my MacBook as a client that is interested in the data sent by the device:

  1. Create a folder named test_client. Inside the test_client folder, run the following command:
$ npm init --yes  
  1. Next, install the azure-event-hubs module (https://www.npmjs.com/package/azure-event-hubs) using the following command:
$ npm install azure-event-hubs --save  
  1. Create a file named index.js inside the test_client folder and update it as detailed in the following code snippet:
var EventHubClient = require('azure-event-hubs').Client;var connectionString = 'HostName=Pi3-DHT11-Nodes.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=J0MTJVy+RFkSaaenfegGMJY3XWKIpZp2HO4eTwmUNoU='; ...

Get Enterprise Internet of Things Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.