﻿<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Protosystem Blog</title>
  <id>https://protosystemblog.azurewebsites.net/</id>
  <subtitle>Where prototyping becomes reality!</subtitle>
  <generator uri="https://github.com/madskristensen/Miniblog.Core" version="1.0">Miniblog.Core</generator>
  <updated>2017-11-10T01:31:28Z</updated>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/aspnet-core-hello-world-on-raspberry-pi/</id>
    <title>ASP.Net Core Hello World on Raspberry Pi</title>
    <updated>Wed, 29 Nov 2017 10:32:08 GMT</updated>
    <published>Fri, 10 Nov 2017 01:31:28 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/aspnet-core-hello-world-on-raspberry-pi/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="software" />
    <category term="raspberry pi" />
    <category term="dotnetcore" />
    <content type="html">&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;In a &lt;a href="http://www.protosystem.net/blog/aspnet-core-on-raspberry-pi/"&gt;previous post&lt;/a&gt; I showed you how to install the .Net Core 2.0 on a Raspberry Pi running Raspbian so that you could run dotnet Core applications on this wonderful device.&amp;nbsp; We didn't really run any applications in the previous post but we did prove that the dotnet core was installed properly.&amp;nbsp; In this post I will walk you through creating an ASP.Net Core 2.0 Hello World Web Application and deploy it onto the Raspberry Pi.&amp;nbsp; You will create this project on your developer machine and target the ARM processor for deployment to a Raspberry Pi.&amp;nbsp; This post will only cover doing this on a Windows machine.&lt;/p&gt;
&lt;h3&gt;Setup&lt;/h3&gt;
&lt;p&gt;You are going to need to make sure you have the .Net Core SDK on your developer workstation before you write some code.&amp;nbsp; Well I don't need to show you how to do that on my blog as it has already been done &lt;a href="https://www.microsoft.com/net/learn/get-started/windows"&gt;here&lt;/a&gt;. So stop procrastinating and get it installed.&lt;/p&gt;
&lt;p&gt;Just to double check that the .Net Core 2.0 SDK is installed open up a comman prompt and execute the following:&lt;/p&gt;
&lt;pre&gt;dotnet --info&lt;/pre&gt;
&lt;p&gt;You should see something like the following output:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="/posts/files/dotnetversion_636458773627441710.png" alt="dotnetversion.png" width="471" height="313" /&gt;&lt;/p&gt;
&lt;h3&gt;Create the Web App&lt;/h3&gt;
&lt;p&gt;Back on your developer workstation in that CMD prompt, create a new directory to hold your web application.&lt;/p&gt;
&lt;pre&gt;&lt;span class="csharpcode"&gt; mkdir hello-world&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Then jump into that new directory.&lt;/p&gt;
&lt;pre&gt;&lt;span class="csharpcode"&gt; cd hello-world&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;Then create a new web application.&lt;/p&gt;
&lt;pre&gt;&lt;span class="csharpcode"&gt; dotnet new web&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This created a simple web application that we can test on our developer workstation to make sure it works.&lt;/p&gt;
&lt;pre&gt;dotnet run&lt;/pre&gt;
&lt;p&gt;You should see something like the following output:&lt;/p&gt;
&lt;p&gt;&lt;img src="/posts/files/dotnetrun_636458773627579584.png" alt="dotnetrun.png" width="415" height="103" /&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Go ahead I know you are dying to open up a browser and navigate to http://localhost:5000 and see this new start of the art application!&lt;/p&gt;
&lt;p&gt;You should see something like the following:&lt;/p&gt;
&lt;p&gt;&lt;img src="/posts/files/helloworldmvc_636458773627655484.png" alt="helloworldmvc.png" width="467" height="185" /&gt;&lt;/p&gt;
&lt;p&gt;Ok this is pretty bare bones but I did say we were going to create a hello world web application.&amp;nbsp; But wait the real fun part is getting this to run on the Raspberry Pi. Go ahead and kill the development web server in the CMD prompt using Ctrl+C.&amp;nbsp; First we need to change the code so that it will bind to more IP addresses then the localhost one.&amp;nbsp; Edit the Program.cs class and change the following to add the UseKestrel and telling the web server to listen on all IP Addresses:&lt;/p&gt;
&lt;pre&gt;       public static IWebHost BuildWebHost(string[] args) =&amp;gt;
            WebHost.CreateDefaultBuilder(args)
                .UseStartup()
                .UseKestrel(options =&amp;gt;
                {
                    options.Listen(IPAddress.Any,5000);
                })
                .Build();
