Archive for category Windows 10 IoT
I’ve had somewhat of an adventure with the Windows Update process on the Windows 10 IoT Core.
In the Windows Device Portal I was on the Windows Update page. So to make sure my device was up to date, I clicked the “Check for updates” button and … nothing happened on screen. Knowing that the process was probably running in the background, I moved on to check other pages.
When I came back to that screen later I got a You must restart your device to apply the updates kind of button. So I clicked on it and the device proceeded to reboot as expected. I got the cog wheel going and a progress bar for a number of minutes. Then I got a giant frown emoticon:
And the screen went blank. I waited for 30 minutes then turned off the device. Then turned it back on, got cog wheels for a few minutes, then frown, then blank. It had essentially screwed up the Operating System.
Flashing the SD card
I took out my SD card, placed it in my development machine. And proceeded to re-image it without issues. Placed the card back in my device and it started without issues.
In any case, it gave me the material to write a post about Flashing the SD card…
This happened to me on a brand new device with a new SD card that is part of a starter pack.
This may have been a bad fluke. But getting errors like this on a clean device is a bit worrisome.
So I finally got the Raspberry Pi hardware yesterday. I will spare you the unboxing video, I’m sure there are a number of them already.
I plugged in the Raspberry Pi to a keyboard, a mouse, and a screen. Added the Wifi USB dongle and started it up.
This blog explores the different ways we can access the device by default. This is only an introduction, we probably will return to see some of those interfaces in more depth as we need them in the future.
Raspberry Pi on screen Experience
(Sorry, I have not figured out how to take screen shots on the Raspberry Pi yet, and phone picture are horrible. I will add screen shots when/if I figure it out)
First Start Up
After churning for a couple minutes, it prompted me for language and selecting the wireless network. That done, it re-directed me to the main screen.
If you saved the default settings, on subsequent start ups, the boot process sends you directly to the main screen.
On the main screen, the device information application is displayed. The top of the screen look like a task bar with applications running on the left with a system tray to the right.
The applications running are:
- Device info
The system tray has:
- Device Settings
- On/Off button
The On/Off button offers:
Device Settings Page
The Device Settings page allows you to set:
- Basic preferences: Only sets language at this point
- Network & Wi-Fi: Select and configure Wi-Fi
Windows 10 IoT Core Dashboard
Going back to my development computer and I fired up the Windows 10 IoT Core Dashboard to see what would show up.
The startup page gets you on the Set up a new device. Setting up a new device is used to create a new SD card. I already had a pre-configured SD card (from the starting pack) so I went directly to My devices.
My devices show a list of devices connected on your network. Give it a few minutes to detect your device.
From here you can open up the device Settings or Open in Device Portal. I went for Settings.
The Device Settings page allows you to change your device name and set your administrator password. You should take the time to at least change the password. The default password for the Administrator account is: p@ssw0rd
From here we’ll go to the Windows Device Portal in browser.
Windows Device Portal
The Windows Device Portal is a web page served directly by the device. It provides a lot more functionality than the IoT dashboard or the device interactive UI. The left hand menu allows you to navigate to different sections.
The sections are:
- Perf Tracing
- Windows Update
Also a number of functions are available on the right hand header:
Here are the more high level and useful pages for now:
The home page provides information about the device, allows you to change the device name and change the administrator password.
The App Manager page provides a lot of functionality. It allows you to manage applications, uninstall application, select default startup application. It also allows you to deploy new applications.
The debugging page provides a list of the current processes, displays error logs and set error reporting parameters. It also allows you to manually start the Visual Studio Remote Debugger.
Note: The remote debugger is not installed by default on Windows IoT Core 10586. It is only deployed the first time you start a debugging session from Visual Studio. If you attempt to start the Remote Debugger before you start a debugging session, you get the following error message is:
The networking section allows you to set the networking parameters. It provides a list of available networks and displace the current IP configuration for the different networking interfaces on the device (I snipped the screen shot, it actually showed 3 network adapters).
The Windows Update page allows you to check for available operating system updates. If updates are available they will be installed on the next restart.
This seems to be most of the out of the box high level user interfaces available to interact with the Windows 10 IoT Core operating system.
Of course there are also more advanced mode of interaction available like command lines, PowerShell and programming APIs. But we will see those in other posts in the future.
Let’s explore the General Purpose Input/Output (GPIO) interface offered by the Windows 10 IoT core.
The GPIO interface is deceptively simple. It consists in a few classes and enumerations. The main classes are:
- GpioController class: Provides access to all the pins of the GPIO(s) bus.
- GpioPin class: Represents a single pin on the GPIO. It provides functions to read/write pin values and provides an event that can be triggered when a pin value changes.
The GpioController class cannot be directly instantiated. Instances are accessed through one of the static functions on the class:
- GetDefault(): Returns the default Gpio controller for the device.
- GetDefaultAsync(): Returns the default Gpio controller for the device asynchronously.
- GetControllersAsync() : Returns a list of all the Gpio controllers available for the device asynchronously.
The instance functions of the GpioController are used to manage pins:
- PinCount: Returns the number of pins available for this GpioController.
- OpenPin(): Opens a connection to the pin and returns the corresponding GpioPin. An overload of the function allows you to supply a sharing mode other than exclusive.
- TryOpenPin(): Opens a connection to the pin and returns the corresponding GpioPin. This variant will not throw an exception on error but will return a status making it easier to handle errors.
The GpioPin class gives you access to read and manipulate a single pin. Like the GpioController, you cannot instantiate this class directly. You access it using the GpioController OpenPin or TryOpenPin functions.
The GpioPin class provides members query information about the pin:
- PinNumber: Returns the pin number for this pin.
- SharingMode: Returns the sharing mode for this pin. Modes can be Exclusive or SharedReadOnly.
The GpioPin class provides members configure the pin. Drive mode is probably the most important item to configure on a pin. It tells the pin whether it is an input or an output and specifies the way the electronic is organized. There are multiple drive mode available see GpioPinDriveMode for more information about the available drive modes. I will do a post specific to this later on.
- IsDriveModeSupported(): Can the pin support this drive mode.
- GetDriveMode(): Returns the currently configured drive mode for this pin.
- SetDriveMode(): Sets the drive mode for this pin.
- ValueChanged: Event that is triggered when a change of state is detected on the pin. This member allows us to attach an event handler to handle that event.
- DebounceTimeout: Get/Sets the interval of time after the ValueChanged event is trigger during which the changes in the pin will not trigger another ValueChanged event.
The GpioPin class provides members to read and write the value of the pin:
- Read(): Returns the current value of the pin High/Low. This will work on inputs or output pins.
- Write(): Sets the value for the pin High/Low. This will only work on output pins.
There are a number of possible ways to use the GPIO. The most common scenario are:
Pin reading / writing
This process consist in setting up your pin(s), manipulating them and disposing of the pin when done.
This process consist in setting up your pin(s), registering an event handler that will be triggered when a pin change is detected and waiting for events to occur, and disposing of the pin(s) when done .
The GPIO interface provided by the Windows 10 IoT library is simple but comprehensive. This information should allow us to come up with a plan on how to write device code.
The only touchy points I can see so far is: Figuring out how to set a valid DebounceTimeout value. We’ll be in a better position to figure out those details once we start coding against an actual device.
For more information see the MSDN documentation
Now that my development computer is setup, I wanted to look at some code. So I explored a little around the start up sample projects offered by Adafruit where I purchased the Microsoft IoT Pack for Raspberry Pi 2. I also looked at Microsoft supplied samples and the Raspberry Pi Foundation web site.
My goal here was: To look at code to understand the general anatomy of the process to develop IoT devices using the Raspberry Pi. To see someone using the GPOI in C#.
I found tons of good projects of all kind. I just wanted one that would be simple, but would give me an overall view. The one offered by Adafruit offered all the information I wanted:
This blog post clarified a number of points for me:
Windows Universal Application
Visual Studio offers a large amount project templates. Choosing the right template can mean the difference between success and re-doing everything. Unfortunately for me, having done mostly ASP.NET and MVC (with some WPF) applications for the past 15 years, I was not aware of the Windows Universal application thread.
I had already started coding some useful libraries that I wanted to re-use across multiple project types. I used the Portable Libraries project type for those. Of course, I could just copy/paste the code into a Windows Universal class library but that defeats the purpose of re-use… Some re-design will be required there for sure.
WPF User Interface on the Device
I did not expect this and I did not expect it would be this easy. You can write the User Interface for your application to run directly on the device.
Best of all it’s WPF and I am quite comfortable with it. I see great things happening in this department!
Coding the GPIO
Although the code in this application is very linear and repetitive (for simplicity purpose I am sure), it shows that the code to access and control the GPIO is simple. I did some additional research and figured out that: Yeah! This is actually really simple!
Building Electronic Circuit
Last time I wrote an electronic circuit was in 1992. I do have a lot updating to do. The section “Building out the circuit” in this sample was just what I needed to get me thinking about this again.
Perhaps the most interesting thing here is Fritzing . Fritzing is an application to create and document your electronic circuit prototype. That is definitely something I will have to explore deeper.
Running and Debugging
There is no talk about debugging, but running seems quite easy and strait forward. Just start the application on the device, provide device IP address and Voila!
I feel quite confident we can get this working and have fun doing it. This is going to be a lot easier than I expected!
I found that a good place to get started with the Windows 10 Iot Core is on the Microsoft developer’s site:
This site provided a good introduction and provides a section on prepping your PC. So I can get started on this right away.
Set up your PC page
The setup was fairly simple for me as I already have Windows 10 and Visual Studio 2015 installed. So I went through the check list quickly:
- Windows 10 (10.0.10240 +) Check
- Install Visual Studio 2015 Check
- VS 2015 Update 1 and + Check
- Validate Visual Studio 2015 (14.0.24720.00) Check/Done
- Install IoT Core Project Templates (Tools > Extensions and Update > Online) Done
- Enable developer mode on Windows 10 device. Done
There are a couple of important things to know:
On step 4 you may need to Add the Visual Studio Tools for Universal Windows Apps if they are not already installed. To add this to Visual Studio do this follow:
- Control Panel -> Programs and Features
- Select your installation of Microsoft Visual Studio 2015
- Right click Change
- Select Modify in the Installer
- Select Features > Windows and Web Development > Universal Windows App Development Tools
- Click Update / Install.
- This may take a while…
For step 5, the step are:
- In Visual Studio click Tools > Extensions and Update > Online
- Type IoT in the search box
- Select Windows IoT Core Project Templates
For step 6, this is about turning off the nagging screen whenever you run a Universal application from Visual Studio. You can read the full instructions. The steps are basically:
- From the Windows Start Menu
- Settings. Choose Update & security
- Choose For developers
- Select Developer mode
- Read the disclaimer and click Yes
Set up your Raspberry Pi 2 page
If we continue on the setting up the Setting up your Raspberry Pi 2 page. They download an install the IoT Dashboard tool. I decided to download this and install it right now.
We are now ready to go once I receive the Raspberry Pi.
Next we will start looking at code and examples.