>> Hi, I'm Richard Lander.
I'm a member of the .NET team.
Today, I'm going to talk to you about how .NET Core can run in
small places like IoT and Raspberry Pi.
So, you can run .NET Core on a Raspberry Pi 2 or 3.
We don't yet support Raspberry Pi 0, but we're working on it.
Most IoT devices support ARM hardware and
often talk to devices like sensors, displays,
and other things .NET Core 2.1 added support for Linux,
ARM32, .NET Core 2.2 added support for ARM32 for Windows.
This time around what .NET Core 3.0 routing
support for ARM64 for Linux,
which you've had a lot of customers ask for.
So .NET Core now has APIs that
enable you to build IoT applications,
specifically programming the hardware pins or
GPIO pins that are available on Raspberry Pi and similar devices.
So, IoT development is a bit different than
client programming or server programming
or Cloud programming because it involves
a combination of software and hardware.
So, you need some basic electronic skills
like creating small circuits,
using resistors, understanding what a load or a ground is.
It's actually not that hard,
I learned this really quickly and you can too.
So one of the tools you can use is a breadboard.
It's really useful for connecting
all the wires together and avoiding making a mess.
Because eventually you're going to
find that if something doesn't work,
and you have to debug
all these cables and a Breadboard helps you do that.
So many IoT devices use serial protocols and they have like
really specific expectations on timing and
the data that's going through and we know it provide APIs,
so that makes that easy.
So speaking of APIs,
we have two NuGet packages that you can use.
One is System.Device.GPIO and
that enables all of the fundamental scenarios that you care about.
Like turning pins on or off or using
specific hardware supportive protocols
like GPIO, SPI and I-squaredC.
The IoT.Device.Bindings package,
exposes higher level APIs that target specific devices.
So this is the one that you're probably going to
want to use because it's much easier.
So, for example, there will be
a specific temperature sensor
and there will be a class for that and all
you need to do is call
specific APIs to get save the temperature or the humidity.
As opposed to needing to know
the very specific pins to use in a particular combination.
System.Ports.Serial,
that's a name-space that we've had for a long time,
actually going all the way back to Dyna Framework.
But until recently, we didn't have support for that on Linux,
only on Windows and we had a bunch of
requests for that so it now works on Linux.
All of this is going on at the dotnet/iot repo.
So please take a look there.
We have people contributing, device bindings,
bug fixes reporting issues
and we'd love to have more people helping us out.
Okay, so let's take a look at what code
looks like for an IoT Application.
This is actually the minimal application for turning
an LED on and off and you can see
right away that I've hard-coded pin 17.
That's the one that I'm actually connected
to, connected the LED to.
What we're going to do is,
we're going to turn that light on for 1,000 milliseconds
and then offer 200 milliseconds and then keep on repeating that.
So you can see we've created a GPIO controller.
That's basically the underlying concept
that owns all of these pins.
Then we're going to be in a while loop and we're
going to run that forever and you can see that
we're riding a high value and then a low
value to that specific pin 17.
You probably noticed that we have
this while true loop that goes on forever.
That's not a common pattern in most,
say server or client programming,
but it's completely the way things work in IoT land.
Let's take a look at an application
that's a little bit more complex.
You can see here that we're operating
over a much larger set of pins.
This is something like, 10 or a dozen and then,
the important part of the application is actually down here.
So you can see that we've created,
this is animating and LED bar and what you can see here is,
we're passing in both the lead time and the dim time.
That's in this case it's 200 milliseconds and 50 milliseconds.
Then we have various animations that
we've created to make these lights do various things.
So, this is just another example of using.NET.
This is regular C# code and you can see that it's really simple
to just cycle through a set of LEDs.
Most of the code here uses this cycle LEDs method that I've
created and it's given a params of a set
of LEDs and then it
just turns them on and off according to this, whatever is needed.
So that just gives you an idea of what the bit larger of
a program looks like than the one we were looking at before.
Okay, so what can you build?
In short, anything.
So.NET is a great option for non real-time scenarios.
If you have a real-time need,
then you probably want to choose something else.
You probably don't even want to choose
even Linux or the Windows operating system
to make those things work.
It is really easy to make lights blink,
write to LCDs and query sensors
for the information that they expose,
including accelerometers and other things.
So, we're building support for LED matrices right
now to enable dashboards and other kinds of displays.
We think that there's a bunch of folks
that probably want to make those work.
We're also building support for CAN bus,
which is a serial protocol that's used for automotive scenarios.
We have some specific customers that are
asking us to build that and we'd love feedback
on what you would like to see supported next because we
found that there are so many different scenarios in the IoT space.
So one of the scenarios that we've started to build,
is support for LED matrices.
So each one of these matrices is a two-dimensional set
of LEDs and here we've [inaudible] for these panels together.
Sitting behind them is a single Raspberry Pi,
running.NET Core that's running an application.
It starts out with just a set of colors being displayed
on the four panels and then we move
to displaying animated text and the time,
which is constantly being updated.
Really we see a lot of potential here
to display any sort of content on these displays.
Were just trying to figure out what are the next steps
on the journey here. How do you get started?
Here we're going to be talking about Raspberry Pi,
but you can use other sorts of devices as well.
So the best place to start is buying a kit from say,
Adafruit or SparkFun and there are
other vendors for this hardware as well.
Download and install.NET Core on your Pi.
You can install the SDK and
actually do development itself on the Pi.
You can also just install the runtime on
the Pi as well, both scenarios work.
And in terms of actually building your application,
you can build it on your desktop machine or
your laptop or you can build it on the Pi as well.
So if you're going to build it on the application on the desktop,
then you deploy the application to the Pi.
I use tools like SSH and SCP,
Secure Shell and Secure Copy.
Other folks use Putty, there's several options.
Or you can, like I said,
just run and build the application on the Pi.
You can debug remotely from Visual Studio or Visual Studio Code.
So I hope you liked that. Let's talk about what's next.
So we need to take the two NuGet packages that we've built,
System.Device.GPIO and IoT.Device.Bindings and
bring those to quality and make stable releases.
We also need to ship .NET Core 3.0,
which you probably expect what we are going to do.
Next for you, get familiar with these APIs,
try them out, learn about hardware programming and
contribute to dotnet/iot and have fun.
There's a lot to learn here,
and we've certainly enjoyed building
this new functionality and we hope you really like it.
[MUSIC]