&lt;/pre&gt;
&lt;p&gt;Now lets publish this web application to a linux ARM platform.&lt;/p&gt;
&lt;pre&gt;dotnet publish -r linux-arm&lt;/pre&gt;
&lt;p&gt;The output of this commend looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="/posts/files/dotnetpublish_636458792254358166.png" alt="dotnetpublish.png" width="507" height="83" /&gt;&lt;/p&gt;
&lt;p&gt;This command generated all the files you need to copy over to the Raspberry Pi.&amp;nbsp; This is where you need to figure out the best way to copy the files to the Raspberry Pi.&amp;nbsp; One way to do this is to run an FTP server on the Pi and open up a FTP client (such as FileZilla) on your developer workstation and upload the files.&amp;nbsp; I like to use the Python library called &lt;a href="https://github.com/giampaolo/pyftpdlib"&gt;pyftpdlib&lt;/a&gt;&amp;nbsp;as it allows you to serve up files in any folder on the Pi and it is a temporary FTP server.&amp;nbsp; I didn't really want to focus this post on setting up an FTP server so I thought using this library will be the path of least resistance.&amp;nbsp; I am going to assume you already know how to SSH into your Raspberry Pi with something like Putty so go ahead and do that.&lt;/p&gt;
&lt;p&gt;On the Raspberry Pi install the python FTP library.&lt;/p&gt;
&lt;pre&gt;pip install pyftpdlib&lt;/pre&gt;
&lt;p&gt;Once the library is installed you need create a folder on the Raspberry Pi that will hold the hello-world web application.&amp;nbsp; On the Raspberry Pi issue the follwoing command:&lt;/p&gt;
&lt;pre&gt;mkdir hello-world&lt;/pre&gt;
&lt;p&gt;Then navigate into that directory&lt;/p&gt;
&lt;pre&gt;cd hello-world&lt;/pre&gt;
&lt;p&gt;Then start up the FTP server so we can upload the files.&amp;nbsp; On the Raspberry Pi execute the following command.&lt;/p&gt;
&lt;pre&gt;python -m pyftpdlib -w&lt;/pre&gt;
&lt;p&gt;On your developer workstation start up your favorite FTP client (such as FillZilla) and connect to the Raspberry Pi using anonymous/anonymous as the useranme/password.&amp;nbsp; Upload the files located in bin\debug\netcoreapp2.0\linux-arm\publish folder to the Raspberry Pi.&lt;/p&gt;
&lt;p&gt;Once the files are uploaded you can stop the FTP server on the Pi by using Ctrl+C in the SHH terminal. Next we need to set the right permissions on the executable.&amp;nbsp; Execute the follwing command on the Raspberry Pi.&lt;/p&gt;
&lt;pre&gt;chmod 755 hello-world&lt;/pre&gt;
&lt;p&gt;Now lets execute the application to serve up the files, so execute the following on teh Raspberry Pi:&lt;/p&gt;
&lt;pre&gt;./hello-world&lt;/pre&gt;
&lt;p&gt;The program should start up and let you know the port it is serving the web site on.&lt;/p&gt;
&lt;p&gt;Open up a browser on your developer workstation and put in http://x.x.x.x:5000 where x.x.x.x is the IP address of your Raspberry Pi. You should see the hello-world web application in your browser.&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;As you can see it is pretty easy to create a web application on your development machine and target the linux-arm platform so that the application can be copied over to the Raspberry Pi and executed.&amp;nbsp; We only did a simple web application but you can also create an mvc application and expose a Web API from the Pi.&amp;nbsp; Just execute the following:&lt;/p&gt;
&lt;p&gt;dotnet new mvc&lt;/p&gt;
&lt;p&gt;Next up I will look into remotely debugging an application from your developer workstation on the Raspberry Pi.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/aspnet-core-on-raspberry-pi/</id>
    <title>ASP.Net Core on Raspberry Pi</title>
    <updated>Fri, 10 Nov 2017 04:16:05 GMT</updated>
    <published>Sat, 04 Nov 2017 08:26:51 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/aspnet-core-on-raspberry-pi/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="software" />
    <category term="raspberry pi" />
    <category term="dotnetcore" />
    <content type="html">&lt;h2&gt;Overview&lt;/h2&gt;
