#Azure – Sending custom Telemetry and Event information from a #RaspberryPi device to #AzureIoT Central


Azure IoT Central is one of the amazing services we can use on Azure. I was wondering how easy is to use a Raspberry Pi using Raspbian and Azure IoT and here is my experience.

Let’s assume we had a device up to date using Raspbian, our next step will be to create an Azure IoT Central application. The official step by step is the main resource for this

Create an
Azure IoT Central application (see references)

Once we have our application, we can quickly create a new Raspberry Pi device and use it. However, I’ll do an extra step, lessons learned as a handsome developer

Create a Device Template

Go to [Device Templates] and create a new template

azure iot central create new device template

For Raspberry Pi, I’ll name this [Raspberry Pi Dev]

azure iot central create new device template raspberry pi dev

So now, I can add a new real device, in the Devices section from the left menu

azure iot central raspberry pi dev add new real device

Once you create a new real device, is important to copy and save for later the connection information. To access this, go to the top right [Connect] button

azure iot central raspberry pi dev real device connect information

Almost there, there is an official tutorial that explain how to send random telemetry information with a Python script in a Raspberry Pi. I’ll use it as base for this scenario.

Connect a
Raspberry Pi to your Azure IoT Central application (Python) (see references)

For this demo, I’ll add a custom telemetry property and a custom event to the device. Since I won’t use the device to track temperature, accelerometer, and more, I think it make sense to track some custom information.

So, I’ll go back to my Device Template definition and I’ll add a new Telemetry, named [t1], with the following information.

azure iot central raspberry pi dev new telemetry information

And now, I can run a custom version of my script that will send new telemetry information, for [t1]. Sample in line 18

After a couple of minutes running the sample script, I can see the telemetry information for T1. In this view, I enabled [Temperature] and [T1] to display the timeline.

azure iot central raspberry pi dev real device dashboard telemetry

And, next step will be to add an event, which is also a very important uses case in Azure IoT. Back in the Device Template, I add a new event named [event1]

azure iot central raspberry pi dev new event information

And added some extra lines of code to send also an event between telemetry, Line 22

In the following image, we can see how the events appears in the timeline, and we can also get some extra details clicking on each event.

azure iot central raspberry pi dev real device dashboard telemetry and events

Very cool! Next steps will be to integrate this with some image recognition scenarios.

Happy Coding!

Greetings @ Burlington

El Bruno


#VSCode- Add #AzureIoT source files to your C++ settings in #VisualStudioCode


Context: You may call me picky, but I like to read source code. And if I know that I have the source code, but I can reach it, I can’t code in happy mode.

So, I’m back to Azure IoT and while I was browsing the Project Catalog for my DevKit device. I hold myself in the [Get Started – Connect IoT DevKit AZ3166 to Azure IoT Hub] section thanks to this warning.

visual studio code mxchip get started cant find include errors

Don’t get me wrong, once you installed Visual Studio Code, Arduino and the complete set of dependencies; you can build and deploy everything. However, I need my peek definition and the following error is a stopper for me

visual studio code include file not found in browse.path
Error: Visual studio code include file not found in browse.path 

The main problem is that the C++ extension can’t found any of the Azure IoT files. So, we need to add the path to VSCode settings. Lucky for us, the tip bulb will directly guide us to this option

visual studio code edit browse path setting

We only need to add this path to the C++ settings. Of course, check your Arduino version and your username

C:\Users\{user name}\AppData\Local\Arduino15\packages\AZ3166\**

And that’s it! Peek definition and more is available now

visual studio code c++ peek definition

Happy coding!

Greetings @ Burlington

El Bruno