Sunteți pe pagina 1din 82

Beginning

Windows 10 IoT Core


Raspberry Pi 2


Beginning Windows 10 IoT Core


Raspberry Pi 2

Alison Watson
Suntimebox Publishing
2016

Copyright 2016 by Suntimebox Publishing



All rights reserved. No Part of this book may be reproduced or transmitted in any form by
means, electronic or mechanical, including photocopying, recording, or by any
information storage or retrieval system, without the prior written permission of the
copyright owner and the publisher.
Where trademarked names appear in this book, we use the names in an editorial fashion
and to the benefit of the trademark owner, with no intention of infringement of trademark.
This book is distributed globally.

The information in this book is distributed on an as is basis, without warranty. Although
every precaution has been taken in the preparation of this book, neither the authors or its
publisher shall have any liability to any person or entity with respect to any loss or
damage caused or alleged to be caused directly or indirectly by the information in this
book.
All trademarks are property of their respective owners.

First Printing: 2016
Suntimebox Publishing - www.suntimebox.com

Dedication

This book is dedicated to The Ulchira Childrens Fund and John St. Julien for helping others. While we sit here learning
about programming, computers and the Internet, please remember that there are others in the world with greater needs
than our own.
Please visit http://uchirachildrensfund.org/ and help in any way you can.

Contents

Preface

Chapter 1 - The Beginning of the Raspberry Pi


Chapter 2 - The Internet of Things
Chapter 3 - Introducing Windows 10 Core IoT
Chapter 4 - Setting up the Raspberry Pi 2
Chapter 5 - Booting Windows 10 IoT Core
Chapter 6 - Using Windows 10 IoT Core
Chapter 7 - IoT Core Commands
Chapter 8 - Programming & Deploying Code

Preface

I would like to thank the creators of the Raspberry Pi and the open source community for contributing to such a
wonderful collaborative device. Microsoft have to take some credit for their insight into creating Windows 10 IoT
Core. I would also like to thank and my family without whose help and dedication this book would never have been
completed.

Conventions used in this book



This book will contain icons that are used to draw your attention and highlight important. For example the icon below it
used to highlight important information.

The Raspberry Pi is available in many versions each with varying degrees


of capabilities.



The icon below is used to highlight information that is worth noting down as this will be used frequently and is of
significant importance.

The Raspberry Pi is available in many versions each with varying degrees


of capabilities.



Throughout this book you will come across italic text. This indicated that a command
needs to be typed. For example, enter the following command at the prompt.

C:\> ipconfig

This should be entered without the C:\>.

Only ipconfig should be typed.

Chapter 1
The Beginning of the Raspberry Pi
The Raspberry Pi has caused a media frenzy in recent years and is currently leading a
trend in the computer industry but what it is it and what can it do? You already have some
idea of what the Raspberry Pi is due to the fact that you are reading this but just to clarify
the Raspberry Pi 2 is a low cost computer that has the ability to be used as a general
computer or it can be embedded into another device. It is very small, approximately the
size of a credit card, very powerful and has the ability to playback high quality movies,
process audio and play 3D games.

All this is done using very low power consumption. Since the Raspberry Pis inception it
has gone through a number of changes, versions and revisions. The current version is the
Raspberry Pi 2 Model B. This model performs the same functions as a laptop or PC
including creating word processing documents, creating music, browsing the internet,
creating spreadsheets, writing programs, creating web sites, watching movies and even
playing complex games. All this for only approximately $35.

The Raspberry Pi 2 also has the capability to communicate with the outside world by
allowing it to be connected to home automation systems, sensors, musical devices, robots,
displays, cameras, and more.

This is what makes the Raspberry Pi 2 so versatile because it can be made aware of the
surrounding devices and can communicate with them. It can send and receive data and
take action based on external input without any user interaction. Before we get into the
details of how it works we must first explain the origins.


THE RASPBERRY PI
IDEA BEGAN BACK IN 2006



The Raspberry Pi originated back in 2006 at Cambridge University when Eben Upton,
Rob Mullins, Alan Mycroft and Jack Lung became concerned with the decline of skills in
A level students applying for Computer Science courses. During the 1980s and 1990s
most students applying for Computer Science courses where enthusiastic hobbyist with a

passion for computers and programming.



Most students already had an in depth knowledge of computers before applying for these
courses but during the 2000s, students applying where no longer programmers or
enthusiasts but instead only had a limited amount of knowledge in computers. Most of
these students only had knowledge of using Microsoft office products with some very
basic web knowledge.

Unfortunately the education system had reinforced this decline by only teaching Microsoft
Windows at school with particular focus on office products. This was only educating
students to become basic administrators and personal assistants. Students were not
learning about computers but instead they had became basic users of computers.

During this time there was a rise in home computer consoles such as the Playstation 3 and
the XBox console. These consoles submerged children into games and removed any
interface into the system which would enable them to learn about it. The affect of this was
that children would only become a simple user of the technology.

Although these games fired the imagination of millions it wasnt easy to learn how these
game have been created, at least not by purchasing a console. The gaming console
companies also put many obstacles in the way of learning how to create applications and
games and most people especially children could not afford the development costs or the
prices of the courses.

A generation of children were instantly frozen out of learning. With this in mind the team
got together and decided to change the situation.

The team decided to think back to what had sparked their passion for computers and the
pre year 2000 generation. This was the home computer, specifically the Commodore 64,
Amiga, Atari 800XL, Atari ST and the BBC Micro. These computers sparked the
curiosity of children and led them to explore new things.

They had to come up with something that would create as much interest that the older 8bit and 16-bit computers did during the 80s and 90s. Computers back in those days
allowed a user to explore and experiment with it with the knowledge that you could not
break it. If something went wrong with the computer you would just turn it off and turn it
back on.

The first thing that computers did back then was to put you into a programming
environment which forced the user to learn something about it before you can start using
it. This made the whole experience fun because each day you would learn something new
until you had mastered most of the operating system and the features of the computer.
This was seen as the key and the idea of the Raspberry Pi was born.

During 2006 to 2008 a number of prototypes had been designed which would eventually
lead to the Raspberry Pi. At this time computer processors had became faster, smaller,
more powerful and cheaper. The rise of mobile phones had stimulated this market which
allowed the team to look at incorporating these processors.

By now Eben was a computer chip architect at Broadcom and had also teamed up with
Pete Lomas and David Braben. David Braben was known to many programmers and
computer enthusiasts because he had pioneered the computer games industry during the
1980s with his game Elite. The decision was made to create a Raspberry Pi Foundation
that would spearhead the Raspberry Pi.


FEBRUARY 19th, 2012
THE RASPBERRY PI IS LAUNCHED.



Approximately three years later the Raspberry Pi Model B entered mass production and
was sold under license to a limited number of hardware manufacturers. During the next
two years over 2 million Raspberry Pi devices had been sold. The Raspberry Pi had
started a learning revolution that computer enthusiastic and children from all around the
world embraced. A global community was born which allowed users to hack the device,
write programs, create music and embed the device in hardware that was never thought
possible. The most promising of all this was that everyone shared their knowledge and
each user improved on this knowledge. A complete online knowledge recycling learning
environment had taken place.


FEBRURY 18th, 2015
OVER 5 MILLION RASPBERRY PI DEVICES SOLD.


This concept is not a new one and is in fact based on something called Open Source.

Open Source is a means of creating something without limitations or restrictions and
sharing it for free so that it can be freely distributed. For example a program with its
source code on how it was created can be shared freely so that others can learn from it,
modify it without restrictions and pass it on without the fear of infringing any copyright
laws. Anyone is allowed to re-release this modified code and program to others so that
they can continue to share and pass on knowledge. The Raspberry Pi was built on open
source technology so it was natural that many open source programs and programmers
would start using the Raspberry Pi.


APRIL 2015, MICROSOFT RELEASE WINDOWS 10 IoT PREVIEW.



Microsoft take a slightly obscure slant on open source and while some of their software is
available to download for free, it is not always free to distribute due to their proprietary
nature. Be sure to check the Windows 10 IoT Core web site for more information this.