&lt;p&gt;I just started playing around with &lt;a href="https://dotnet.github.io/"&gt;.Net Core&lt;/a&gt; since it has hit the 2.0 release.&amp;nbsp; Since I have used Raspberry Pi&amp;rsquo;s on many projects I thought it was time to do a hello world Asp.Net Core project that is served up on a Raspberry Pi using Raspbian for the OS.&amp;nbsp; Here is how I got that going.&lt;/p&gt;
&lt;p&gt;My goal was to create the default out of the box ASP.Net Core MVC application on my Windows 10 developer machine and publish it targeting ARM and see if I could get that running on the Raspberry Pi.&amp;nbsp; I do not intend to compile applications on the Raspberry Pi as I believe that would just be slow going.&amp;nbsp; I have longer term goals like being able to debug on the Pi from my Dev machine but lets take baby steps first.&lt;/p&gt;
&lt;h3&gt;Setting up the Raspberry Pi&lt;/h3&gt;
&lt;p&gt;At the time of writing this post it wasn&amp;rsquo;t real clear to me how to get .Net Core running on my Raspberry Pi with the latest Raspbian OS.&amp;nbsp; On the &lt;a href="https://docs.microsoft.com/en-us/dotnet/core/"&gt;Dotnet Core Docs site&lt;/a&gt;, there were instructions that targeted specific Linux distros but nothing that I saw specifically for Raspbian.&amp;nbsp; However I did find another &lt;a href="https://jeremylindsayni.wordpress.com/2017/07/23/running-a-net-core-2-app-on-raspbian-jessie-and-deploying-to-the-pi-with-cake/"&gt;blog post by Jeremy Lindsay&lt;/a&gt; that got me to the point that .Net Core 2 was installed on my Raspberry Pi.&amp;nbsp; I am not going to go into deep details on how to get Raspbian installed and how you shell into a terminal on a linux box as that is covered on many other posts (including Jeremy&amp;rsquo;s).&lt;/p&gt;
&lt;p&gt;Run the following commands in a terminal window on the Raspberry Pi:&lt;/p&gt;
&lt;pre&gt;&lt;span class="csharpcode"&gt; 
# Update the Raspbian Jessie install 
sudo apt-get -y update 

# Install the packages necessary for .NET Core 
sudo apt-get -y install libunwind8 gettext 

# Download the nightly binaries for .NET Core 2 
wget &lt;a href="https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.0.0/dotnet-runtime-latest-linux-arm.tar.gz"&gt;https://dotnetcli.blob.core.windows.net/dotnet/Runtime/release/2.0.0/dotnet-runtime-latest-linux-arm.tar.gz&lt;/a&gt;

# Create a folder to hold the .NET Core 2 installation 
sudo mkdir /opt/dotnet 

# Unzip the dotnet zip into the dotnet installation folder 
sudo tar -xvf dotnet-runtime-latest-linux-arm.tar.gz -C /opt/dotnet 

