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.
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!
You’ll need a few components:
-
a couple of resistors
-
Micro USB cable to connect Raspberry Pi to power source
once that is sorted,
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.
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 :
-
Editing launch.json and tasks.json [Follow Hanselman's blog + this link]
Excellent, at this point, we can connect our IoT device to the great wild internet.
-
Update the DeviceConnectionString and DeviceID from values in Step 2 in Program.cs
-
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.
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!