A user can now learn to program and understand computers without spending hundreds of
dollars. The fact that the Raspberry Pi is so cheap has enabled a community of
developers, enthusiasts, programmers and hackers to share information so everyone can
benefit. Up until now most Raspberry Pis used some form of GNU/Linux operating
system with RISC OS being one of the only non GNU/Linux distributions.

With the announcement of Microsoft looking towards supporting the Raspberry Pi 2, they
have brought their own unique flavour of operating system. Most users are already
familiar with Windows based operating systems so the learning curve to using Windows
on the Raspberry Pi 2 might be little different but you will need to familiarise yourself
with the command line interface and Windows commands.

The Raspberry Pi Foundation and Microsoft have teamed up together to promote the
Raspberry Pi 2 and the Microsoft Windows 10 IoT Core operating system. This will

extend the reach of the Raspberry Pi 2 to users who have only been Windows PC based
users and therefore allowing communities of developers, programmers, engineers, and
hackers to experience the Raspberry Pi 2 and IoT.


FEBRUARY 2nd, 2015
RASPBERRY PI 2
WITH 1GB RAM RELEASED.

Summary
This chapter explored what the Raspberry Pi can achieve and the reason why the
Raspberry Pi came into existence. We took a quick tour of the history of the Raspberry Pi
and the foundation that took it to where it is today. We examined the capabilities of what
can be done with the Raspberry Pi and with the introduction of Microsofts Windows 10,
the whole Raspberry Pi community & Windows communities will continue to grow and
learn together. You also learned that the Raspberry Pi was built on open source meaning
that the software is free to be shared and modified without restriction and the free from the
fear of infringing any copyright.

Chapter 2
The Internet of Things

The IoT or the Internet of Things is a giant network of connected devices that range from
phones, wearable devices, washing machines, coffee makers to home automated systems.
These devices are connected to the internet and are aware of other connected devices
around them. The IoT also includes smaller device aware objects that make up a larger
collective such as car components, networked traffic lights, power grids etc which make
up an entire connected city.

Traffic lights for example can automatically inform engineers that a fault has occurred and
the lights can be automatically scheduled for maintenance. The car components for
example can be aware of each other while providing the driver with a status updates of
fuel, tyre pressure, safety updates etc. At the same time the car can inform the dealership
or a garage that the car needs a service or a component needs replacing. These devices are
sometimes referred to as Smart Objects.


It is estimated that by 2020 there will be more than 26 billion connected devices which
will have a major impact on our lives. The future impact of this is that almost all devices
will be connected. Imaging that your coffee machine is low on coffee beans and because
it is an IoT device that is connected to the internet it can automatically order itself some
beans from your favourite supplier.

This interconnection will bring in a new era which brings with it new terminology. One of
those terms is labelled Big Data. This means that each of these devices will produce a
vast amount of data which will increase the traffic on the internet immensely. Some of
this data will need to be stored so it can be analysed and acted upon and some of this data
will be used by other embedded devices for their input. Based on this input another device
can take action or send out further data to another IoT device.

Currently some TVs have this already built in. Smart TVs for example have the
capability to go online and stream movies and apps directly to the TV. They can even
update themselves to include additional functions. The Internet of Things will be able to
cover a range of areas including healthcare, manufacturing, environmental monitoring,
space activity monitoring, media, energy management, transport and other small and large
scale frameworks.

Google Chromecast and the Amazon Firestick are examples of an IoT device. These
devices extend the capabilities of older TVs which are not internet aware by allowing the
TV to stream movies and music directly to your TV. The Raspberry Pi 2 can be thought of
as an IoT device and yet it still is a fully working computer.

The Cloud

It is impossible to talk about the IoT without mentioning the cloud and its role. The cloud
is currently the most talked about topic in recent years but what is it? The cloud is built on
existing technologies during the last decade but it is only the increase in internet speeds
and cost reduction that it is now at the forefront of things. It can be thought of as a virtual
resource of IT hardware and software that exists on the internet that gives you 24/7 access
to your resources across the globe. The benefits of cloud computing is that it allows users
and businesses to consume shared computing resources and storage on the fly. IT
administrators and users are no longer required to purchase hardware, maintain hardware
or even buy software. A user can simply sign up to a cloud provider and just start using
the resources.

If a user needs to increase storage space, they simply pay for the extra storage and when
they no longer need it they can just reduce the size. Better still when the user no longer
requires the resources they just terminate the resources and no further payment is taken.
This creates a pay as you go model or software as a service model that delivers services
based on the users demand. This subscription model works well with the internet of
things and the cloud.

A user would traditionally purchase a 1TB hard drive but the problem with this scenario is
that they are limited to just 1TB plus you have an upfront cost and the technology can
rapidly go out of date. To increase the size of the storage the user would need to purchase
another hard drive and then maintain or replace any hardware failures. With cloud storage
a user can simply click a checkbox or enter their required parameters and the size is
increased and they are charged accordingly.

Cloud computing offers flexibility at a low cost price.


The same scenario applies to operating systems and servers. A user can select their
hardware requirements, select the operating system and pay a monthly fee. In most cases
this will be up and running in minutes. It is also scalable so if you require 1 or a 1000
servers then this can be done from your own desktop even though the servers may exist in
Melbourne, Australia, Ireland or the East coast of the USA.

There are no upfront costs and in most cases no long term commitments. You only pay for
what you use. All the security has been taken care of for you so there is no need to
purchase expensive firewalls. The cloud providers handle all this for you so you can
concentrate on your application or business.

Some of the well known cloud providers that are leading the way are Amazon Web
Services, Google Cloud Platform, Microsoft Cloud, IBM, Cisco, HP, and Openstack.

Amazon are currently offering 12 months free on their cloud platform which is called
Amazon Web Services. This will allow you to take advantage of their services with some
time limit restrictions. Amazon Web Services allow you to try their Amazon EC2 services
which is their virtual hardware in the cloud. Amazon EC2 stands for Amazon Elastic
Cloud and they define it as a web service that provides resizable compute capacity. This
means that you can select your hardware, select the memory capacity, storage size and the
operating system. All you need to do now it boot this machine up and start working on it.
When you are done you can shutdown the server and terminate it.

The start up costs in cloud make it affordable for any company to compete
with larger businesses


This type of scenario will only cost pennies in some cases depending on memory capacity,
storage space, bandwidth use and other factors that will determine costs.

The screen shot below is from the Amazon Web Services console. It shows a list of
categories & services including

Compute services
Storage & delivery
Databases
Networking
Developer tools
Management tools
Security
Analytics
Mobile services
Applications services
Enterprise applications

That is quite an extensive list of categories that are available and each of these categories
list a vast number of services.











A recent rival to Amazon whom may well be a contender for top spot in the cloud
computing battlefield in the future is Scaleway. Scaleway offers a cloud platform that can
reproduce cloud features directly on hardware.

This means that whereas some companies use virtualisation, Scaleway offer true dedicated
hardware devices using IaaS (Infrastructure as a Service). Scaleway use bare metal
servers which is the term used for a computer or server without an operating system.


IaaS is cloud computing that provides virtualised computing resources over the internet.



With all this talk of virtualisation in the cloud I should explain what virtualisation is.

Virtualisation
Virtualisation is a method of using a computers existing architecture and resources but it
is still capable of functioning regardless of the physical architectural layout. For example,
on your existing machine which we will call the host, is capable of running Windows 10
and Ubuntu at the same time in a virtualised environment even though the host computer
is running the Mac OSX operating system.

Each virtualised operating system appears to have its own isolated CPU, RAM, storage,
network devices and operating system without causing any damage to the other. Each
virtualised operating system is running inside its own self contained box which appears to
any other operating system as a physical machine.

The screenshot below demonstrates the use of multiple operating systems using Oracle
VM VirtualBox from Oracle corporation.



The advantages of virtualisation are
that the virtual operating system is

