Azure IoT Hub / Raspberry Pi IoT Project – Connecting Pi, Azure and Power BI.

With the Pi successfully reading temperature and pressure from the sensor, and connecting successfully to Azure it left one more step in my project – outputting the data in a meaningful way.  For this part of my project I’m looking to collect the data Azure is receiving and put it into a line graph which should easily show any increases or decreases in temperature.

I started off at the Azure Portal ( https://portal.azure.com/ ), expanded the IoT menu and clicked IoT Hub.

geektechstuff_IoT_menu
Azure Internet of Things menu

Built in Endpoints

From the IoT Hub menu the option needed is “Built in Endpoints”.

geektechstuff_IoT_hub_menu
Azure IoT menu – Built in Endpoints

Most the the settings for the endpoint can remain as the default, however I created a new consumer group for temperature reading. With the endpoint configured it is time to create a stream analytics job.

Stream Analytics Job

From the Internet of Things menu choose Stream Analytics Job, and add a new job.

Azure Stream Analytics
Azure Stream Analytics
  • Job Name – Enter a unique name for the job.
  • Subscription – If, like me, you are using the free resources then choose “Free Trial”. If not, choose an appropriate subscription.
  • Resource Group – choose the IoT hub created earlier in this project.
  • Location – Make sure this matches where your IoT hub is located (so “UK West” for me).
geektechstuff_azure_analytics_new
New Stream Analytics Job

Once the stream analytics job is created, which may take a few minutes, open it and choose “inputs” from “Job Topology” on the left.

geektechstuff_azure_stream_inputs
Azure Stream Analytics – Job Topology

Give the input alias a name, select the appropriate IoT Hub and make sure Endpoint is set to messaging.

geektechstuff_analytics_input
Azure Input Details

After the input is set up an output is needed. This is where Power BI comes into play. For this step an business or school account is needed.

Stream Analytics Output
Stream Analytics Output
  • Output alias – has to be a unique name
  • Group workspace – for testing I would leave as “My Workspace”
  • Dataset Name – a name for the data as it pulls through to Power BI
  • Table Name – a name for the table as it pulls through to Power BI

With an input and output created the project also needs a query so that Azure knows what data to send to Power BI. Under “Job Topology” click Query and change the “YourInputAlias” and “YourOutputAlias” to match aliases created above.

geektechstuff_azure_query
Azure Stream Analytics Query

For me this was a simple * (for everything) into my output Power BI (GeekTechStuff) from my input temperature. Then from the “Overview” option on the left press the “Start” button to start streaming,

geektechstuff_azure_start_stream
Starting the Azure Stream Analytics Job

With the stream running I opened Power BI, clicked “My Workspace” on the left and chose the dataset for GeekTechStuff_Temperature. Then from the right I selected line graph and dragged the appropriate fields to get my line graph to populate – it’s flat as temperature has not increase/decreased whilst running.

Power BI streaming temperature readings
Power BI streaming temperature readings

 

 

 

One thought on “Azure IoT Hub / Raspberry Pi IoT Project – Connecting Pi, Azure and Power BI.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.