# set up a symbolic link to a directory on the path so we can call dotnet 
sudo ln -s /opt/dotnet/dotnet /usr/local/bin &lt;/span&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;p&gt;At this point you should be able to test the install by executing the following in a terminal window on the Raspberry Pi:&lt;/p&gt;
&lt;pre&gt;&lt;span class="csharpcode"&gt;
dotnet --info
&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;And you should get something back that tells you what version on dotnet core you have.&lt;/p&gt;
&lt;p&gt;&lt;a href="/posts/files/dotnetcore.png"&gt;&lt;img style="display: inline; background-image: none;" title="dotnetcore" src="/posts/files/dotnetcore_thumb.png" alt="dotnetcore" width="461" height="132" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Conclusion&lt;/h3&gt;
&lt;p&gt;As you can see getting the .Net Core 2 on your Raspberry Pi is pretty easy.&amp;nbsp; &lt;a href="http://www.protosystem.net/blog/aspnet-core-hello-world-on-raspberry-pi/"&gt;Next post&lt;/a&gt; I will go into creating an MVC hello world app and running it on the Raspberry Pi.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/halloween-scare-2016/</id>
    <title>Halloween Scare 2016</title>
    <updated>Sat, 04 Nov 2017 22:08:47 GMT</updated>
    <published>Fri, 28 Oct 2016 18:06:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/halloween-scare-2016/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="Hardware" />
    <category term="Raspberry Pi" />
    <category term="Software" />
    <content type="html">&lt;p&gt;I kicked off another Halloween project this year and I posted it on GitHub for everyone to see and use if they like. &amp;nbsp;This project has focused around building smart devices that are all connected via an MQTT bus. &amp;nbsp;I wanted to have something that I could build on every year. &amp;nbsp;The devices are either actuators or sensors that are smart enough to serve a purpose and can be orchestrated into a bigger animation scene using a workflow engine such as &lt;a title="Node-red" href="http://nodered.org"&gt;Node-red&lt;/a&gt;. &amp;nbsp;Anyways check out the project on &lt;a title="Hackster.io" href="https://www.hackster.io/mlinnen/halloween-scare-d5628d?ref=user&amp;amp;ref_id=4745&amp;amp;offset=0"&gt;Hackster.io&lt;/a&gt; and &lt;a title="GitHub" href="https://github.com/mlinnen/halloweenscare"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/halloween-treat-with-windows-10-iot-core-and-raspberry-pi/</id>
    <title>Halloween treat with Windows 10 IoT Core and Raspberry Pi</title>
    <updated>Sat, 04 Nov 2017 22:08:26 GMT</updated>
    <published>Tue, 08 Mar 2016 17:54:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/halloween-treat-with-windows-10-iot-core-and-raspberry-pi/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <content type="html">&lt;p&gt;I wrote another article on Hackster.io that shows how to build an animated ghostly pumpkin using Windows 10 IoT Core. &amp;nbsp;&lt;a href="https://www.hackster.io/mlinnen/halloween-treat-with-windows-10-iot-core-and-raspberry-pi-6de75d?ref=search&amp;amp;ref_id=mlinnen&amp;amp;offset=1"&gt;Check it out: Halloween treat with Windows 10 IoT Core and Raspberry Pi.&lt;/a&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/windows-10-iot-core-powered-garage-door/</id>
    <title>Windows 10 IoT Core powered garage door</title>
    <updated>Sun, 22 Nov 2015 21:23:09 GMT</updated>
    <published>Tue, 06 Oct 2015 20:03:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/windows-10-iot-core-powered-garage-door/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="Home Automation" />
    <category term="Software" />
    <category term="Raspberry Pi" />
    <category term="Hardware" />
    <content type="html">&lt;p&gt;I wrote an article on using the Raspberry Pi 2 Model B for a contest on &lt;a href="https://www.hackster.io/"&gt;Hackster.io&lt;/a&gt;.&amp;#160; This project focuses on using the &lt;a href="https://allseenalliance.org/"&gt;Alljoyn&lt;/a&gt; messaging framework. Head on over to &lt;a href="https://www.hackster.io/"&gt;Hackster.io&lt;/a&gt; for my &lt;a href="https://www.hackster.io/mlinnen/garage-door-powered-by-win-10-and-raspberry-pi"&gt;Garage door powered by Win 10 and the Raspberry Pi project&lt;/a&gt;.&amp;#160; Here is a video demo of the project.&lt;/p&gt; &lt;div&gt; &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/RPJ_iIO_5ZY" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; &lt;/div&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/continuous-delivery-on-a-sparkio/</id>
    <title>Continuous Delivery on a Spark.io</title>
    <updated>Thu, 06 Aug 2015 09:33:37 GMT</updated>
    <published>Sun, 15 Feb 2015 20:11:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/continuous-delivery-on-a-sparkio/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="Azure" />
    <category term="Home Automation" />
    <category term="Hardware" />
    <category term="Software" />
    <category term="Spark Core" />
    <content type="html">&lt;p&gt;I have always wanted to remotely update my IoT devices when they are in need of a software change.&amp;#160; It is really a pain when I have to disassemble a dedicated device just because I need to update the software that is embedded in it.&amp;#160; It has been so much of a pain for me I have gone as far as trying to make the device as dumb as possible and leave the smarts in a service located on a computer with an OS that supports remote access.&amp;#160; Doing so seems to make the device just a remote I/O extension and not an actual Smart Device.&amp;#160; &lt;/p&gt;  &lt;p&gt;Continuous delivery takes the remote update one step further.&amp;#160; If I have a source control repository that I commit some new code to, then my automated process should be smart enough to pick up that change, compile, test and deploy the new bits to it’s final destination.&amp;#160; Wow wouldn’t that be cool!!!&lt;/p&gt;  &lt;p&gt;In order to do this the device would need to be smart enough to support a remote update process.&amp;#160; That means a device would have to be able to check for updates and automatically apply them.&amp;#160; You could write your own remote update process and I have done this many times for desktop applications, but doing this on an embedded device is little more tricky.&amp;#160; Sometimes it would require you to actually change the device firmware especially if the device doesn’t support dynamically loaded software.&amp;#160; Basically the process to do so would require you to do the following:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Detect if an update exists on some remotely accessible resource &lt;/li&gt;    &lt;li&gt;Download the update and unpack it &lt;/li&gt;    &lt;li&gt;Unload the current version of the software &lt;/li&gt;    &lt;li&gt;Load the new version of the software &lt;/li&gt;    &lt;li&gt;Start executing the new version &lt;/li&gt;    &lt;li&gt;Do this reliably without bricking the device &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Fortunately the Spark.Io platform does all this for you so you don’t have to.&amp;#160; The platform even supports an open source backend that will take source code, compile and deploy it.&amp;#160; Now that makes it very possible to do continuous delivery for IoT devices.&amp;#160; The rest of this blog post will explain how easy it is to set this up.&lt;/p&gt;  &lt;p&gt;There are several things you will need to have in order to accomplish this:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;A Spark.io account and a device that is connected/registered with the account. &lt;/li&gt;    &lt;li&gt;A source control repository that is supported by your CI tool of choice (I am using GitHub) &lt;/li&gt;    &lt;li&gt;A build script that can either call restful APIs or can shell out to curl.exe (I am using psake with curl.exe). &lt;/li&gt;    &lt;li&gt;A CI tool that watches the source control for commits and kicks off the build process (I am using &lt;a href="https://www.jetbrains.com/teamcity/"&gt;Team City&lt;/a&gt; on a &lt;a href="http://azure.microsoft.com/en-us/services/virtual-machines/"&gt;Windows Azure VM&lt;/a&gt;). &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You can see my source repository over at &lt;a href="https://github.com/mlinnen/SparkContinuosDeliveryExample"&gt;SparkContinuousDeliveryExample&lt;/a&gt;. Feel free to fork it and use it if you like.&amp;#160; I used &lt;a href="https://github.com/psake/psake"&gt;psake&lt;/a&gt; as my build scripting language of choice as it is supported by Team City and I find it very easy to understand.&amp;#160; &lt;/p&gt;  &lt;h2&gt;Build script&lt;/h2&gt;  &lt;p&gt;My build script is called default.ps1.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;font size="1"&gt;properties { 
  $deviceId = $env:SparkDeviceId 
  $token = $env:SparkToken 
  $base_dir = resolve-path . 
  $curl = &amp;quot;$base_dir\lib\curl\curl.exe&amp;quot; 
}