Easily backed up
It is portable
Is isolated from other operating systems
Each is independent of the hardware that they are running on
Easily restored in minutes
If you have a catastrophic failure of a virtual operating system then the reinstall process is
quick and painless.

However there is a major disadvantage to this utopia. If the host machine suffers a
hardware failure then like a house of cards it will all come crashing down rendering every
virtualised operating useless.

Remember that when using virtualisation you are sharing the physical resources of the
host with the virtual operating systems and the hosts.

Now that virtualisation has been explained we will take a look at some of the latest
technology to IoT and cloud computing.

Project Brillo & Google Weave


Googles latest offering to the IoT is the Project Brillo and Google Weave. Brillo will be
Googles primary backbone for connecting the IoT including your home to the internet.
Google want you to use smart fridges, smart locks and even smart lighting in your homes.
In essence Brillo is an extension of the existing Android platform but will be packaged
up in a much simpler and stripped down form.


Like other IoT platforms, Brillo will be small, very powerful and will be intelligent
enough to communicate with devices around it as well as remote devices across the world.
Most devices will be able to be controlled from your phone so if you want to dim the
lights, simply slide the icon that controls the lights to the left. This sounds like the future
will be bright but as with all technology the question arises, how secure is this going to
be?

Google take security very seriously with multiple ways to authenticate with existing email
and drive services but with IoT, things become a little more serious because these devices
are embedded in our homes.

You wouldnt want someone in France turning your music on and your fridge off at 1:00
am in the morning so Google are making it imperative that security is at the top of their
agenda. So where does Weave fit into all this?

Weave is the language that will be used to talk to all devices supporting Brillo. This
language will allow Weave to become the standard language between these devices. The
infrastructure of this whole setup will require Brillo devices to communicate with the
cloud as well as your phone sending a receiving data from the cloud.
ZigBee is a lesser known visitor to the IoT arena but may well be installed and functioning
in your home without you even knowing. ZigBee is a wireless language that devices can
use to communicate and connect to each other. ZigBee offer a low cost, highly reliable
large networks which are optimized for low power consumption. The beauty of these
devices is that many are self configuring and self healing devices which also have the
capability to use green power instead of using mains power. The major players are
already making use of the IoT such as Samsung with their SmartThings range. These
include home sensors which can trigger alarms when a door is opened. You will be
notified on your phone when such events occur or you can notify a group of people.

Summary
During this chapter you have explored the basic concept of the Internet of things or IoT for
short. You have an understanding of how these smart objects can connect to each other
and send and receive data. These devices can store or take action based on this input. The
cloud along with how businesses can take advantage of this was explained. We also
looked at near future developments going on in the cloud and we concluded with a list of

cloud companies that are leading the way in cloud computing.


Chapter 3
Introducing Windows 10 Core IoT

The first step to installing Windows IoT onto a Raspberry Pi 2 is to download the image
and write it to the microSD card. When you have done this you will be able to boot up the
Pi and start using the Microsoft Windows 10 IoT operating system. Before taking the
following steps we will need to clarify some prerequisites.

Windows 10 has been designed to deliver a personal computing experience that has many
of the same features across most devices. This means that if you learn the home desktop
edition then you will already have the knowledge to use the mobile edition or education
edition. Each edition has been optimized for each device so that Windows 10 can take
advantage of memory, disk access and the graphics capability of that device. Windows 10
will be available for PCs, phones, tablets, Xbox One, mobiles device, surface hub and
Microsoft Hololens.

Windows 10 can also power the Internet of Things which can include washing machines,
lights, media systems and car systems. The Windows 10 experience will look and feel the
same across all devices making it universal and familiar to any user. One of the main goals
of Windows 10 is to make it available as a service. This means that software and content
will be delivered to your device as and when you demand the service. This is much the
same way as Spotify and Netflix deliver their content.

Windows 10 Editions

To begin with we will need to have a quick review of the Windows 10 editions available
and their various capabilities. Although the Raspberry Pi edition will not have the
complete feature set of Windows 10 it will utilise many of the features available for the
mobile edition. Here is a brief explanation of the various editions available.

Windows 10 Home

Windows 10 Home is targeted at the home user using a PC, laptop, tablets and 2 in 1s.
This edition is primarily focused on gaming, media, and general home user desktop
actions. Microsoft suggest that by using the home edition a user will be more productive
and can complete personal projects in a fraction of the time. Cortana is available for the
Windows 10 home edition which is a voice activated digital assistant that can keep track
of your appointments, calendar events and reminders.

This edition also features face recognition, iris scanning and fingerprint login which is
branded as Windows Hello. The usual utilities and applications are available including
music, video, photos, email, calendar and maps.

This edition also features the Xbox gaming experience which is being integrated into the
whole windows 10 experience which. This will allow a user to play their Xbox One
games from any Windows 10 PC.

Windows 10 Pro

This edition is built upon the features of the Windows 10 home edition but contains
additional features for business use. It has file protection for sensitive business data,
business applications, and support for remote access. It also has cloud technology built
into it so that business users can take advantage of the Microsoft Cloud services.

Windows 10 Mobile

The mobile edition is designed for a smaller, mobile, and touch-centric devices including
smart phone and tablets. It offers mobile productivity, security and management features
which can been seen as an extension to the mobile office worker.

Windows 10 Enterprise

The enterprise edition contains advanced features while adding to the pro edition of
Windows 10. The target audience for the enterprise edition is for medium to large sized
business organisations that have the added threat of security breaches. It therefore comes
with additional options for securing and locking down Windows 10.

Windows 10 Mobile Enterprise


The mobile enterprise edition is designed to add even more flexibility to the mobile
business worker. This version also has updated security options designed to keep the
business user safe while travelling.

Windows 10 Education

Microsoft hold education as one of their priorities and therefore do not want to leave the
education sector out of computing. It has been designed to meet the needs of schools and
their staff with students in mind.

Windows 10 Desktop

If you are already familiar with Windows 7 or 8 then learning Windows 10 will be
extremely fast. If you are new to the Windows operating then you also have the advantage
of not being held back by previous expectations of Windows.

Windows 10 Enterprise 2015 LTSB


This edition is known as Long Term Servicing Branch and is much like the enterprise
edition but gives companies greater control on updates. It only features a minimalistic
version of Windows 10 and therefore does not contain applications such as Edge, Cortana,
Windows player etc.

K and KN Editions
These Windows 10 editions have been designed for Europe and South Korea. The N
edition stands for Not with Media Player and the KN edition is for South Korea (KN)
which also does not contain the media player. The edition is in response to a European
commission rule back in 2004 that states that Microsoft are required to supply an edition
without the media player being tied into the operating system.

Windows 10 IoT Core


The IoT edition is used to power extremely small devices. These devices contain a very
small footprint so that the size of the operating system and the memory is kept to an
absolute minimum making the operating system run very efficiently. Windows 10 IoT
Core is the edition that we will be installing onto the Raspberry Pi 2. This version is

compatible with most USB devices including the standard USB mouse, keyboard, external
flash drives and external USB hard drives but Microsoft have extended this to make their
wired and wireless XBox 360 controllers compatible. Bluetooth and wireless devices are
also supported.

You will need the following to complete the installation.

A microSD card, preferably a class 4 or better, a PC or laptop that has a microSD card
reader which must also be running an edition of Windows 10 and the Windows 10 IoT
Core image. Microsoft have supplied a Raspberry Pi 2 ISO which you will use to write to
the microSD card. Carry out the following instructions on your Windows 10 PC or laptop.

The easiest way to install the operating is to use the Windows 10 IoT Core
Dashboard


You have a number of options when it comes to installing Windows 10 IoT Core but the
best option is to use the Windows 10 IoT Dashboard. The dashboard will allow you to
select a hardware device, in this case the Raspberry Pi 2 and it will download and install
Windows 10 IoT core. You can also use the dashboard to install the operating system onto
another board such as Minnowboard MAX. We will only cover installing Windows 10
IoT Core onto a Raspberry Pi.

Now visit the following web site


https://ms-iot.gitbug.io/content/en-US/GetSTarted.htm

