Brewing Beer With Raspberry Pi: Visualizing Sensor Data
Using Microsoft's Power BI software, learn to visualize the data collected from the sensors when brewing beer with your Raspberry Pi.
Join the DZone community and get the full member experience.Join For Free
we are eager to try out our beer cooling solution and we want to see it in action. we want to visualize our data and keep eye on the temperature of the cooling beer. before doing anything more complex like building a web or mobile app, we'll take a quick shortcut and bring our data to web, desktop, and mobile. this post is about power bi in action.
what is power bi?
power bi is online data visualization platform by microsoft. it works on desktop, tablets, and mobile devices.
microsoft: microsoft power bi transforms your company’s data into rich visuals for you to collect and organize so you can focus on what matters to you. stay in the know, spot trends as they happen, and push your business further.
with power pi we can get temperatures on desktop and mobile with one app. to get started, you have to create a power pi account . it’s free until you have small demands like what we have here.
getting data to power bi
in previous beer iot post using stream analytics to save data from iot hub to sql database we created stream analytics job to move sensors data from azure iot hub to sql azure database. our sql azure database was just one output source for stream analytics job. same way we may add other types of output sources and among supported types we find also power bi.
nb! adding and configuring power bi output source is currently possible only in azure management portal. new portal doesn’t support it yet.
now let’s make stream analytics job to pump data to power bi. go through the following steps to make it happen.
- open old management portal and move to open stream analytics job we created in previous post.
- click on “outputs” menu and then on “add output” button.
- select “power bi” and click arrow to move to next page.
- under “existing microsoft power bi” section click on “auhtorize now” link.
- log in to power bi.
- fill required fields:output alias – name of output source, dataset name — name of power bi dataset (for example: beer iot), table name — measurement, workspace — leave it like it is.
- click on the check button to save data.
next, we have to modify our query and make it insert data to the power bi output source. here is the query:
select batchkey as batchkey, max(cast([timestamp] as datetime)) as time, avg(beertemp) as beertemp, avg(ambienttemp) as ambienttemp into [sqlazurebeeriot] from [fromiothub] group by batchkey, tumblingwindow(minute, 5) select batchkey as batchkey, max(cast([timestamp] as datetime)) as time, avg(beertemp) as beertemp, avg(ambienttemp) as ambienttemp into [powerbi] from [fromiothub] group by batchkey, tumblingwindow(minute, 5)
duplicating is not a nice or polite solution, but i couldn't find a better way to accomplish our goal right now.
if you run stream analytics and the beer cooling solution, then after five minutes you should see a new dataset appearing in the power bi interface.
nb! it’s easier to build reports and dashboards in power bi if you have some data already waiting there. to get data, run a stream analytics job and the beer cooling solution, and let the solution report measurements for around 20-30 minutes.
building the beer cooling report
now let’s build the beer cooling report. log in to power bi through your browser and under the datasets section on left, select beeriot (this must be the name you gave to the dataset when you added a new output source to the stream analytics job).
select line chart under visualizations, drag it wider, and configure it like shown on the screenshot below.
click on somewhere in the empty space near the chart to get it out of focus and click on "table" under visualizations. configure the table like shown in the following screenshot:
now save your report and name it “beer cooling”, for example. under the reports menu on the left, select the report you just created. click on the pin button on the line chart and add it to the beer iot dashboard.
if you click on "dashboard" you will see the beer cooling chart there. when the beer cooling solution is running, then the chart will be updated in real-time. i also added the measurings table to the dashboard, and changed their sizes to make the dashboard look better.
power bi on your desktop
on windows 10, open store from the taskbar and search for power bi. install the power bi application to your machine and run it. log in if needed and open your beer iot dashboard.
you can click on the chart and table to see them enlarged. also, you can open your beer iot report and see it on your desktop. in report view, you can also use filters if you defined some.
now take your windows phone 10, open store, and search for power bi. install the power bi app to your phone and run it. log in to power bi when asked and open the beer iot dashboard you created before.
we see almost same thing also on the power bi mobile app. if you'd like, you can pin this dashboard to the home screen of your windows phone.
this was the first time we visualized our measurements data. we added a new output source to the stream analytics job to send aggregated measurement data to power bi. on power bi, we created a beer cooling report and dashboard. after this, we can monitor beer cooling through the web browser and through power bi desktop and mobile apps. we wanted to get our data visualized and we did so with minimal time and effort.
brewing beer with a raspberry pi: table of contents
- brewing beer with a raspberry pi: measuring temperature
- brewing beer with a raspberry pi: moving to itemperatureclient interface
- brewing beer with a raspberry pi: measuring cooling rate
- brewing beer with a raspberry pi: making cooling rate calculations testable
- brewing beer with a raspberry pi: reporting measurements to azure iot hub
- brewing beer with raspberry pi: stream analytics
- brewing beer with raspberry pi: visualizing sensor data
- brewing beer with raspberry pi: building a universal windows application
Published at DZone with permission of Gunnar Peipman, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.