task default -depends Deploy

task Clean { 
}

task Deploy { 
  $url = &lt;span class="str"&gt;&amp;quot;https://api.spark.io/v1/devices/&amp;quot;&lt;/span&gt; + $deviceId + &amp;quot;?access_token=&amp;quot; + $token 
  exec { 
     .$curl -X PUT -F file=@src\helloworld.ino &amp;quot;$url&amp;quot; -k 

  } 
} -depends Clean

task ? -Description &amp;quot;Helper to display task info&amp;quot; { 
   Write-Documentation 

&lt;/font&gt;&lt;/pre&gt;

&lt;p&gt;The first thing you will notice is that the script takes 4 parameters that are defaulted but also can be overridden by Team City.&amp;#160; The $deviceId represents the spark.io device Id and can be found in the &lt;a href="https://www.spark.io/build/"&gt;spark.io build&lt;/a&gt; website after you have logged in and picked one of your devices.&amp;#160; The $token is your spark.io access token and can be found in the &lt;a href="https://www.spark.io/build/"&gt;spark.io build&lt;/a&gt; website after you have logged in and selected the settings menu option.&amp;#160; You really only have 1 access token for an account but you could have multiple device id’s for an account.&amp;#160; The other 2 parameters are really only for executing the curl.exe program that interfaces with the spark.io platform.&amp;#160; Since the repository has the curl.exe you wont have to worry about installing it on your build server, but if you don’t like putting EXE’s in your repository you could override these parameters to launch the curl.exe that is installed on your build agent. The Deploy task is the only task in this build script that does anything.&amp;#160; Basically it launches curl.exe passing in the device id, token and the file name to upload to the spark.io platform for compilation and deployment.&amp;#160; In this case the program source file is helloworld.ino.&lt;/p&gt;

&lt;h2&gt;Testing the build script locally&lt;/h2&gt;

&lt;p&gt;You can test the psake build script on your local machine by first setting the environment variables for the $env:SparkDeviceId and $env:SparkToken.&lt;/p&gt;

&lt;p&gt;&lt;a href="/posts/files/SetEnvVariables.jpg"&gt;&lt;img title="SetEnvVariables" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="SetEnvVariables" src="/posts/files/SetEnvVariables_thumb.jpg" width="394" height="54" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Of course I didn’t include my real Device ID and Token in the example above so make sure you set them using your own Spark.io settings.&lt;/p&gt;

&lt;p&gt;Make sure you are in the directory where you cloned the repository and use the Invoke-psake keyword to kick off the build.&lt;/p&gt;

&lt;p&gt;&lt;a href="/posts/files/Build.jpg"&gt;&lt;img title="Build" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="Build" src="/posts/files/Build_thumb.jpg" width="399" height="187" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your code will be uploaded to spark.io, compiled and then deployed to your device.&amp;#160; As you can see here the process completed successfully.&lt;/p&gt;

&lt;h2&gt;Setting up Team City:&lt;/h2&gt;

&lt;p&gt;You will have to follow the instructions on the Team City web site on how to install Team City.&amp;#160; It is very easy to do but I wont detail it here.&amp;#160; I am also going to ignore the step of setting up Team City to connect to your Github repository. Assuming you have a project created in Team City and you have assigned the VCS root to the project you need a build step added to your project.&amp;#160; You want to make sure you select Powershell as the runner type.&amp;#160; See the other options I selected in the following screen snapshot:&lt;/p&gt;

&lt;p&gt;&lt;a href="/posts/files/TC_1.jpg"&gt;&lt;img title="TC_1" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="TC_1" src="/posts/files/TC_1_thumb.jpg" width="415" height="196" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you select Source Code as the script type and then type in the powershell script but make sure you replace the YourDeviceId and YourToken.&lt;/p&gt;

&lt;p&gt;&lt;a href="/posts/files/TC_2.jpg"&gt;&lt;img title="TC_2" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="TC_2" src="/posts/files/TC_2_thumb.jpg" width="421" height="86" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the script so you can copy and paste it easier. &lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;font size="1"&gt;&lt;/font&gt;&lt;font size="1"&gt;
import-module .\lib\psake\psake.psm1
invoke-psake .\default.ps1 -properties @{&amp;quot;deviceId&amp;quot;=&amp;quot;YourID&amp;quot;;&amp;quot;token&amp;quot;=&amp;quot;YourToken&amp;quot;}
if ($psake.build_success -eq $false) {exit 1} else { exit 0}&lt;/pre&gt;

&lt;p&gt;Here are the rest of the options to finish off the build step:&lt;/p&gt;

&lt;p&gt;&lt;a href="/posts/files/TC_3.jpg"&gt;&lt;img title="TC_3" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="TC_3" src="/posts/files/TC_3_thumb.jpg" width="309" height="118" /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that is all there is to it.&amp;#160; You will want to add a Trigger to your build project so that it fires off a build when source is committed to the repository.&amp;#160; Also make sure you have the VCS Root pointed to the “master” branch.&amp;#160; Now whenever you commit changes to the master branch the build will pick it up and send it off to Spark.io for compile and deploy.&lt;/p&gt;

&lt;h3&gt;Limitations:&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Works on single file source solutions at this time. &lt;/li&gt;

  &lt;li&gt;If a compile error exists the build does not fail (but the device does not update). &lt;/li&gt;

  &lt;li&gt;If you edit the readme or any other non-source files and commit it then the device gets updated even though no source changes were made. &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Enhancements:&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Get this working on a free hosted build platform &lt;/li&gt;

  &lt;li&gt;Use a Raspberry PI as a build server &lt;/li&gt;

  &lt;li&gt;Remove the dependency on curl.exe and use powershell to make the REST api calls &lt;/li&gt;

  &lt;li&gt;Add in multi-file support &lt;/li&gt;

  &lt;li&gt;If the Spark.io platform is down fail the build &lt;/li&gt;

  &lt;li&gt;Make sure a compile error fails the build &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Conclusion:&lt;/h2&gt;

&lt;p&gt;That is all I wanted to cover on this blog post.&amp;#160; Of course there a million other ways you could set this up and I would also like to hear how others might do this.&amp;#160; I have always dreaded pulling devices apart just to upgrade them and therefore I tended to not update them as frequently as I would like.&amp;#160; I just need to get the hardware nailed down on some projects so that I can get them installed and hooked up to a build.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/garage-door-and-the-spark-core-on-github/</id>
    <title>Garage door and the Spark Core on github</title>
    <updated>Sun, 05 Nov 2017 14:16:01 GMT</updated>
    <published>Thu, 25 Dec 2014 18:11:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/garage-door-and-the-spark-core-on-github/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="software" />
    <category term="spark core" />
    <category term="home automation" />
    <category term="hardware" />
    <content type="html">&lt;p&gt;I just posted my initial code for my Garage door project using the Spark Core on github.&amp;nbsp; This is a work in progress and will evolve over time.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mlinnen/SparkGarageDoor"&gt;Source Code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.protosystem.net/post/Garage-door-and-the-Spark-Core"&gt;Initial blog post about the project&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/garage-door-and-the-spark-core/</id>
    <title>Garage door and the Spark Core</title>
    <updated>Sun, 05 Nov 2017 14:22:08 GMT</updated>
    <published>Fri, 19 Dec 2014 22:21:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/garage-door-and-the-spark-core/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="home automation" />
    <category term="software" />
    <category term="hardware" />
    <category term="spark core" />
    <content type="html">&lt;p&gt;I recently moved to a new home and I now have 2 garage doors to control instead of one.&amp;nbsp; So I decided to revamp my garage door home automation project by using the &lt;a href="https://www.particle.io"&gt;Spark Core&lt;/a&gt;.&amp;nbsp; This is a fascinating device as it is designed to connect to the Spark.IO cloud service without doing a lot of coding to maintain the connectivity to the cloud.&amp;nbsp; The default firmware in the device allows you to remotely connect to it and invoke functions, expose variables to the cloud service as well as perform pub/sub between devices.&amp;nbsp; Make sure you check out their website to gain a better understanding of all the capabilities of this small packaged IoT controller.&lt;/p&gt;
&lt;p&gt;My goals in this project was to achieve the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;know when either garage door is opened or closed.&lt;/li&gt;
&lt;li&gt;remotely close or open the garage door.&lt;/li&gt;
&lt;li&gt;have the door automatically close when I go to bed.&lt;/li&gt;
&lt;li&gt;keep track of how long it takes to open/close the garage door.&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;if the door starts to take longer to open and close this might be a sign that it needs maintenance.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;automatically open the garage door when I arrive home.&lt;/li&gt;
&lt;li&gt;automatically close the garage door when I leave my home.&lt;/li&gt;
&lt;li&gt;notify me when the door needs maintenance because it has been opened/closed so many times.&lt;/li&gt;
&lt;li&gt;monitor the temperature and humidity in the garage.&lt;/li&gt;
&lt;li&gt;monitor the garage for motion when the security system is on.&lt;/li&gt;
&lt;li&gt;notify me that I left the door open after a specific time of night.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That is certainly a large number of goals and I don&amp;rsquo;t intend to complete all of them initially but you kind of get the idea of what the possibilities are.&lt;/p&gt;
&lt;p&gt;Initially I intended to do all of this for 2 garage doors with one &lt;a href="https://www.particle.io"&gt;Spark Core&lt;/a&gt;, but after thinking about it a bit it made more sense to use at least two &lt;a href="https://www.particle.io"&gt;Spark Cores&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;One thing I decided to do right off the bat is to make sure I have enough sensors that could determine when the door was opened and when it was closed.&amp;nbsp; I have seen other remote garage door projects that simply have one sensor that detects if the door is closed or not.&amp;nbsp; I wanted more inputs so that I could time how long it took for a door to complete it&amp;rsquo;s open or close command.&amp;nbsp; I want to keep track of this in order to determine if the door will need maintenance when it starts to take longer to open or close.&amp;nbsp; I can also gather a little more analytics around the timing of the door command and the temperature in the garage.&amp;nbsp; I don&amp;rsquo;t know if I will use this more detailed information for anything or not but I thought it would be fun to play around with.&lt;/p&gt;
&lt;p&gt;So I will have 2 magnetic reed switches that I plan on placing on the door track to determine if the door is closed or opened.&amp;nbsp; The status of the door will be 5 different states: opened, closed, opening, closing and unknown.&amp;nbsp; The unknown state will only be for when neither of the sensors are triggered and the device doesn&amp;rsquo;t know if the door was previously opened or closed.&amp;nbsp; I have most of the code written to handle the basic door operations and I will be sharing that code in a future post.&lt;/p&gt;
&lt;p&gt;So stay tuned on future posts on this topic as I move forward with it.&amp;nbsp; Please feel free to give me feedback or ask questions on items I haven&amp;rsquo;t clarified very well.&amp;nbsp; I am very interested in anyone&amp;rsquo;s thoughts on the Spark Core as well as home automation in general.&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/builderfaire-track-at-raleigh-code-camp-2014-/</id>
    <title>BuilderFaire track at Raleigh Code Camp 2014</title>
    <updated>Sat, 04 Nov 2017 18:44:28 GMT</updated>
    <published>Sat, 08 Nov 2014 07:04:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/builderfaire-track-at-raleigh-code-camp-2014-/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="hardware" />
    <category term="home automation" />
    <category term="software" />
    <category term="raspberry pi" />
    <content type="html">&lt;p&gt;I gave a talk at the Raleigh Code Camp called "What can I do with a Raspberry PI". The slide deck is attached to this post for those of you that attended.&lt;/p&gt;
&lt;p&gt;&lt;a href="/posts/files/2014/11/Raspberry%20PIv2.pptx"&gt;Raspberry PIv2.pptx (6.67 mb)&lt;/a&gt;&lt;/p&gt;</content>
  </entry>
  <entry>
    <id>https://protosystemblog.azurewebsites.net/blog/raleigh-code-camp-2013-netduino-azure-session/</id>
    <title>Raleigh Code Camp 2013 Netduino Azure Session</title>
    <updated>Wed, 30 Oct 2013 18:33:18 GMT</updated>
    <published>Wed, 30 Oct 2013 18:31:00 GMT</published>
    <link href="https://protosystemblog.azurewebsites.net/blog/raleigh-code-camp-2013-netduino-azure-session/" />
    <author>
      <name>Mike Linnen</name>
      <email>test@example.com</email>
    </author>
    <category term="Home Automation" />
    <category term="Azure" />
    <category term="Software" />
    <category term="Netduino" />
    <category term="Hardware" />
    <content type="html">&lt;p&gt;I am presenting two sessions in the &lt;a href="http://www.codecamp.org/Raleigh/Sessions"&gt;Raleigh Code Camp&lt;/a&gt; 2013 Builder Faire track on November 9th.&amp;#160; The first session is called &lt;strong&gt;&lt;em&gt;Building a cloud enabled home security system Part 1 of 2 (the presentation)&lt;/em&gt;&lt;/strong&gt;.&amp;#160; The second session is &lt;strong&gt;&lt;em&gt;Building a cloud enabled home security system Part 2 of 2 (the lab)&lt;/em&gt;&lt;/strong&gt;.&amp;#160; You really need to come to both sessions as the first session explains what you will be building in the second session.&amp;#160; Yes I said that right, if you attend the second session you will be building a Netduino based security system that connects to Windows Azure.&amp;#160; Check out the project website for more details at &lt;a href="http://www.cloudhomesecurity.com/"&gt;Cloud Home Security&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;I hope to see you there!! &lt;/p&gt;</content>
  </entry></feed>