and click on the Get Windows 10 IoT Core Dashboard.

Make sure you are downloading this file on a Windows 10 PC. Run the executable file
that has been downloaded.

Click install when the security prompt appears.

The dashboard will appear with a number of options but the option that concerns us is the
Set up a new device option.

Click on this and accept the default settings.

Insert your SD card into your computer and the dashboard will recognise that it has
been inserted.

Check the license agreement check box.

Click on the Download and Install box.

When the download has finished you can safely eject the SD card ready for the next step.
There is an alternative option to install the operating system but it is lengthy process
compared to what you have just completed. Nevertheless, I will explain the process in
case the above didnt work for you.

1. Download the Raspberry Pi 2 IoT from the Microsoft Download Center.

2. Double click on the Windows_10_IoT_Core_Rpi2 and Windows 10 will
automatically mount the iso.

3. Install the Windows_10_IoT_Core_Rpi2.msi. When this has finished installing you


will find that number of files and folders have been created in C:\Program
Files\Microsoft IoT.

4. Go to the Windows start menu and in the search box enter WindowsIoTImageHelper
and run the application.

5. Insert the microSD card into the your reader and click on the Refresh button.

6. Click on the WindowsIoTHelper Desktop application.


7. Select the SD card drive letter if it hasnt already done so.

8. Select the flash.ffu image by clicking browse and locating the file in C:\Program
Files\Microsoft IoT\FFU\RaspberryPi2

9. Click the Flash button.

When it has completed successfully, right click on the Safely Remove Hardware icon in
your task tray and select the SD card reader. Make sure you perform this function as this
can corrupt the contents that you have just written.

If you prefer to be more hands on and are quite comfortable using the
command line then you can follow the instructions below. The result will
be the same as the above so you can select either method.


The Alternative Method



1. Sign up to the Microsoft Connect platform which will allow you access to download
the Windows 10 IoT image. You are required to have a microsoft account. If you
already have one then you can sign in otherwise just sign up for an account.

2. Download the Windows 10 IoT image from the following location.
https://connect.microsoft.com/windowsembeddedIoT/Downloads

3. Extract the contents of the zip file and make a copy of the Flash.ffu file.

4. Insert the SD card into your PC or Laptops SD card reader.

5. Open the administrator command prompt by clicking on the Start button and enter cmd
or hold down the Windows Key and press X. Right click on the command prompt and
select Run as administrator. Go to the folder that contains the file flash.ffu

6. Enter the following commands which will display the disk number of the SD card.
Make a note of the disk number for the SD card.
diskpart
list disk
exit
At the prompt enter the following commands but make sure you replace the X with the
SD card drive number.
7. Enter the following command
dism.exe /Apply-Image /ImageFile:flash.ffu /ApplyDrive:\.\PhysicalDriveX
/SkipPlatformCheck

8. Remove the SD card by clicking on the Safely Remove Hardware icon on the taskbar
and select the SD Card reader. Make sure you perform this step otherwise the SD card
can become corrupted.

Summary
In this chapter we took a high level overview on the available editions of Windows 10 that
Microsoft have produced. These include editions that are targeted towards the home user
PC and laptop market, a mobile edition for phone and tablets, an education edition, a
business edition and the IoT edition aimed at small devices such as the Raspberry Pi 2.
With so many editions available it can be difficult to decide between them but the only
edition that this book will concentrate on is the IoT Core Edition. You also learned how to
write the Windows 10 IoT Core ISO to the microSD card so that you are ready to start
using the operating system.

With such a plethora of editions it can be daunting but Microsoft do an honourable job of
deciphering the different editions on their web site.

Chapter 4
Setting up the Raspberry Pi 2

Before we dive into setting up the Raspberry Pi 2 we should first take a quick look at the
components that make up the hardware. The Raspberry Pi 2 is equipped with a Quad Core
ARM Cortex-A7 CPU processor which is at the heart of the Raspberry Pi 2. The purpose
of this processor is to carry out instructions and process the information it receives. It
does this by performing basic arithmetic, logical decision making and input and output
processes.

This processor is manufactured by the UK based company ARM. This ARM processor
runs at a speed of 900MHz which is very fast considering the size of the processor and its
low power consumption. The ARM company specialise in fast, small, efficient and
powerful processors. The processor in the Raspberry Pi 2 is the same type of processor
that you will find in some entry level phones, tablet and wearable devices.

The Cortex-A7 processor can also be found in routers and other business network
infrastructure devices and more recently it has been used with the Internet of Things (IoT)
devices.

Looking at the image below you can see the processor located just to the left of the center
of the device. (1)


The main components located on the Raspberry Pi 2 board are:

1. The Quad Core ARM Cortex-A7 CPU running at 900MHz which processes an amazing
amount of data at high speeds.

2. This is where the memory is located. Its memory totals 1GB but is shared with the
GPU (Graphics Processing Unit). If you are using intense 3D graphics then you can
allocate more memory to the GPU than the CPU.

3. The GPU (Graphics Processing Unit) is used to processes multimedia and calculate
high intensity graphics.

4. 4 x 2.0 USB ports which can be used to plug in your mouse, keyboard, wi-fi adapters,
bluetooth devices or external media.

5. 1 x Ethernet port running up to 100Mbps. This is used if you want to use a hardwired
network connection.

6. Output on the Raspberry Pi 2 can either be via a TV or monitor. Most modern TVs and
monitors use HDMI. Use an HDMI cable to connect it to a monitor or TV.

7. This is the audio/video connection which uses a 3.5mm jack.

8. These pins 40 in total are used to connect the Raspberry Pi 2 to the physical outside
world. This is almost limitless and can be anything from a scanner, a printer, a robot or
sensors.

9. The Camera Interface is used if you wish to connect a camera. You will need a 15 pin
MIPI connector.

10. The Display Interface (DSI) port is used if you wish to use a touch screen display.

11. This is the location of the micro usb power adapter.


12. These are the LED lights which are used when power is being supplied to the
Raspberry Pi or when there is network or SD card activity.

You need a number of additional hardware components in order to connect your Raspberry
Pi 2. These include a power supply, a CAT 5/5e/6 network cable or a Wi-Fi adapter, a
USB keyboard and mouse and an HDMI cable. We will be using the HDMI connection
for audio capabilities and to keep the setup as simple as possible.
Lets just review the extra peripherals required in order for the Pi to function.

1x Power supply. A micro USB power supply that can supply at least 600mA at 5V. If
you own a Google Nexus or Samsung phone then it is most likely that your charger will be
able to power the Raspberry Pi but be sure to check with the manufacturer.
1x Micro SD card class 4 but class 10 also works.


1x HDMI cable.

1x USB wired keyboard.


1x USB wired mouse.

1x Network cable.

1 x Compatible Raspberry Pi 2 Wi-Fi adapter

The Setup

Slide in the microSD card into the card reader slot which is located on the
underside of the Raspberry Pi 2.

Plug in the USB mouse and keyboard.


Plug in the HDMI connection and make sure the other end is connected to your
monitor/TV.

Plug in the Network cable or the Wi-Fi Adapter.


Finally plug in the power adapter.


The final completed setup will look like the image below.

One small oddity about the Raspberry Pi 2 is that it does not have an on/off switch. The
only way to power it on and off is to remove or switch off the power from the mains.

Summary

You should have a greater understanding of how the different components on the
Raspberry Pi 2 are used. You also know how to connect the Raspberry Pi 2 together and
you are aware that you need to use a micro USB power supply that requires at least
600mA at 5V in order to power it. Remember that to power up the Raspberry Pi 2 you
only need to plug in the power supply and turn the power on from the source. There is no
on and off power switch on the Raspberry Pi 2.

Chapter 5
Booting Windows 10 IoT Core

Make sure you have completed the steps in the previous chapter and make sure that the
Raspberry Pi 2 is connected. When the Raspberry Pi 2 has powered up you will be
prompted with a Windows 10 IoT screen.

