Live streaming Weather station with Cortana Analytics – Part 2

Posted by on Feb 28, 2017 in Analytics, Cortana Analytics, IOT | One Comment
Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail

In previous post (http://radacad.com/create-a-live-stream-weather-station-with-cortana-analytics-part-1), I have explained what is Cortana, What is IoT and how to set up the Raspberry pi3. In this post, I will explain the process of connecting weather station sensor to Raspberry Pi. Also, how to send data to the Event Hub and set it up.

Get Weather Data

For connecting Raspberry PI to weather station sensor, we should write some codes. Two types of code are needed. First a code that read data from sensor and, the second one that send data to cloud.

image25

There is an article that shows the process of connecting weather station to Raspberry PI (https://www.hackster.io/windowsiot/build-hands-on-lab-iot-weather-station-using-windows-10-5b818f). This article provides 4 main .Net projects:
1- Sparkfun weather shield: a Universal windows project for collecting information from Weather sensor

 

image26

also for collecting the “barometric pressure” information we use mpl3115a2 project and also for measuring humidity htu21d project has been used.

First of all, we should specify the name of Raspberry PI in code. Hence, find the file with name “MainPage.xaml.cs” then in uri put the iot device name.

image28

In  windows universal projects, the code will be run in specific device, that in this scenario is “Raspberry Pi”. hence we have to specify the device name, that we want to run code on it. In page build2015-weather-station we should find the remote machine first.image30

there is an important note that raspberry pi and pc that we run should be in a same internet network.

image31

by running the code, in monitor you will see the below picture, that shows weather station is receiving information about weather such as humidity, temperature and pressure.

image32

In this stage,  Raspberry Pi and weather station sensor have been connected. Now, we should sent the collected data to Cloud (Cortana), but before that, we it should be set it up.

image33

Event Hub

Event hub is a managed event ingestor that able to collect million of events per second from different devices. Event hub is  part of service bus in Cortana. It receives information from Raspberry PI in JASON Format. To create event hub, I login in old Cortana portal: “Manage.windowsazure”. Tto create new event hub we should create “New” component.

image34

By clicking on New bottom, new page will be show up, we should create “APP Service” and then “Service Bus”. following, in service bus, “Event Hub” should be chosen.

image35

This should be accompany with specifying the Event Hub name and Region, which in my case is “Southeast Asia”.

image36

now we can see the process of creating Event hub and related service bus in Cortana (see below picture).

image37

image38

After creating Event Hub, we able to see Event hub configuration by clicking on the configuration component (below picture). By clicking on the name of Service bus, we able to see the configuration in event hub.

 

image39

In event hub we can see some information about the “Policy Name” and “Primary Key” that can be used for creating connection between Universal Windows code that we have and Cortana analytics.

image40

now we should put the policy code and primary key in our .Net code as below

image29

By running the code, first the project will be deployed in Raspberry PI and the information from weather sensor will be send to Event Hub. Below picture shows the sending message in output.

image41

Now by clicking on the “iotLeila” service bus in Cortana analytics (see below picture), we can see the Related Event Hub.

image42

 

Then, we can see iot event hub in below picture.image43

We can see all the messages that have been sent to Event Hub in last 24 Hours. This includes all sending message, errors and successful messages.

image44

Till now, we find out how to send data from weather station to Raspberry PI and  then to Event Hub. In the next, post I will show how to sent information to Power BI and Azure ML via stream Analytics.

image45

[1]https://www.hackster.io/windowsiot/build-hands-on-lab-iot-weather-station-using-windows-10-5b818f

[2]http://blogs.perficient.com/microsoft/2015/10/data-and-event-ingest-with-cortana-analytics/

Save

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmailFacebooktwittergoogle_plusredditpinterestlinkedintumblrmail
rssyoutuberssyoutube
Leila Etaati
Dr. Leila Etaati is Principal Data Scientist, BI Consultant, and Speaker. She has over 10 years’ experience working with databases and software systems. She was involved in many large-scale projects for big sized companies. Leila has PhD of Information System department, University of Auckland, MS and BS in computer science. Leila is Microsoft Data Platform MVP.

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">