Tuesday, March 21, 2017

SOLVED: Configure Raspberry Pi Wi-Fi the easy way

I recently had to configure the Wi-Fi on my Raspberry Pi which was running on Raspian Jessie Lite 8.0 (Debian).  It took a few attempts, but in the end, what I ended up with was very simple and it worked nicely.

I just modified /etc/network/interfaces with (changed in red text):

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

allow-hotplug eth0
auto eth0 iface
iface eth0 inet dhcp

# Wireless configuration

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
        wpa-ssid "myVisibleSSID"
        wpa-psk "password"

Then just remove the network cable and reboot.  Presto magic!

Saturday, March 11, 2017

Writing your own plugin for GpioWeb web service framework on Raspberry Pi

The RaspberryPi.NET.GpioWeb project is an extensible web service framework which not only comes with many built-in plugins for controlling the Raspberry Pi GPIO pins via a RESTful web service, but allows developers to write their own custom GPIO plugins.  Woo hoo!

We created a good video to help folks understand how to write their own custom plugins to extend this GPIO web service framework. As a reminder to folks, the framework is .NET based and executes on the Pi using Mono.

You can view the video at:

https://youtu.be/PwNvpr27Gw4

Would love to get some constructive input on if this is adequate to help folks with writing their own plugins.

The GpioWeb project and source code can be found on both Github and Bitbucket:

Github
https://github.com/paultechguy/RaspberryPi.DotNet.GpioWeb

Bitbucket
https://bitbucket.org/PaulTechGuy/raspberrypi.dotnet.gpioweb

Thanks.

Git: Sync a single local repository to both Github and Bitbucket

It turns out to be fairly simple to sync a single local git repository to both Github and Bitbucket. I use SourceTree for my single repository, which originally pointed solely to Bitbucket.  I did an Import of that repository into Github and now want all my commits using SourceTree to push to both remote repositories.

I just modified my local .git/config file to include another pushUrl.  No changes required in SourceTree, but when SourceTree does a push, both remotes will be updated.

Before:

[remote "origin"]
url = https://bitbucket.org/xyz/bitbucket.repository.name
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = https://bitbucket.org/xyz/bitbucket.repository.name

After:

[remote "origin"]
url = https://bitbucket.org/xyz/bitbucket.repository.name
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = https://bitbucket.org/xyz/bitbucket.repository.name
pushurl = https://github.com/xyz/github.repository.name

Wednesday, March 1, 2017

Resolved: Enable CORS on OWIN the right way

I was having difficulty, probably like you, trying to figure out how to get CORS working on a OWIN self-hosted application.  There were so many answers posted, but seemed like so many of them were based on older versions of Visual Studio / .NET.

Here is what I finally found to work for me; hopefully this will help you as well.  This is as of Visual Studio 2015 in early March 2017.

  1. Add nuget packages to the web api project:
    1. Microsoft.AspNet.WebApi.Cors
    2. Microsoft.Owin.Cors (this will also install Microsoft.AspNet.Cors)
  2. Modify startup.cs, Configuration(IAppBuilder app), add this line:

    app.UseCors(CorsOptions.AllowAll);

    and add it before the line:

    app.UseWebApi(config);
  3. Add the following attribute on my web api controller class:

    [EnableCors("*", "*", "*")]
These three steps got things finally working.

Control Raspberry Pi camera (tilt/pan) with C# / Mono

We updated the GpioWeb repository to include an example of how to control a tilt/pan camera hooked up to the Raspberry Pi (2 servos).  This was done in C# / Mono.

See the ServoPanTiltDemo.html file in the GpioWeb.PluginServoSimple directory.

The GpioWeb repository is located at:

Note: Remember that servos are all a bit different so you will need to slightly adjust the following values in the json "config" file (see instructions in the ServoPanTiltDemo.html file); values tend to run in the range of 100 to 700.

  • pwmMinPulse
  • pwmMaxPulse
If you download the GpioExamples repository, there is a servo example that you can run to determine the min/max pulse values for a specific servo.  When you run the example, it will ask for degrees (0 to 180), but if you prefix your input with "!" then it will be interpreted as a raw pulse value.  For example, "!125".  Very helpful.

Can't RDP? How to enable / disable virtual machine firewall for Azure VM

Oh no!  I accidentally blocked the RDP port on an Azure virtual machine which resulted in not being able to log into the VM anymore.  I did ...