Skip to content

Sweekriti91/IoTButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoTButton

This repo is the sample code presented as part of the Reactor Twitch Stream on the Microsoft Developer Twitch account. This creates a smart IoT Button, which when pressed lights up an LED locally and sends a Twitter message via Azure IoT Hub and Azure Logic Apps.

Coming soon

Direct link to the Twitch Stream here!

YouTube link coming soon!

Bookmark, Subscribe the Reactor YouTube channel to get the notification for this video and other amazing content!​

Connect the components

You’ll need a few components:

once that is sorted,

Setting up your breadboard

breadboard diagram

Prerequisites

This sample assumes completion of Raspberry Pi setup for .NET Development and Blinky Sample that can be found explained in detail in the .NET 101 Series for IoT

NOTE In the video series, the Raspberry Pi is connecting to the internet via Ethernet cable. If you are following this from the MS Developer Twitch/Video Stream, you will notice there is no Ethernet cable, I setup the Rasbperry Pi to connect to the interwebs via WiFi. Either way, for the repo in this sample, the Raspberry Pi needs interweb connection and you can connect via either method, whatever works best for you.

Setup for VSCode Remote Debugging

This makes it easy to debug the code being run on the Raspberry Pi. To make this work for this sample repo, after completing the SSH steps explained in the Prerequisites , you can update the publish.bat with the values.

With that set, we follow the steps in Scott Hanselman's Blog Remote debugging with VS Code on Windows to a Raspberry Pi using .NET Core on ARM

Useful links :

Create your Azure Services

Excellent, at this point, we can connect our IoT device to the great wild internet.

  1. Create IoT Hub

  2. Register the Raspberry Pi device

  3. Update the DeviceConnectionString and DeviceID from values in Step 2 in Program.cs

  4. Setup Azure IoT Tools for VS Code to monitor the default IoT Hub Device end point for messages. This is super easy to setup by following the documentation

Congratulations! At this point, you can deploy the app to your Raspberry Pi, press the button and you will see messages appear in the VSCode output window.

Let's add a Logic App!

For this section, we are combining the steps in 2 different MS Doc tutorials. We will setup the intitial service bus, message routing and the initial logic app setup from this tutorial here. But for the fun twist, instead of email, we'll be using the Twitter Logic App Connector and steps for that can be found here.

And for the last fun bit, lets parse the IoT Message JSON value to Tweet our specific message by using the doc here.

Wahoo! If you made it this far, you are now tweeting via the button on your breadboard connected to a Smart Raspberry Pi, and all of it with the Power of .NET!

Additional resources

Releases

No releases published

Packages

No packages published