When Windows 10 IoT Core boots for the first time it will take a little longer than usual
because Windows will set some first time configuration options. After a few minutes you
will be presented with a Welcome to Windows 10 IoT welcome screen. Select your
country and continue. After a few minutes your will see a message regarding some basic
configuration.








Windows 10 will automatically configure most settings for you so be patient and let the
configuration complete. When Windows 10 IoT has been installed you are presented with
the following display.

This screen displays some information about the device including the device name, the
network type and IP address. Make a note of the IP address as you will need this later
when we connect to the Raspberry Pi 2 remotely but you will also be able to connect using
the device name. In this case the device name is called minwinpc.

The device info button located at the top left of the screen is the default Windows 10 IoT
screen with a general overview of connected devices and networking settings. Next to this
is a Tutorials button that provides further information on getting more out of Windows IoT
Core. On the right side of the default screen you will find the current time followed by the
settings button. Click on the settings buttons and you can modify your language and
Network & Wi-Fi settings.

Setting up a Wi-Fi connection



Using a wired connection can be inconvenient because your Raspberry Pi 2 needs to be in
close proximity to your router. The simplest solution to overcome this is to make your
Raspberry Pi 2 wireless. To set up Wi-Fi on you Windows 10 IoT and your Raspberry Pi
2 you will first need to obtain a compatible wireless dongle. You can purchase the official
Raspberry Pi Wi-Fi dongle from Amazon or by clicking the image below.
There are a number of different approaches available when setting up your wireless. We
will start with the simplest approach and then explore the various ways to connect
Windows 10.

The Easy Wi-Fi option

1. Insert your Wi-Fi dongle into the USB port on your Raspberry Pi 2 and boot up your
device. You will be presented with a Welcome screen that contains your wireless networks
available.

2. Select your Wi-Fi network and enter your wireless network credentials and click
connect. You will now have a wireless connection.

The WiFi & Network Settings


Your Windows 10 IoT Core home screen allows you to configure your wireless network settings.


1. Click on the gear settings icon and select Network & Wi-Fi on the left.


2. Select the Wi-Fi that you want to connect to and enter your network credentials.


3. Check the Connect Automatically box if you want to connect your device to this network each time.

Web based Headless Wireless Setup



If you are using a headless Raspberry Pi setup and you want to connect using a wireless
network then you will need to use the web based option. Before you can continue, you
will need to make sure that your Raspberry Pi 2 is already hardwired to a network.

1. Browse to the name or IP address of your device and enter the Administrator username
and password.

2. Select the networking menu and a list of available wireless networks will appear.

3. Select the network that you want to connect to and click the Connect button.

Connecting Remotely

When you installed the IoT Core RPi.iso it installed the Windows IoT Core Image Helper
and a small program for viewing any Windows IoT Core devices on your network. This
program is called Windows IoT Core Watcher and it can be located in your programs menu
on your Windows 10 laptop or PC. It is not essential to run this in order to connect to
your devices just as long as you know the names or IP addresses of the devices. However,
this tool is great for quickly seeing the device information on your network.

Firstly we will connect to the Windows 10 IoT Core instance using PuTTY on a windows
PC. To download PuTTY visit the following web site.
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

PuTTY is a stand alone executable file that you can double click on to run. Double click
on the executable file. When the following image is displayed on your PC enter the IP
address that you noted earlier into the Host Name location.

Your IP address will be different from that above. Enter 22 as the port number into the
port field and make sure the connection type below is selected as SSH. When you initially
connect to your Raspberry Pi 2 you will be presented with a Security Alert message
indicating that the servers host key is not trusted. Select Yes because you trust the
connection that you are connecting to. You will not see this message again unless the IP

on your Raspberry Pi 2 changes.



When you have a successful connection you will see a login as: prompt. Enter
Administrator as the login name and p@ssw0rd as the password. After you have
successfully authenticated you will see a Microsoft message confirming the Windows
version of the remote operating system.
Microsoft Windows [Version 10.0.10138]
Copyright Microsoft Corporation. All rights reserved.
C:\>
The first thing you should do is update your password by entering the following
command.
net user Administrator your-new-password

Just to demonstrate the we are connected to the remote Windows 10 IoT Core we can use
the ipconfig command.
C:\> ipconfig
You will receive something similar to the following output.

Ethernet LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . : fe90::6d01:b518:f514:8a96%17
IPv4 Address . . : 192.168.1.11
Subnet Mask . . : 255.255.255.0
Default Gateway : 192.168.1.1
Now we will reboot the Raspberry Pi 2 using a simple remote shutdown command.

C:\> shutdown /r /t 0
The alternative way to connect to the Raspberry Pi 2 is use the Windows Powershell.

Windows PowerShell is a program and scripting language that will allow commands to be
sent to your Raspberry Pi. These commands will be executed on your Raspberry Pi and
the results will be displayed on your screen. This has been specifically designed to allow
system administration from a remote location to take control of the Raspberry Pi. This
makes it a valuable tool for managing multiple devices in different locations.

In order to access the Raspberry Pi 2 you will need to create a PowerShell session with
your Windows IoT core device by creating a trust relationship between your PC and the
device. Start Windows PowerShell on the local PC by locating the start menu and in the
search location enter powershell. When Windows PowerShell appears in the list, right
click on the name and select Run as administrator.

The Windows PowerShell console will appear. Enter the following command to start the
Windows Remote service.
c:\net start WinRM

Next we will need to add the Raspberry Pi device to the list of trusted devices. Replace
the DEVICE NAME with your device name or the ip address that has been allocated to it.


C:\Set-Item WSMan:\localhost\Client\TrustedHosts -value MACHINE-NAME

or
C:\Set-Item WSMan:\localhost\Client\TrustedHosts -value IP ADDRESS

Enter Y to confirm that you wish to add this device to the list of trusted computers.

Windows 10 has been known to cause a Stack overflow error on the PC. If you happen to
receive this error message enter the following

C:\remove module psreadline -force
You are now ready to start the session with your Windows IoT core device. Enter the
following replacing MACHINE NAME with your device name.

Enter-PsSession -ComputerName MACHINE NAME -Credential MACHINE
NAME\Administrator.

When prompted for a password enter
p@assw0rd
Connecting remotely to the Windows IoT 10 core is quite slow and may take up to 30
seconds or more. When you have connected successfully to the Raspberry Pi 2 you will
see an IP address appear before the prompt. This means that you have a remote
connection to the Raspberry Pi WIndows IoT Core device.

Enter the following command

shutdown /r /t 0

This command will restart your Raspberry Pi 2. You will explore the shutdown command
later in more detail.

Summary

You have the knowledge of downloading, installing and booting up Windows 10 IoT core.
You have also created a remote connection to your Raspberry Pi 2 using PuTTY which
allowed you to execute remote commands on the Raspberry Pi 2. You also connected
remotely using a PC running Windows 10 using the Powershell program. You also
executed the shutdown command which rebooted the Raspberry Pi 2. In the following
chapters you will execute various remote commands using the command line so that you
can really get to grips with understanding the inner workings of Windows IoT Core.

Chapter 6
Using Windows 10 IoT Core

Although connecting remotely using the Powershell or PuTTY to your Raspberry Pi 2 is
essential, it might not be efficient to go through those steps every time if you only want to
check on the status of something or quickly reboot it. Microsoft have supplied a Webbased device management web page that provides some basic functionality including
shutdown, reboot, view running applications and basic networking information. You can
also perform general configuration settings from the web based interface which displays
real time information and diagnostics.

Make sure your Raspberry Pi 2 is running and make sure it is connected to your network.
Also make sure that you know the IP address of the device because you will need this to
make the connection.

Open a web browser and enter the IP address of your Raspberry Pi 2 into the url field
followed by 8080 and press enter.

http://192.168.1.100:8080

When prompted for the user name and password enter Administrator for the user name
and p@ssw0rd for the password.

The web based device management page will be displayed. On the left side of the page it
provides access to commonly used actions that you may perform while at the top you have
the essential quick action options including shutdown and reboot. While shutdown,

