Send sensor data to Microsoft Power BI

In this tutorial we'll show you how to use your microcontroller to send data to Microsoft Power BI. This will enable you to do things like store and graph temperature readings (or anything else) over time.

This sketch uses our Microsoft > Power BI > CreateDataset Choreo as well as our Microsoft > Power BI > AddRow Choreo.

Get Set Up

1Make sure you have a Temboo account. If you don't already have one, you can register for a free account here.

2If this is the first time using Temboo, you'll need to set up your ARTIK board to find the Temboo libraries. To do so, you'll need to create the file temboo.conf in /etc/ld.so.conf.d. Inside of temboo.conf, you'll want to copy the line below and paste it into the file:


After saving temboo.conf, run ldconfig from the command line to add the Temboo library directory to the system library search path.

You’ll also need to get the IP address of your ARTIK board using ifconfig. The example below shows the results when the ARTIK board is connected to the internet through an ethernet cable. The IP address you'll want to use is listed next to inet.

[root@localhost ~]$ ifconfig
eth0: flags=4163  mtu 1500
        inet  netmask  broadcast

3Since this sketch uses Microsoft Power BI, you'll need a Power BI account and a Power BI application within which you'll generate and store your sensor data. Follow these instructions to get set up with Power BI.

4Once you've created your Power BI account and set up a Power BI app, make sure that you save your ClientID and ClientSecret - you'll need them to run through the OAuth process in the next step.

5Now, run through the Microsoft OAuth process using the details of your Power BI app. You can get started with the InitializeOAuth Choreo, but before you do we recommend watching this 2-minute screencast. It'll help make the OAuth process clear and save you time getting set up.

When you're filling in the inputs for the InitializeOAuth Choreo, make sure to specify the following value in the Resource input, which tells Microsoft that you want to access Power BI programmatically. You can also use this value when you're asked for a Resource value in the FinalizeOAuth Choreo.


Create Your Dataset

6After setting up your Power BI app and running through the OAuth flow, you're ready to create your dataset via the Microsoft > Power BI > CreateDataset Choreo.

7On the Choreo page, turn on IoT Mode and make sure that you've selected the microcontroller device that you're using.

8Enter the appropriate values into the required input fields based on the Power BI application that you set up previously. For the dataset specification, you can use the following JSON which gives a simple sensor readings table with two columns - temperature and humidity:

    "name": "SensorData",
    "tables": [
            "name": "SensorReadings",
            "columns": [
                    "name": "Temperature",
                    "dataType": "Int64"
                    "name": "Humidity",
                    "dataType": "Int64"

Here's a screenshot of what the populated Choreo form should look like:

Power BI Choreo inputs

9Now run the Choreo to create your dataset on Power BI. This will give us a place that we can start adding sensor values to, and you'll be able to see your new dataset on your Power BI dashboard.

Your Power BI dataset

Make sure to note response returned by Power BI in the Choreo's Response output. You'll need to supply the dataset ID as an input to the AddRow Choreo in the next section. Your response data will look something like this - it contains both the dataset ID and its name:


Generate Code to Send Sensor Data

10With the dataset in place, we can generate code that will send sensor data readings into the Power BI dataset, which we can then turn into a graph.

11Go to the Microsoft > Power BI > AddRow Choreo in our Library.

12Fill in the required inputs, using the dataset ID returned by Power BI when you ran the CreateDataset Choreo. Remember that we called our table SensorReadings, so make sure to use that name for the TableName input. For the Rows input, you can use the following JSON, which maps to the dataset schema that we set up earlier.

{"rows": [{"Temperature": 90, "Humidity": 92}]}

Adding data to Power BI

13Run the Choreo and you'll be adding a row of data to your dataset in Power BI. Head over to your Power BI dashboard and make sure that your data is appearing as expected.

Run The Sketch

14At this point, Temboo has auto-generated the code that you need to send sensor values to Power BI, so the next step is to grab the code and try it out. Scroll down to the CODE section then download the auto-generated C code.

15The auto-generated code references the TembooAccount.h header file, which contains your Temboo account information and network interface details. You'll find the code for this file beneath your generated sketch. Make sure that you keep this file alongside your main C code on your ARTIK device.

16Copy the downloaded zip file to your ARTIK board using scp. From your computer, go to the directory where the zip file is located and type the command below. Make sure you use the IP address for your board you found using ifconfig.

[root@localhost ~]$ sip [yourtemboozipfile].zip root@xxx.xxx.xxx.xxx:/home

17Now go to the directory containing the code and compile your code and start sending data to Power BI from your ARTIK. Run the first command below to compile your code, making sure to substitute in the name of the c file that you're compiling, and the name of the file your are outputting. After compiling has finished and no errors have been reported, run your program using the second command, subbing in the name of the file that you want to run. Your data will start uploading to Power BI from your ARTIK.

[root@localhost ~]$ gcc -L/opt/iothub/artik/temboo/temboo_artik_library/lib -ltemboo -I/opt/iothub/artik/temboo/temboo_artik_library/include -DUSE_SSL [yourtemboocode].c -o [filename]
[root@localhost ~]$ ./[filename]

Note: If you get an error about cdefs.h not being found, this could mean your ARTIK board was not shipped with glibc-headers. This can be solved by reinstalling glibc-headers using the command below. After reinstalling glibc-headers, run the two commands above to compile and run your code.

[root@localhost ~]$ yum reinstall glibc-headers

Extending The Sketch

You'll notice that your sketch always sends the same value to Power BI. Of course, it's far more interesting to send dynamic values i.e., sensor values.

18We outline how to extend any Temboo sketch so that it's sending dynamic sensor data in the "Extending the sketch" section of our Google Spreadsheets tutorial, so take a look at that one to see how you can extend your sketch to send real sensor values to Power BI. Take care when substituting dynamic variables into the JSON string that you're sending to Power BI.

19Once you've extended your sketch, you can run it again and you'll be sending live sensor values to Power BI from your ARTIK.

20Finally, log into your Power BI dashboard and turn your dataset into whatever type of graph works for you. Here's one that we created from our sensor data from this example.

Power BI sensor data graph

What's Next?

Now that you've mastered working with Power BI, why not check out the rest of the 2000+ Choreos in our Library and get inspired for your next project.

Need Help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.