Additional Guidance for the Microsoft Connect-the-Dots Sample Project

 

clip_image002[4]

 

Project Scope

While deploying the Microsoft Connect-the-Dots sample project, I ran into a few difficulties and this article is a description of the workarounds that were used to solve those difficulties.   

Here is a brief description of the project in question:  The Microsoft Connect-the-Dots GitHub sample project builds a weather reporting Internet of Things (IoT) application which demonstrates data collection using Azure Streaming Analytics and Azure Event Hubs.  See links below for the project resources and guide:

 

Requirements

Here is a list of the things you will need to deploy this project.

 

Some Assembly Required

Unless you purchased a pre-assembled kit, the first step will be to solder the Arduino Stackable Headers onto the SparkFun Weather Shield – this step was not covered in the project guide.  Given my lack of soldering experience, I will make no attempt to teach soldering, but this video was extremely helpful to me.  To hold the Stackable Headers and Weather Shield in place while soldering, turn the Arduino upside down, slide the Stackable Headers onto the pins underneath, and then slide the Weather Shield on top. 

Here is a picture of the Weather Shield after it has been soldered:

 

clip_image004[4]

 

Set Up the Azure Resources

This step in the project guide deploys and configures the Azure Event Hubs service, an Azure Streaming Analytics service, and an Azure Web App to the Azure subscription.  I ran into no problems during this step, so simply follow this portion of the project guide to the letter.

Here is a screenshot of the Event Hubs service that will be deployed:

 clip_image006[4]

Here is a screenshot of the Streaming Analytics service that will be deployed:

clip_image008[4]

 

Prepare the Arduino and Weather Shield

It was assumed in the project guide that the process for uploading code (called a sketch) to an Arduino was already known, so the steps are included here:

  1. Attach the Weather Shield to the Arduino:  soldered weather shield
  2. Connect the Arduino to your computer with the USB cable
  3. Start the Arduino IDE
  4. Go to ‘File’ –> ‘Open’ and navigate to the folder with the unzipped Connect-the-Dots project
  5. Go to Devices/GatewayConnectedDevices/Arduino UNO/Weather/WeatherShieldJson and open the WeatherShieldJson.ino file
  6. If desired, change the values for GUID1[], Guid2[], Guid3[], Org[], and Disp[], but this is not necessary
  7. Compile the sketch and upload it to the Arduino (file –> upload or Ctrl+U)
  8. Open the Serial Monitor (tools –> serial monitor) and you should see the data flowing

 

Prepare the Raspberry Pi

The Raspberry Pi will operate as the gateway to Azure for the data transfer.  There were a few permission-related issues that I ran into while following this part of the project guide, so here is a workaround for copying files to the Raspberry Pi.

  1. Plug the Arduino with attached Weather Shield into the Raspberry Pi by the USB cable
  2. Follow this guide until reaching the point in the guide were the deploy.cmd file needs to be executed, then use the instructions below instead.  Once completed, return to the guide linked above
  3. Log into the Raspberry Pi with WinSCP (installed previously)
  4. Copy all of the following files to the ctdgtwy/staging directory (If a permission error occurs, see ‘Dealing with Permission errors on the Raspberry Pi’ below):
    • Everything in the “GatewayService\WindowsService\bin\Release\” folder
    • SeviceAdapters\SerialPort\bin\Release\Microsoft.ConnectTheDots.SerialPortAdapter.dll
    • DeviceAdapters\Socket\bin\Release\Microsoft.ConnectTheDots.SocketAdapter.dll
    • Scripts\RaspberryPi\Modified\certificate_update.sh
    • Scripts\RaspberryPi\Modified\autorun_install.sh
    • Scripts\RaspberryPi\Modified\kill_all.sh
  5. Copy the following files to the ctdgtwy directory (If a permission error occurs, see ‘Dealing with Permission errors on the Raspberry Pi’ below):
    • Scripts\RaspberryPi\Modified\deploy_and_start_ctd_on_boot.sh
  6. Run the following commands while logged into the Raspberry Pi using Putty (this will make some of the executable):
    • sudo chmod 755 ctdgtwy/staging/certificate_update.sh
    • sudo chmod 755 ctdgtwy/staging/autorun_install.sh
    • sudo chmod 755 ctdgtwy/staging/kill_all.sh
    • sudo chmod 755 ctdgtwy/deploy_and_start_ctd_on_boot.sh
  7. Return to the main Raspberry Pi guide (step 2) starting from “On the Raspberry Pi, modify /etc/rc.local with nano”

Dealing with Permission Errors on the Raspberry Pi:  It is possible that a permission error will occur when attempting to copy directly to those folders. If so, copy the files to the Home/Pi folder with WinSCP and then move the files in a normal Secure Shell (SSH) session using Putty by following these steps:

  1. Go to the Home/Pi folder
  2. Run the following commands:
    • sudo mv deploy_and_start_ctd_on_boot.sh ctdgtwy
    • sudo mv *.* ctdgtwy/staging

 

Deploy the Sample Website

I ran into no issues with this section, so simply follow this portion of the project guide. 

 

Setup the Analysis Services

The latest scripts used in the “Set up the Azure Resources” section (above) incorporated the creation of these services, so they can be skipped.

 

Run the Scenario

Here is a picture of the finished product, including a nifty case for the Raspberry Pi (the one pictured can be purchased here):

 

clip_image011[4]

Once the project guide is completed with the above modifications, data will begin flowing to the website at the URL chosen when deploying it – this will be of the form myname.azurewebsites.net.  The average temperature measurements will show up in the web browser every 20 seconds.

By selecting ‘All’, the raw readings from the device will be updated every one second.  If the temperature exceeds 75-degrees Fahrenheit, then an alert will appear on the alerts table (once every 20 seconds while the temperature on any of the devices exceeds 75 degrees).   Try covering the Weather Shield with a hand and see the effect on the data coming in.

Here is a screenshot of the website after it has collected a few minutes of data:

clip_image012[4]

 

Conclusion

Following the above steps, while working though the project guide should solve any problems encountered and have the solution deployed in just a few minutes (soldering not included).  If any additional difficulties are discovered, the GitHub Project Issues Forum is a fantastic resource.  Please feel free to comment below.

 

Leave a Reply