reboot, feedback and help are self explanatory some of the options on the left need further
investigating.

Apps

The appX manager gives you the ability to install and uninstall programs. If you have
created a program or downloaded a program, you can install it by following the
instructions below.



1. Click Browse and locate the file that ends in .appx.

2. Click certificate and locate the .cer file.

3. Some programs require dependencies, if this is the case select them here or ignore this
and continue.

4. Click on the Deploy button.

Uninstalling a program follows similar steps.

1. Make sure the application is not running by going to the running apps and closing it.

2. Press the Remove button.

Processes
The processes menu displays a list of running processes along with memory and
performance information. To terminate a process simply click on the X.

Performance
The performance option will let you see real time CPU information, memory statistics and
I/O usage.

Devices

The device options will show you all the connected devices.

Networking
The networking information will display IP configuration including the IP address and a
description of the network connection type. You can check to see of your Wi-Fi adapter is
working with your Windows 10 IoT Core device and you also have the ability to switch
between Wi-Fi adapters if you have more than one connected.

EWT
This is used for event tracing. This is used to identify problems with applications when
you are developing programs.

Sharing and uploading files


You will from time to time want to store files and possibly share files with others on your
network or over the internet. The first method will examine FTP to transfer files to and
from your device. Luckily Windows 10 IoT core automatically starts the FTP server when
it is booted so all you need to do is connect to it using the IP address of the Raspberry Pi.
The next step is to download FileZilla. FileZilla is a free open source FTP program that
will allow you to download and upload files. Download FileZilla from the following
URL.
https://filezilla-project.org/
Select the download file for your operating system and follow the installation
instructions. The next step is to add the IP address or the site address of the Raspberry Pi
2.

1. Click on File.

2. Select Site Manager.

3.

4.
5.

6.

7.


The site manager window will open. Enter Raspberry Pi 2 for the site name or
something similar. The site manager will store your FTP sites that you connect to so
that in the future you can quickly connect to previously sites.

Click on the New Site button.

Enter the IP address in the Host field and make sure that the FTP - File Transfer
Protocol is selected from the protocol drop down list. By default FileZilla will use
port 21 so you can leave this blank or if you prefer you can always enter 21 in the port
field.

Enter your Administrator user name in the User field and your password in the
Password field.

Click the Connect button.

On the left side of the window you are presented with files that are local to your computer
and on the right side you can see files that are on your Raspberry Pi 2. To navigate to a
folder on your Raspberry Pi 2 you can simply double click on a folder and the right panel
will refresh with the new folder contents.

To upload a file from your local PC or laptop you can simply right click on the file name
and select Upload from the popup menu. You can monitor the upload progress by viewing
the panel at the bottom. To download a file from your Raspberry Pi 2 move your mouse
over to the right panel which is the remote device, in this case the Raspberry Pi and right
click on a file. Select Download and the file will be downloaded into the current directory

that you have selected locally on the left panel. You can determine the current folder
location by examining the Local Site and Remote site near top of FileZilla.

The alternative to using FileZilla is to use the built in FTP Windows Explorer program.
Open file explorer and enter ftp://192.168.1.100 into address field and press enter.

When prompted, enter your username and password and the explorer window will reveal
the files on the remote Raspberry Pi 2. You can use the FTP explorer window just as you
would any other folder location. To copy a file to the Raspberry Pi 2, simply drag a file
from your local computer to the remote FTP explorer window. To copy a file from the
Raspberry Pi 2 to your local machine simply reverse the process.

If you do not require the FTP server to be running you can stop it via the command line.
If you are connected using PuTTY then you can issue the following command.


C:\Windows\System32>kill ftpd*

If you are connected using Windows PowerShell then you are required to enter a slightly
longer syntax.

kill -processname ftpd*

And then press Y to confirm.

One thing that should be changed is the default location that the FTP server uses. It
dumps the user directly into the root of Windows which isnt really the ideal location. We
can change this by entering the following command.

start C:\Windows\System32\ftpd.exe C:\MyUploads

You will need to change MyUploads to your own a directory that you want to store your
files in. If you connect via FileZilla or Windows explorer you will see that the location
that you set appears as the default folder but this change isnt permanent. In order to set
the default FTP location permanently we first need to edit the startup scripts.

Using Windows explorer on your PC or Laptop enter the following location in the address
bar.

\192.168.1.100\c$\Windows\System32

Replace 192.168.1.100 with your IP address of the remote Raspberry Pi 2.

Right click on the file IoTStartupOnBoot.cmd and select Edit.

Click on the Run button if you are prompted with a security dialog. Notepad or
your default text editor will appear.

Locate the line that reads

start ftpd.exe >nul 2>&1


And change it to

start ftpd.exe C:\MyUploads >nul 2>&1

Now start the FTP server by entering the following commands using PuTTY or Windows
PowerShell.

C:\>start c:\Windows\System32\ftpd.exe

Now use the tlist command to verify that the FTP server is running by examining the list
and looking ftpd.exe.

File sharing
By default file sharing is enabled in Windows 10 IoT which is great because there isnt
anything to configure. Connect to your Raspberry Pi 2 using windows file explorer on
your PC and enter the following into the address bar.
\192.168.1.100\c$

You can now view the files located on your Raspberry Pi 2. If file sharing isnt required
you can enter the following command to stop terminate it.

net stop Server /y

And to start the file sharing enter

net start Server
To prevent Windows 10 IoT from running file sharing at startup you will need to make
some changes to the registry. The Windows registry can be thought of as a database that
stores configuration settings that can be manipulated to modify settings.

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\lanmanserver /v Start /t REG_DWORD /d 0x3


/f

You will receive an operation completed successfully message when the change is
completed.

To enable file sharing again enter the following.

reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\lanmanserver /v Start /t REG_DWORD /d 0x2
/f

Summary
In this chapter we looked at the web based interface that will allow you to manage the
basic settings of Windows 10 IoT including displaying networking and real time
information such as running processes, memory usage and CPU usage. We also looked at
how to install and remove applications before examining some of the other available
options for monitoring the Raspberry Pi 2. We then looked at the various ways of sending
and retrieving files using FileZilla and Windows 10 built in FTP File explorer. We
examined the basic functionality of the FTP Server and also looked at how to share files
on a network. Finally we examined how to edit the startup command script and modify
the registry to start and stop the Windows sharing.

Chapter 7
IoT Core Commands

To get to grips with using Windows 10 IoT Core you will need some basic knowledge of
the commands and their uses. You have already learned quite a few commands from the
previous chapter but we need to dive deeper into Windows 10 syntax. To issue these
commands you will need to use either PuTTY or PowerShell. You have already seen these
tools in action so we wont go into further detail. Using PowerShell or PuTTY is a very
fast and efficient way of sending remote commands to another device. The advantage of
this process is that it does not require the overhead of a desktop environment.

Lets start with some basic commands. You have already used the shutdown command to
restart the Raspberry Pi 2 but we should explain in more detail exactly what is going on
here.

Shutdown and Restart


To restart the Raspberry Pi enter



shutdown /r /t 0

The first part of this command is the word shutdown followed by a forward slash / and the
character r. The forward slash followed by a character is called a flag. A flag is used to
modify the command in some way. In this case it is informing the command that we wish
to reboot the Raspberry Pi. Following this is another flag, /t followed by the number 0.
This /t flag indicates the amount of time required to reboot in minutes. We have specified
a 0 which means immediately. If we were to replace the number 0 with the number 1 then
it will reboot in 1 minute.

To completely shutdown the Raspberry Pi 2 enter

shutdown /s /t 0

This command executes a shutdown command but with a slight difference. We have used
the modified flag, /s. This indicates that it will shut down rather than reboot.

Change your Password


It is always recommended that you change the default password on any device and this is
no exception. To change the Administrator password on Windows 10 IoT Core enter the
following.

net user Administrator YourNewPassword

Replace YourNewPassword with your own.

Create a new user


Create an additional windows 10 user by issuing the following command.



