Clone sample application and install the prerequisite packages

Clone the sample application by running the following command: Copybashgit clone https//github.com/Azure-samples/iot-hub-node-raspberry-pi-clientapp

Install all packages by the following command. It includes Azure IoT device SDK, BME280 Sensor library and Wiring Pi library. Copybashcd iot-hub-node-raspberry-pi-clientapp npm install Note It might take several minutes to finish this installation process denpening on your network connection.

Configure the sample application

Open the config file by running the following commands: Copybashnano config.json

There are two items in this file you can configurate. The first one is interval , which defines the time interval between two messages that send to cloud. The second one simulatedData ,which is a Boolean value for whether to use simulated sensor data or not. If you don’t have the sensor, set the simulatedData value to true to make the sample application create and use simulated sensor data.

Save and exit by pressing Control-O > Enter > Control-X.

Run the sample application

Run the sample application by running the following command: Copybashsudo node index.js '<your Azure IoT hub device connection string>' Note Make sure you copy-paste the device connection string into the single quotes.

You should see the following output that shows the sensor data and the messages that are sent to your IoT hub.

Schematics of Data visualization in Power BI with BME280 + Raspberry Pi

Add a consumer group to your IoT hub

Consumer groups are used by applications to pull data from Azure IoT Hub. In this lesson, you create a consumer group to be used by a Stream Analytics job to read data from your IoT hub.