{"id":1340,"date":"2019-09-22T14:21:47","date_gmt":"2019-09-22T14:21:47","guid":{"rendered":"https:\/\/wordpress-634681-2064240.cloudwaysapps.com\/?p=1340"},"modified":"2020-05-02T22:00:19","modified_gmt":"2020-05-02T22:00:19","slug":"explorations-in-dot-net-core-3-0-for-raspberry-pi-part-3","status":"publish","type":"post","link":"https:\/\/www.petecodes.co.uk\/explorations-in-dot-net-core-3-0-for-raspberry-pi-part-3\/","title":{"rendered":"Explorations in Dot Net Core 3 for Raspberry Pi – Part 3 – Azure IoT Hub"},"content":{"rendered":"\n
This is part 3 of a (at least) 4 part blog series on Dot Net Core on the Raspberry Pi….<\/em> On September 25th 2019<\/a>, the Dot Net Team released version 3.0 of the Dot Net Core Framework at .Net Conf.<\/a><\/p>\n\n\n\n To join in the fun, I held a special with Notts IoT<\/a>, the IoT group I organise in Nottingham, where I gave a talk on Dot Net Core 3.0 on the Raspberry Pi.<\/a> <\/p>\n\n\n\n This blog post is what I’ve learnt along the way to preparing for the talk…! <\/p>\n\n\n\n In the last blog post<\/a> we’d already gotten a Blazor App setup. We then created a Console app that flashed an LED. Finally we read the status of a button and flashed an LED when it was pressed.<\/p>\n\n\n\n In this post we’ll connect our console app to an Azure IoT Hub and send a message to the hub. We’ll then monitor the Hub for messages and view them using the Microsoft IoT Device Explorer application. <\/p>\n\n\n\n If you’ve followed along with the previous blog, you’ll already have installed the Dot Net Core 3.0 binaries and runtimes, and have a console app running that flashes an LED when you press a button.<\/p>\n\n\n\n Our next step is to hook our Raspberry Pi up to an Azure IoT hub to add some internet goodness.<\/p>\n\n\n\n To do this, we’ll be adding a reference to a Nuget package that allows us to communicate with the Azure IoT Platform, and the IoT Hub in particular.<\/p>\n\n\n\n We’ll then modify our button press code to allow us to send the message.<\/p>\n\n\n\n Finally we’ll add a subroutine that will create our message and send it across to the IoT Hub.<\/p>\n\n\n\n The first thing we need to is add a reference to the Microsoft.Azure.Devices.Client Nuget Package<\/a> to our project.<\/p>\n\n\n\n As in the previous post we added the GPIO nuget package, we can add this by running;<\/p>\n\n\n\n
You can see Part 1 – Installation and Hello World – right here<\/a>… <\/em>
You can see Part 2 – GPIO – right here<\/a>… <\/em>
You can see <\/em>Part 4 – Receiving Azure IoT Hub Messages – right here…<\/em><\/a>
You can see Part 5 – Remote Deployment and Debugging – right here…<\/a><\/em> <\/p>\n\n\n\nPreviously on Pete Codes…<\/h2>\n\n\n\n
What you’ll need <\/h2>\n\n\n\n
Putting the “I” in IoT<\/h2>\n\n\n\n
The return of the Nug(g)et<\/h2>\n\n\n\n
dotnet add package Microsoft.Azure.Devices.Client<\/code><\/pre>\n\n\n\n