net user YourUserName YourPassword /add
The net user command is used for most user account settings and in this case it is used for
adding a new user because you have used the /add flag. Note that you will need to replace
YourUserName and YourPassword with your own username and password.

Change a user Password


To change the password on an account issue the following command.



SetPassword TheUserName ThePassword TheOldPassword

Dont forget to replace the above username and passwords with your own passwords.

The Hostname
Windows 10 issues your Raspberry Pi 2 with a hostname so that it can be identified on the
network. To identify your hostname enter the following.


hostname

If you need to change this at any time simply enter the following.

SetComputerName NewHostName
Replace NewHostName with your new selected hostname.

The Ping command



The ping command is used to determine if another device is connected to a network
including the Internet. Assuming that a firewall is not rejecting our ping requests on the
remote device we are able to obtain a reply. Enter the following command.

ping 8.8.8.8

Pinging 8.8.8.8 with 32 bytes of data:
Reply from 8.8.8.8: bytes=32 time=707ms TTL=52
Reply from 8.8.8.8: bytes=32 time=706ms TTL=52
Reply from 8.8.8.8: bytes=32 time=705ms TTL=52
Reply from 8.8.8.8: bytes=32 time=704ms TTL=52

Ping statistics for 8.8.8.8:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 704ms, Maximum = 707ms, Average = 705ms

The reply indicates that this device is online and active. The IP address of 8.8.8.8 is
Googles primary DNS server and responds to ping requests. If the server was offline or
protected by a firewall then you would see the following output.

Request timed out.

Request timed out.


Request timed out.
Request timed out.

Ping statistics for 8.8.8.8:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

You can expand on the ping command by using flags to extend its capabilities. Enter the
following.

ping -n 2 8.8.8.8

The -n flag indicates that a finite amount of packets will be sent and the number 2
indicates the number of packets. Incidentally, a packet can be thought of as a small
envelope containing information that the remote computer will examine. In the case
above the Google DNS server examined the packet and responded with a request.

Trace Route
The tracert command is used to trace a packets route across the internet or through a
network. For example to follow the path to UU Nets DNS server enter the following.

tracert 158.43.128.1

Tracing route to cache0002.ns.eu.uu.net [158.43.128.1]
over a maximum of 30 hops:

1 1 ms 4 ms <1 ms 192.168.1.1
2 * * * Request timed out.
3 990 ms 955 ms 1118 ms 11.130.122.9
4 673 ms 678 ms 693 ms 11.130.162.254
5 709 ms * 688 ms 11.11.162.162
.
.

.
17 726 ms 711 ms 729 ms FastEthernet0-0.lnd4eusoesr1.lnd.ops.eu.uu.net
158.43.254.14]
18 908 ms 745 ms 726 ms cache0002.ns.eu.uu.net [158.43.128.1]

Trace complete.

The numbers above indicate each hop along the way that the packet travelled. Finally you
can see the trace completed and ended on hop 18 which is 158.43.128.1.

The Net Stat command


The netstat command is used to inform you of the network status of your device. Enter
the following.

netstat

Your information will appear differently because you will be connected to different
devices but it will look similar to that below.
TCP 192.168.1.11:50589 jow21-in-fff:https ESTABLISHED
TCP 192.168.1.11:50695 mikerq09-in-4:https ESTABLISHED
TCP 192.168.1.11:50907 jillj5-in-01:https ESTABLISHED
TCP 192.168.1.11:51144 HP347137:8080 ESTABLISHED

The first column indicates which protocol is used to communicate with the remote device
followed by the local IP address and port number that your Raspberry Pi 2 is
communicating on. The third column is the remote address and finally the communication
states. The state of the communication can be ESTABLISHED, TIME_WAIT or
CLOSE_WAIT. For more information on netstat or any other Windows 10 IoT core
command enter netstat /? or search the web.

IP Config
The ipconfig command is used to give the user information regarding the network

interfaces. This includes information relating to your IP address, network, default


gateway, DNS servers and IP lease information. Enter the following command.

Wireless LAN adapter Wireless Network Connection:

Connection-specific DNS Suffix . :
Link-local IPv6 Address . . : fe90::6d01:b518:f51 4:8a96%17
IPv4 Address . . : 192.168.1.11
Subnet Mask . . : 255.255.255.0
Default Gateway : 192.168.1.1

Managing Processes
A process is part of a program that is currently being executed at that particular time.
Windows 10 along with many other operating systems are able to run multiple programs at
the same or at least make it look like they are running at the same time. This is achieved
because the operating system allocates time to each process so each program is given
suitable time to run some of its program before it hands control back the operating
system. This happens at such a high speed that we are not able to determine which
program is running and so it appears that everything is happening simultaneously. An
example of this occurs in games where each element of the game takes its turn before
moving on to the next element. For example, move the player, move the enemy, player
fires a weapon and then the program checks to see if the enemy was hit by the player.
None of this is taking place at the same time but appears to be due to its speed of
execution.

To view the running processes enter the following command.

tlist

0 System Process
4 System
891 helloWorld.exe
994 rpi2.exe
356 csrss.exe
424 services.exe

436 lsass.exe
604 svchost.exe
The list of processes are displayed with their unique ID numbers which appear in the first
column followed by the program name. If you wanted to find a process ID without
searching the entire list you could enter

tlist -p helloWorld
891
The number that is displayed on screen is the running process. To find more details on the
running process enter the following.

tlist 891

Below is a snippet of some of the information that is returned

VirtualSize: 21920 KB PeakVirtualSize: 91827 KB
WorkingSetSize: 21633 KB PeakWorkingSetSize: 28991 KB
NumberOfThreads: 5

Some common issues that occur with running processes is that they can appear not to
respond in which case you will have no alternative but to kill the process and shut down
the program. To do this enter the following command followed by the unique id number
that you are terminating.

kill - 891

In our example we have killed the helloWord.exe process. If we wanted to kill the
rpi2.exe process then we would enter

kill -994

Display options

If you need to find out your screen resolution then you can use the SetDisplayResolution
command. Enter


SetDisplayResolution
This will return the width and height of your screen. If you need to adjust the screen
resolution you can always enter the same command followed by the width and height.

SetDisplayResolution 800 600

Headless vs Headed

A headless device is a device that does not have a monitor or TV connected to it but a
headed device is one that has a monitor or TV connected. As an example you may have
written a program that plays music via a stereo or jukebox. The music will be controlled
via a phone so your Raspberry Pi will not require a monitor as it is only accepting
commands from a phone and playing audio. From this point on the only reason you might
want to view settings on your Windows 10 IoT Core device is because you are trying to
troubleshoot it. In headless mode the GUI or output will not be displayed. This saves
processing resources and will allow the Raspberry Pi 2 to perform better.
To view the current setting enter the following command.

C:\> setbootoption.exe

To set your Windows 10 IoT Core device into headless mode enter the following.

C:\> setbootoption.exe headless

You will need to reboot the Raspberry Pi 2 in order to see your change. Enter the
following.

C:\> reboot /r/ t/ 0

To enable headed mode enter the same command followed by headed.

C:\> setbootoption.exe header

And again reboot the Raspberry Pi 2 to see the change.


C:\> shutdown /r/ t/ 0

Setting the Startup Application


To set a Startup Application that will appear every time the Raspberry Pi 2 is booted enter
the following.

C:\>iostartup list TheProgramToRun
Replace TheProgramToRun with the program that you want to run and enter the following
C:\>iotstartup add headed HelloWorld
Setting the startup application is explained in more detail in the next chapter.

Setting the Default Startup Application


Enter the following if you want to revert back to the original default startup application.

C:\> iotstartup add headed DefaultApp

Summary

This chapter guided you through many of the command line options that are available for
Windows 10 IoT Core. You know how to change the default Administrator password,
create new users, perform basic system commands. You also know some basic
networking tools that can be used to determine if other devices are contactable. You also
have an understanding of headless vs headed device and you are aware of how to set start
up applications.

Chapter 8
Programming & Deploying Code

