|Software apps and online services:|
Thanks to the tutorials on Docs.microsoft.com – https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-node-get-started#create-an-iot-hub
Prepare your Azure accounts
You might need follow the steps to create an Azure IoT hub
and a Power BI account. (Try Power BI for free)
Connect the sensor to Pi
Connect the sensor to Pi
Use the breadboard and jumper wires to connect an LED and a BME280 to Pi as follows. If you don’t have the sensor, skip this section.
For sensor pins, use the following wiring:
Start (Sensor & LED) | End (Board) | Cable ColorVDD
(Pin 5G)3.3V | PWR (Pin 1) | White cable
GND (Pin 7G) | GND (Pin 6) | Brown cable
SCK (Pin 8G) | I2C1 SDA (Pin 3) |Orange cable
SDI (Pin 10G) | I2C1 SCL (Pin 5) |Red cable
LED VDD (Pin 18F) | GPIO 24 (Pin 18) |White cable
LED GND (Pin 17F) |GND (Pin 20) |Black cable
Click to view Raspberry Pi 2 & 3 Pin mappings for your reference.
After you’ve successfully connected BME280 to your Raspberry Pi, it should be like below image.
Turn on Pi by using the micro USB cable and the power supply. Use the Ethernet cable to connect Pi to your wired network or follow the instructions from the Raspberry Pi Foundation to connect Pi to your wireless network.
Run a sample application on Pi
Clone sample application and install the prerequisite packages
- Use one of the following SSH clients from your host computer to connect to Intel NUC.
- PuTTY for Windows.
- The built-in SSH client on Ubuntu or macOS.
- Clone the sample application by running the following command: Copybash
git 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. Copybash
cd iot-hub-node-raspberry-pi-clientapp npm installNote 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: Copybash
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: Copybash
sudo 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.
To add a consumer group to your IoT hub, follow these steps:
- In the Azure portal, open your IoT hub.
- Click Endpoints on the left pane, select Events on the middle pane, enter a name under Consumer groups on the right pane, and then click Save.