Introduction To The Internet of Things and Embedded Systems
Introduction To The Internet of Things and Embedded Systems
com/wp-content/uploads/2018/07/2018-SANS-Industrial-IoT-Security-
Survey.pdf
https://www.nytimes.com/2018/10/10/technology/future-internet-of-things.html
Bojanova, I. (2015, March 31). What Makes Up the Internet of Things? Computing Now, IEEEComputer
Society
http://www.computerworld.com/article/2886316/mobile-networks-prep-for-the-internet-of-things.html
http://www.csoonline.com/article/2947477/network-security/security-and-the-internet-of-things-are-we-
repeating-history.html
[MUSIC]
Welcome to Introduction of Programming the Internet of Things and Embedded Systems.
I'm Professor Ian Harris.
I'm a professor in the Department of Computer Science at the University of
California Irvine.
In beautiful Irvine, California.
I got my degree, my PhD from University of California San Diego in 1997 and
before that I got my Bachelors at MIT in 1990?
1990.
I do computer security research.
I do Internet of Things research, specifically building components,
stuff that this course is about.
And I also do work in testing, testing and verification of hardware designs.
[MUSIC]
7. Name the core hardware components most commonly used in IoT devices
Prerequisites
There are no prerequisites for this course.
Readings
In this course, each module will recommend readings correlating with the module content that will enrich your
learning experience. These readings are optional. All the resources required to complete this Specialization are
included.
Each peer assignment will be worth 20% of your final grade. You must earn 80% to achieve a passing score on
each peer review.
Quizzes
At the end of each module you will have an opportunity to check your knowledge and skills by taking a brief
quiz.
• Your final grade for a given quiz will be based on the highest score of all of your attempts.
• The four quizzes will count for a cumulative 20% of your final course grade.
Grading Scheme
Each of the four modules in this course has 1 quiz and 1 peer review assignment. Each quiz is worth 5% of
your grade and each peer review assignment is worth 20% of your grade. You must score 80% or higher on
each of these assessments in order to pass this course.
[MUSIC]
[MUSIC]
[MUSIC]
The point of this lecture is really to just introduce the term
Internet of Things.
Just to define the term, give you some kind of a general idea
of what Internet of Things really is, what it's about.
So we'll go through an example, a refrigerator example.
And talk about how a refrigerator can be integrated into the Internet of Things,
and how it’s different than just a regular,
traditional refrigerator that you are probably used to.
[MUSIC]
This lecture will give some more examples of the Internet of things devices.
Just to give you a sort of a better more concrete idea of what these devices
are and how they differ or how they're distinct from traditional computers.
So we'll run through a few more examples and
get a little more detail about their behaviors.
[MUSIC]
This lecture will compare IoT devices to standard computers, and
it will just compare and contrast.
Just so you get an idea of the difference between an IoT device and a computer,
because they are substantially different.
And we'll need to know this for
later because we're gonna talk about how you design IoT devices.
And the design methodologies are very different than what you'd use for
a standard general purpose computer.
[MUSIC]
This lecture we'll talk about the various trend [INAUDIBLE].
Technological trends that have led to the incident of things, say revolution.
It's a overused word, but let's try to use that right now.
So there are lots of different trends that have led to this,
led to the incorporation of things, technology into devices today.
And so we'll talk about those things.
And it sort of crept up on us over the years,
but now there's this convergence where the situation is right.
Everything works and
you can really do a lot of the things that you see in these IoT devices today.
[MUSIC]
This lecture we'll talk about the pervasive nature of IoT.
The fact that IoT is everywhere, [LAUGH] and
even though we're not necessarily aware of it all the time.
It's there and it's helpful, generally helpful.
So not only is it everywhere, it's also networked.
So it gives you access to all these abilities, all these features of things
that are in the network and it gives you access to them at all times.
So it's sort of a constant connection.
[MUSIC]
[MUSIC]
So in this lecture we'll discuss some of the downsides of Internet of Things
technology, some of the risks, and especially the privacy and
security issues that come up when you have IoT devices as pervasive as they are doing
things and out of your control at some extent.
[MUSIC]
So in this lecture we'll talk about embedded systems and
how they are related to IoT devices.
There's a lot of overlap.
Embedded systems, the term, usually refers a lot to,
not just how the device is used, but also how it's implemented, how it's built,
so there is a lot of overlap between the two terms.
And IoT devices are typically embedded systems also, so
we'll just define that and give you an idea Idea of what embedded systems are.
It's good to know the term embedded system because it is still commonly used, and
what we are building are typically embedded systems.
We will talk about building later on in the class.
They are actually usually embedded systems.
[MUSIC]
This lecture will talk about embedded systems a little bit more.
We'll talk in more detail about how they're designed,
since that is the point of this course.
We're gonna be building IoT devices, which are embedded systems.
So we're gonna talk about differences and how you would design an embedded
system as compared to a regular computational platform.
And some of this we talked about in the last module, but
we're gonna talk about how these differences impact the design process.
Start displaying text in 35 seconds0:35
Okay, so application specificity.
[MUSIC]
This lecture we'll talk about the structure of an embedded system.
The hardware structure specifically, look at the different components.
A very generic view and we'll talk about some of them.
The main component, the microcontroller we'll talk more about in the next lecture.
Start transcript at 25 seconds0:25
So, here's my high level generic view of what an embedded system looks like.
So if you look at an embedded system, it's got to take data from the outside world
and then it's gotta output data to the outside world.
So it has, first for the receiving data from the outside world,
it has a set of sensors.
So these sensors they receive information from the outside
in many different ways because there are lots of different types of sensors.
The most basic type of sensor would be a button, push button, something like that.
And that's receiving data that somebody types in.
You know, zero, one is binary.
Then there's also, for instance, you could receive sound information like
the microphone in front of me, or actually connected to here.
And that receives audio information.
There's also video, like the camera in front of me,
or just a regular light sensor that receives video information.
There's all kinds of sensors.
Touch screens, right?
You can receive touch information through a touch screen.
So, there's a lot off different sensors that an embedded system
can receive input from.
So that input comes in to a set of sensors and it's gonna go into the core of
the system and in the end, once the system has decided, process that information,
decide what to do with that information, it needs to cause some results.
An effect to happen in the outside world.
So that's done through the actuators at the other side, the actuators,
they cause events to happen in the world.
So those might be something like an LED,
a light, like there's a light flashing in front of me.
That LED is an output actuator.
And it goes off and on to indicate probably that it's recording, okay?
But there are other actuators too, like for instance, the camera in front of me.
It's got motors inside that control the lens to control the focus.
So those motors, those are actuators.
Those are outputs of the system.
So the system will drive those motors and
those will be considered actuators and make them.
[MUSIC]
So in this lecture we'll talk about basic components that you see in embedded
systems commonly, different versions of what you will eventually use in the class.
[MUSIC]
In class we've been talking about embedded systems.
And I'd like to give you a small example of one in the flesh, so to speak.
This one, it's got a sensor, an actuator and a microcontroller in between.
It's got all the basics that we've spoken about.
So if we look in front of you, we've got a bread board, right here.
And on this bread board, we've got our sensor, this little blue knob right here.
This blue knob is a potentiometer.
What it does is it senses rotation.
So it's a knob, I can turn the knob, and
it will report back to me the amount of rotation.
It does that in terms of resistance, so it's really a changing resistor, or
a variable resistor.
You turn the knob and the resistance changes.
[MUSIC]
So we're going to talk about analog versus digital.
If you remember several lectures ago we talked about embedded systems,
IT devices, and their interface.
And so at the input they have a set of sensors that receive
data about the outside world.
Though the sensors could be simple things like buttons or something like that but
it could be a microphone, a light sensor, a camera, something like that.
But it senses data about the outside world.
And then actuators on the other end, output data to the outside world.
So maybe they're lights, LEDs or speakers, or just a screen or something like that.
Okay, but they send data to the outside world.
So there's this interface, sensors at the input side, actuators at the output side.
[MUSIC]
So in this lecture, we'll discuss some of the basic equipment
that you're going to be using when you're building your internet of things devices.
And some of the basic equipment that we'll be talking about through the class we'll
assume that you're using just to make things a little more concrete so you see.
I've been more generic in the earlier lectures
about the general type of equipment, but now we'll actually
point to the specific things that we're going to cover in this class.
Then when you do the capstone you'll be using this type of equipment when you do
your capstone.
Identify the core hardware components most commonly used in IoT devices
Describe the interaction between software and hardware in IoT devices
Describe the role of an operating system to support software in IoT devices
Bojanova, I. (2015, March 31). What Makes Up the Internet of Things? Computing Now, IEEEComputer
Society.
[MUSIC]
MUSIC]
So this lecture, we're gonna talk about hardware and software systems.
Internet of things devices, are typically hardware and software combined.
So as we're learning about the IoT design process,
we really have to think about how you design hardware,
how you design software, and how do you design them to work together.
So you can't think of one in isolation,
you really need to think about both together as you're working on the project.
[MUSIC]
This lecture will talk about microcontrollers in a little bit more
detail.
Specifically, we're gonna talk about the storage elements and
how you store data inside a microcontroller.
Some of this is important for us, just to have an idea of what type of elements
there are inside a microcontroller.
And not just inside a microcontroller really, but also the memories outside
the microcontroller, cuz these are important parts of the system.
You always have data, you need to store it.
So we need to know a little bit about that.
So first, here's a picture of taken out of a datasheet for
an AVR at mega 2560 microcontroller.
This at Mega 2560 is not the same as what's in the Arduino, or
not in the regular Arduino.
In the Arduino uno, it doesn't have this.
Actually I think there is an Arduino that uses one of these, but
this is the same series of processes that you find in an Arduino.
And here's some of the information that you would find right on the front page of
the datasheet.
8-bit microcontroller up to 16 megahertz, that's the clock frequency.
256 kilobytes of flash memory, so
that tells you something about the type of memory in there.
Flash memory as you may know, it's a type of memory that's nonvolatile memory.
So after you lose power when you regain power, the memory's still there.
So you see this in thumb drives.
Thumb drives are basically flash memory.
EEPROM is also another type of nonvolatile memory similar to flash.
SRAM is your regular random access memory, we'll talk about that.
And then peripherals, that's sort of a general term for
all the other components inside the micro controller on the chip, like the timers,
ADD converters and all those other things.
So it's got a number of peripherals that I didn't list,
I didn't put the whole datasheet up there.
But that picture right there, shows you what the pins look like.
So actually, where they are configured on the chip.
So that means if you bought the chip, then which pin corresponds to which function?
And they're all labeled right there.
Actually, this is just a snippet of it, cuz we couldn't put all the The pins on
this one page, but this is like the upper left hand corner of the chip.
It shows you the pins that you can see there and
there are a lot more pins than that, but they're all labeled with names and
are referred to later in the datasheet.
[MUSIC]
This lecture will talk about the software side a little bit.
Specifically how the software is processed before it's actually executed in
the micro-controller.
So key here is that the code that you actually write isn't
literally processed by the micro-controller.
It's not executed directly.
It has to be processed first [COUGH] compiled or interpreted and
then it's processed.
So we'll talk about that.
[MUSIC]
So this lecture, we'll talk about a comparison between Python and C, C++.
Because Python is what we're going to be using with the Raspberry Pi.
C, C++, we'll be using with the Arduino.
Also we'll talk a little more detail just to understand the contrast.
We'll talk about the tool chain, the software tool chain.
All the tools that go into taking a high level piece of code, and
getting the eventual machine code.
We'll just look at that whole picture,
cuz it ends up looking a little different for one versus the other.
So, Python is an interpreted language.
It's a scripting language, but that's also an interpreted language.
It's high level language.
It's easier to work with, because it's interpreted.
So there are certain things the programmer does not have to deal with,
like the type of variables.
Is it an integer, is it in floating point, is it a string,
you don't have to worry about that in Python.
Python figures that all out based on how you use the code, ow you use the variable.
So at run time, while it's executing and
doing an interpretation, it can figure that out.
Other things too, like memory management, in C, C++ you have to deal with that.
You have to say, look, I need more space.
There's a function called malloc, you can allocate more space,
I need more memory for this variable.
Python, you don't have to say that, it'll just make it for you,right.
And when you're done with it, it'll get rid of it.
So where in C you, have to make it explicitly, and you have to,
as a programmer, have to know oh, now I'm done with it, let me free that memory.
So there are a lot of these burdens, these programming burdens,
that you don't have to deal with in a language like Python,
because the interpreter is there take care of it for you at run time.
Now comparing that to C, C++.
C and C++, they're related languages.
Actually, C is Is a subset of C++.
So C came first, C++ came second.
C++ is a super set, so C++ does everything that C does.
So if you have a C++ compiler, it'll compile any C code.
But C and C++ are compiled languages.
So you write the code, you compile it once, and then you get an executable,
which is machine code plus extra information.
And you only execute the machine code.
You don't have to do the interpretation at run time.
So as a result C, C++ programs are generally a lot faster than Python
programs, but the programmer has to deal with a lot more details.
Now, dealing with a lot of details is hard.
But when it comes to embedded systems, it's often useful because
sometimes, not just sometimes, often the programmer, an intelligent programmer,
can write code more efficiently than the Python interpreter can.
Okay, so the programmer, knowing something about what the behavior they expect,
they can write their C, C++ code in such a way that it runs
a lot faster than the Python interpreter could ever predict,
cuz the Python interpreter, it's dumb compared to a human, right.
A human can know something more about the context in which the software is
being used.
So in C and C++ are commonly using embedded systems.
Outside of embedded systems, you see them used less.
Maybe Java is favored, or something like that.
But because of the level of control that you get with C, C++,
they are much more commonly used in embedded systems.
[MUSIC]
So this lesson, this lecture we'll talk about,
a little more about operating systems and what they do.
We'll talk about tasks and process support really, about how
operating system support multiple tasks executing at the same time and
how that's useful in more complicated IoT devices.
So multiple tasks.
So this is actually going back to the last lecture where we were talking about
this embedded system that I had my students make.
Actually, IoT device, it was a web controlled car.
And through the Internet, you could go to a browser, open up a browser and
remotely control this car.
So you could view what its camera was seeing on your web browser.
Also you could hit some buttons forward, back, left,
right to control the motion of the car.
And so the car itself has its own processor and a web server running on it.
A Wi-Fi web server running on it and a camera and
it could manage all these tasks.
These tests could be managed remotely.
But the idea is that on that car, on its microcontroller,
it had to do multiple things at once.
There are multiple tasks that it had to handle in order to do this that it had to
handle at the same time.
So let's look at some of these.
One thing is sending video data.
So this car, if you were connected to it, it was constantly sending video data
from its camera to your phone or whatever your web browser was running on.
So, it had to do that.
Send video data all the time in the background,
then servicing the motion buttons.
So in the interface, you could go to your web browser.
Hit the forward button, the car would move forward.
Hit the back button, the car would move back, and so on.
So the car, its microcontroller has to service those buttons.
So even while it's playing the video at the same time,
if somebody presses forward, it's got to respond.
Go forward, go backward and all that.
So, it has to do that.
Detecting obstacles.
So this thing has an auto brake feature, so
it has to be constantly detecting obstacles.
So if there's an obstacle in front of it, it will brake.
Regardless of what the commands are, that would get overwritten.
So, it's gotta be constantly detecting obstacles while it's showing its video and
while it's responding to the control buttons.
Also, auto brake.
So that's another thing has to happen concurrently, you can be showing video.
Somebody can be pressing buttons, you can be responding to them.
But if you detect an obstacle, you gotta brake, automatically.
Concurrently, with the video and with everything else.
So multiple tasks have to be performed by this device.
And in a situation like this, it is helpful to have an operating system to
handle the multiple tasks to help you handle them.
So I just talking about how they can happen together, you get detect and
auto brake cannot occur together.
So if you detect, then you auto brake.
They don't happen together, but everything else can happen concurrently.
So in a situation like this,
you need to have multiple things running at the same time.
Multiple tasks being performed at the same time.
Now you could, as a programmer write a relatively complicated program that does
all these things at once and checks.
While you're sending video data, it's also checking to see if a button is pressed,
it's also checking for collisions and so on.
But an operating system makes this easier, because you can write each one of these
tasks as a separate task and then let the operating system inter-mix them.
You can write one piece of code that just sends video data.
Another piece that serves as motion buttons, another that takes obstacles.
Another one that does auto brake and then you can give them the operating system and
the operating system will make sure that they all run at the same time.
You don't have to as a programmer, you can write things separately.
You can write the sending video data code separately from the servicing motion
button code and the operating system can interweave them for
you and that relieves a lot of burden for the programmer.
So the main job of an operating system is to support a process or
a task abstraction.
I'm not gonna differentiate them too well right now,
but let's just talk about processes.
A process is an instantiation of a program, so a run of a program.
So if you got a program, PowerPoint, let's say,
which is running on this machine right here.
When you're running PowerPoint, it has a process running.
And so say on my machine, I open PowerPoint ten times,
then I've got ten different processes all in different instantiations of PowerPoint.
So a process is like a runtime instantiation,
execution of a program and you can have many of them at the same time.
So the process has to have access to the resources of the processor, the CPU.
Meaning, the microcontroller itself, the memory.
A process needs to read from memory and write to memory and so on.
Other resources, the timers, the ADD converters, the network access, all that.
The processes all have to access that, but they have to share that.
So there might be only one ADD converter in this microcontroller and
there might be three processes that need to use the ADD converter.
So the operating system, part of its job is to manage all these resources to make
sure that everything gets used fairly, one at a time.
So if all three processes wanna use this ADD converter,
the operating system essentially put them in a line.
Says, okay, you were first, so you go first.
You're more high priority, so you go second.
The operating system's job is to manage all these resources.
The memory and the CPU and I/O, ADD converters.
All the resources in the hardware, the operating system takes care of that and
makes sure that the different processes can use them in a fair order.
Thank you.
[MUSIC]
“Mobile Networks Prep for the Internet of Things”, Stephen Lawson, IDG News Service, Feb 18, 2015
“Security and the Internet of Things – are we repeating history?”, CSO Jul 13, 2015
So networking is clearly an important part of internet of things,
internet is right there in the name.
So in module four we'll talk about networking in general.
We'll talk about networks, network protocols, we'll focus on the internet
because that's the network to which we'll most likely be connecting.
Also we'll talk more specifically about mobile ad hoc networks.
Mobile ad hoc networks are magnets, sre smaller networks of mobile devices,
which IOT devices commonly are, and they're ad hoc,
meaning they're changing all the time.
Things move in them, things move out of them,
and that's inevitable when your using mobile devices.
The configuration network can change very dynamically.
So we'll talk about magnets, and how there are different protocols used for
magnets, and how you design and
implement an interface component with networking in mind.
[MUSIC]
[MUSIC]
In this lecture, we'll talk a little bit about networking.
Networking is a central feature of Internet of Things.
We'll talk about why it's needed, how it's helpful.
Also we'll start talking about general structure of networks,
sort of the broad categories of networks.
MUSIC]
The internet is a wide area network, the wide area network, and
that's generally the network that we want to communicate with eventually.
So we're going to talk about the general structure of a wide-area network.
These pictures are pretty high level, but they give you the general picture
of what a wide-area network like the Internet would be, how it's composed, and
what the different components are inside there.
So a wide-area network, like the Internet,
is a network, it's a combination of local area networks.
So if you think about the Internet, it's very ad-hoc.
There's no regularity, meaning like right now, if I wanted to, I could build
a network right here in this building, and it would be added to the Internet.
I could give it a name, and it would be part of the Internet.
And so the Internet isn't one of these networks that's controlled and
well-structured.
Unlike the local area networks that you see at your place of work,
or at a school, where you have some I.T.
department, I.T. group, and they constrain how the thing is put in there.
They say, look, every time a machine comes in here,
you've got to register it this way.
We only approve of this and that.
And they put the equipment into the building for you, and all that.
So it's very structured.
But, generally, wide area, the internet specifically,
is pretty unstructured, right?
There is some minimal structure, there has to be, but it's fairly unstructured.
So at a low level, at the leaf level, local area network level, there can be
any number of different local area network types involved in the internet,
just depending on what people want locally.
So you start off with local area networks.
You've got our local area network and
you've got several hosts, Host one, two, three, and
these hosts suggest confrontational devices that on the network.
So basically computers or IOT devices.
And they are all communicating with a component.
Now in this picture we have a switch.
It could be hub or a switch.
A hub is a network component that has several input ports.
We're assuming wired right now.
This can also be all done wirelessly, but let's talk wired for a minute.
It's got several input ports, input-output ports, like in this case,
this switch has three ports, right?
So you could have a hub there that has three.
And any time a packet is sent on one of the ports it is reflected,
copied to the other ports.
So if host one sends a message to anybody,
that same message is spit out to codes two and three.
So both of them get the message.
That's what a hub does.
A switch is more intelligent.
A switch says look, it looks at the packet header to see where it's going.
So if host one sends a message to the switch and it looks at the destination
message is host three, then the switch there is smart enough to know
that that message should only be send to host three not to host two.
So the switch is more intelligent about where it sends messages to,
where a host is more dumb.
But you got a host or switch somewhere in there that transmits data
between the different input ports and output ports.
So generally, LANs look like this.
[MUSIC]
So this lecture we'll talk a little bit about the internet and structure and
we'll get into internet protocols.
Protocols in general.
We'll talk about what a network protocol is.
We have to know a little bit about these.
We don't want to go into detail in protocols.
But you have to know they exist because the hardware that we buy when we make our
IOT device,
the hardware that we buy, we'll buy it matching a particular protocol.
So we'll pick the protocol and pick the hardware to match that.
So we need to know at least the existence of protocols and what they are.
[MUSIC]
So we'll talk a little bit about protocols, network protocols,
Internet protocols specifically and what their responsibilities are.
We won't go into great depth.
But we want to give you a flavor of what's contained inside these protocols and
what they define.
So what does the protocol do?
An Internet Protocol, it does a lot.
An Internet Protocol, meaning IP or TCP or UDP, they do several things.
One basic thing is provide a naming scheme.
Actually that's a very important thing.
So IP, you've probably heard of an IP address.
That comes from the Internet Protocol and
it's a unique address that every network component has.
Every component on the Internet has to have an IP address, and so
each host and router gets assigned at least one of these Internet addresses.
Now when you say least one, basically it should be one to every network adapter.
But a particular machine can have many network adapters.
By network adapter, I mean hardware interfaces to the network.
So if you look at a laptop, you'll often have a wi-fi adapter, but
you'll also have a wired adapter and a wired ethernet jack.
You might not.
Depends on your laptop,
but you might have an ethernet jack where you can plug into the wall, right?
So, you might have two network adapters there.
Two ethernet Internet network adapters.
So you might get two IP addresses, one for each.
Usually you focus on one, but it's possible to have more.
So, Internet protocol, one very important thing it does is it
gives this naming scheme, this unique naming scheme.
Every machine on the Internet has to have a different name.
And now there are problems with this, right,
because IP addresses are not that long.
IP addresses are four byte numbers,
four single bytes, so you've seen them referred to as these,
let's see like 124.254.27.33.
Okay, and they're four numbers separated by dots.
So it's four numbers and each number can range from 0 to 255.
So there aren't that many addresses compared to how many network
components there are these day, because of IOT.
There's so many things on a network.
You need so many addresses.
So there are a lot of challenges in dealing with that.
We won't really cover those right now.
But the idea is everything on the network has to have a unique IP address.
[MUSIC]
This lecture we'll talk about what a protocol stack is,
really define that term.
We will go into a little bit of detail,
little bit of information about how a protocol stack is defined.
Now remember though, that in practice certainly in this specialization,
in practice you're not gonna be writing a protocol stack,
making a protocol stack, but you can use a protocol stack.
So you at least would wanna know what this term is because it gets
thrown around, right.
If you want to make a new embedded system you say, well I need to be networked,
you know Internet, which protocol stack am I going to use, right?
Which implementation of the protocol stack will I use?
You need to know what that term means,
because it gets used a lot when you're actually coding things.
You should know basically what it means.
So not all the details that I'm talking about will be important in the long run,
but you should see it all at once because it'll
give you a better context about what you're using.
[MUSIC]
This lecture we'll talk about protocol stack, the Internet standard protocol
stack which involves TCP/IP and I'll talk a little bit, give a little bit of
an example about an application layer protocol, what that would look like.
We're not going in again, not into too much detail, but you should know what this
protocol stack looks like, because anytime you want to use the internet.
So, if you want to write code that accesses the internet,
you're going to be using this stack, this protocol stack.
So, you want to know something about how it works.