In order to write programs for your Raspberry Pi 2 you will need to use Windows Visual
Studio 2015. Visual Studio 2015 is a programming IDE or Integrated Development
Environment. It has been designed so that programmers and developers can quickly write
code without ever leaving the environment they are in. Some years ago you were required
to write code using a simple text editor like Notepad and then you were required to link
and compile the program before you could run them. These steps required multiple tools,
one for programming, another for compiling and another for linking.
Development IDEs made these steps far easier by implementing all these actions into one
click. Additional features have been added over the years including code completion and
error highlighting. Code completion is a method of the IDE suggesting what the next line
of command may be. This is similar to when you are using Google to search for
something and it makes suggestions based on what you have entered.
Visual studio 2015 has also been designed to work with multiple programming languages
including C++, C#, JavaScript, Python, F#, NodeJS to name a few. This makes
programming easier because you can concentrate on writing your application and
compiling the application will be the same as when using any other programming
language.

The first thing you will need to do is to install Visual Studio 2015 from the Visual Studio
web site.
https://www.visualstudio.com/en-us/downloads
Follow the installation instructions and open visual studio 2015.

Creating an application in C#

We are going to create an empty project, add some code and deploy the application to the
Raspberry Pi 2.

Open Visual Studio 2015 and create a new project by going to the File Menu and select
New Project. On the left side of the screen, expand Templates, Visual C#, Windows and
highlight Windows Universal. Select Blank App (Windows Universal) Visual C#.
In the name field enter HelloWorld. The IoT extension isnt added to projects by default
so we will need to add a reference so that you program can use it.

Select Project and right click on the References entry and select Add Reference. In the
dialog window that appears, navigate your way to Windows -> Extensions -> Windows
IoT Extension SDK and check the box. Click on the OK button to confirm.

Open MainPage.xaml by double clicking on the file in the Solution Explorer window.
Some XML code will appear. Find the tag that reads <Grid> and add the following code.


<Grid Background={ThemeResource ApplicationPageBackgroundThemeBrush}>
<StackPanel HorizontalAlignment=Center VerticalAlignment=Center>
<TextBox x:Name=txtHello Text=Hello World on Windows 10 IoT Core
Margin=10 IsReadOnly=True/>
<Button x:Name=btnSayHello Content=Click Me! Margin=10
HorizontalAlignment=Center/>
</StackPanel>
</Grid>

Now that we have some basic content we will need to add the code that actually makes the
button perform some action when clicked. In the design surface double click on the
button. Visual studio automatically creates the code needed to link this button to a click
action. The magic works here because Visual Studio 2015 added
Click=btnSayHello_Click property to the MainPage.xaml page which is linked to a
method in the code file. A method can be thought of as a function or block of code that
will be executed when called. In this case the method will be called when the button is
clicked. The code for this action has been created in a file called MainPage.xaml.cs.
Open MainPage.xaml.cs and locate the method called btnSayHello_Click.

private void btnSayHello_Click(object sender, RoutedEventArgs e)
{
this.txtHello.Text = Hello World from the Raspberry Pi 2;
}

Notice that this method is called btnSayHello_Click which is the same name allocated to
our button in the MainPage.xaml page.

Next we need to test the application on our local machine to make sure everything in
functioning as expected. Press F5 and the application will execute. Click on the button
and you will see that the text Hello World on Windows 10 IoT Core changes to Hello
World from the Raspberry Pi 2. This works because when the button was clicked it
executed the btnSayHello_Click method which uses the txtHello identifier. Now that it is
identified the code is able to access the Text property to change the text of the txtHello
text.

Before we can deploy our amazing application you will need to set the project target
platform. As the Raspberry Pi 2 is an ARM based device you will need to set the target
device to remote machine and enter the name of the machine.
Click on the Local Machine dropdown list and select Remote Machine. A dialog box will
appear titled Remote Connections. Enter the IP address or the name of your Raspberry Pi
2 device and make sure that the Authentication mode is set to None.
Press F5 to deploy the device and the app should appear on your Raspberry Pi 2. If an
error message appears Unable to connect to Microsoft Visual Studio 2015 remote
debugger (MSVSMONE.EXE) then the remote debugger may not be enabled. This
sometimes happens if it has timed out. If this is the case enter the follow command on the
Raspberry Pi 2 to start it.
schtasks /run /tn StartMsvsmon

This is great. You now have deployed a fully working C# application to your Windows 10
IoT device but we can take this a step further. If you want your application to appear as
soon as the Raspberry Pi 2 is booted as a Startup App, just enter these commands on the
Raspberry Pi 2 device.
iostartup list HelloWorld
The output returned is something similar to the following
Headed : HelloWorld_w82nit0sw96uin!App
The above output is confirming that the application has been correctly installed. Next we
need to actually set the program to run at startup.

C:\> iotstartup add headed HelloWorld


You will see a message explaining that the AppId changed to HelloWorld. This has
confirmed that the startup application will be the HelloWorld app the you have deployed.
Reboot your Raspberry Pi 2 to confirm that this has worked.
To change the startup app to its default settings enter the following

C:\> iotstartup add headed DefaultApp
The response should be similar to that below.
AppId change to DefaultApp_ca5n1891nuxeu!App

Deploying Python Applications on Windows IoT 10 Core


Assuming that you have successfully installed Visual Studio 2015 you can program
applications using Python 3.x and deploy them to Windows 10 IoT Core. If you havent
installed Visual Studio 2015 simply download it and following the instructions to
installing it on Windows 10.

Your first step is to download and install Python 3.x to your local Windows 10 PC or
laptop.
http://www.python.org/downloads
You will also need to download and install Python Tools for Visual Studio 2015 (PTVS).
https://github.com/microsoft/ptvs/releases
Finally you need to download the Python UWP SDK from here.
https://github.com/ms-iot/python/releases/v1.0Alpha
Create a new Python project by selecting File -> New Project and select Template ->
Python -> Windows 10 IoT Core -> Background Application (IoT).

Open the StartupTask.py from the Solution explorer and enter the following.

print(Python 3 programming on the Raspberry Pi 2)



Save the project and right click on the Project node and select Properties. Select the
remote device and confirm. Press F5 to deploy the python application to the Windows 10
IoT Core device. Python can sometimes be a little slow to deploy so allow a few minutes
for the application to appear.

Programming Node.js on the Raspberry Pi 2


We are going to assume that you have already setup and installed Visual Studio 2015 on
your local PC or laptop. When you have done that your next step is to download and
install Node.js for Visual Studio also called NTVS for short. You can download this from
the following location.
https://nodejs.org/download/
Create a new Node.js (Windows Universal Project) by selecting File -> New Project. In
the New Project dialog windows select Templates -> JavaScript and select Node.js. Click
on the Basic Node.js Web Server (Windows Universal) template.
Create the project and you will be presented with a file called server.js. This is the basic
web server template code that NodeJS has created for you.
var http = require(http);
http.createServer(function (req, res) {
res.writeHead(200, { Content-Type: text/plain });
res.end(Hello World\n);
}).listen(1337);
We wont go into detail on how this works but at a basic level what this code does is use a
module that contains web server code. This code gives the programmer access to pre
written methods and one of those methods is createServer. This code creates a server and
listens on port 1337. When a web browser connects to this port the code will respond with
the HTML header information and a line that says Hello World followed by a new line.
Now to deploy the application you will need to go to the Project menu and select
Properties. Enter the IP address of the remote device to deploy to and select the Platform

to be Active (ARM). Press F5 to deploy our Node.js code. Nothing will appear on the
Raspberry Pi 2 because this code creates a web server that will sit in the background
waiting for connections on port 1337.
Open a web browser on your local computer and browse to the IP address followed by the
port number and press enter.
http://192.168.100.1:1337

Summary
This chapter has demonstrated how to create code using Visual Studio 2015 with some of
the most popular languages available to programmers. We create a simple C# application
with some text and a button. When the button was clicked an action occurred. Next you
deployed the C# application to the Windows IoT 10 Core device. You also wrote some
simple helloWorld code using Python and deployed that application. Finally you created a
simple web server using NodeJS.