Heads up! To view this whole video, sign in with your Courses Plus account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed JavaScript and the Internet of Things!
You have completed JavaScript and the Internet of Things!
Preview
Find out why you should consider using JavaScript for the Internet of Things and the strategies you can use. The first is Single Board Computers.
JavaScript Runtimes
Examples of Single Board Computers
JavaScript Frameworks
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You may be asking why should we use
JavaScript for the Internet of Things.
0:00
Firstly, because it's asynchronous and
event-driven.
0:04
When you're reading input or sensor data,
0:07
you can add event listeners to be
triggered when an event occurs.
0:10
This is like adding the click
listener to a DOM element.
0:13
Other languages have difficulty with their
asynchronous programming with JavaScript,
0:16
it's built-in,
then there are millions of developers.
0:20
Long gone are the days where JavaScript
was a novel browser-based language,
0:23
which brings me on to by that point.
0:28
You can use JavaScript literally
everywhere in your stack
0:31
from the dashboard go in your browser to
collecting data on the server side and
0:34
now to the electronics themselves.
0:39
Dealing with JavaScript allows you
to take architect solutions and
0:42
so end in one language.
0:46
There are three types of strategies
when it comes to JavaScript and
0:47
the Internet of Things.
0:51
First, Single Board Computers.
0:52
Second, JavaScript Microcontroller.
0:55
Third, Client-Host Model.
0:58
We'll take a look at each one in detail.
0:59
First, let's take a look at single board
computers, which are computers that have
1:02
all the processing power, RAM and
storage space on a single board.
1:06
Often, credit card sized,
but they're getting smaller.
1:11
Because they're full computers,
they can node.js.
1:13
There are other JavaScript one times two.
1:17
So, check the teacher's notes for
more details on those.
1:19
One of the most common single board
computers is the Raspberry Pi.
1:23
The Raspberry Pi 3 cost
anywhere between 35 and
1:27
$40 and has Wi-Fi, internet and
Bluetooth built-in.
1:30
There are a 40 pins at the top edge of the
board, which can be used for inputs and
1:35
outputs.
1:40
An input is used to sense things
like the Amazon dash button,
1:40
that sensed whether if
there was a press or not.
1:44
The smart sign was an example of
an output printing pricing information.
1:48
These pins can be pro grammatically
checked and modified easing node,js.
1:52
All must be pies require a micro SD card
to install a Linux based operating system.
1:57
The Pi 3 and Pi 2 can also run a version
of Windows 10 called the Core IoT edition.
2:04
There are cheaper models, but
don't have the IoT connectivity,
2:10
but still can be extended via USB.
2:14
This Raspberry Pi is about $25 and
2:17
has a single USB port that could be
used to connect to Wi-Fi dongle.
2:19
This is the Pi 0, which is only $5.
2:24
And again, it doesn't have connectivity
out of the box, but can still run node.js.
2:28
Raspberry Pis have ARM-based CPU's,
2:34
the processors that are commonly
found in smartphones.
2:36
The Intel Edison has
an Intel Atom processor.
2:39
WiFi and Bluetooth built-in,
and it's really small.
2:43
It also comes with 4 gigabytes of storage,
so you don't need an SD card.
2:47
It comes in around about $50,
then there's the Tessel 2.
2:52
The Tessel 2 is built with
JavaScript in mind from the GetGo.
2:57
It has node.js pre-installed already.
3:00
It has Wi-Fi built-in,
as well as an Ethernet port.
3:03
It also has a way to use USB dongles
to extend functionality as well as
3:06
expression ports to put in
modules with various senses, so
3:11
you can get up and
running without soldering.
3:15
This is about $45.
3:19
There are a couple of JavaScript
frameworks that you can use on
3:21
single board computers.
3:24
For example, Johnny-Five and Cylon.js.
3:26
You can talk to the IO pins
on all of these boards and
3:29
read information from sensors and
control outputs,
3:33
like speakers, lights screens and mortise.
3:37
The pros of single board computers
that they are folk computers and
3:41
most open source projects
are mature in terms of support.
3:45
You can one phone node.js on these
devices and any of the frameworks, and
3:49
modules written a node.
3:54
You also have the luxury of using
anything that can be installed Linux,
3:56
like computer vision libraries.
4:00
There are some cons though.
4:03
For example, you have to wait for
the computer to boot up.
4:04
It's not an instant on.
4:08
The IO is slow, because there's a full
Linux kernel running on top of the chip.
4:10
It's hard to get super fast ratings.
4:15
Because there is a fellow west,
4:18
there's more points of failure
in the software stack.
4:19
Also, it can be quite costly to have
a general purpose computer to do a few
4:22
simple tasks not only costly in price,
but also in power consumption.
4:27
In the next video, we'll take a look at
another class of devices that can be a lot
4:31
cheaper and more power efficient.
4:36
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up