1 00:00:00,000 --> 00:00:04,780 You may be asking why should we use JavaScript for the Internet of Things. 2 00:00:04,780 --> 00:00:07,949 Firstly, because it's asynchronous and event-driven. 3 00:00:07,949 --> 00:00:10,078 When you're reading input or sensor data, 4 00:00:10,078 --> 00:00:13,660 you can add event listeners to be triggered when an event occurs. 5 00:00:13,660 --> 00:00:16,662 This is like adding the click listener to a DOM element. 6 00:00:16,662 --> 00:00:20,977 Other languages have difficulty with their asynchronous programming with JavaScript, 7 00:00:20,977 --> 00:00:23,822 it's built-in, then there are millions of developers. 8 00:00:23,822 --> 00:00:28,324 Long gone are the days where JavaScript was a novel browser-based language, 9 00:00:28,324 --> 00:00:31,000 which brings me on to by that point. 10 00:00:31,000 --> 00:00:34,880 You can use JavaScript literally everywhere in your stack 11 00:00:34,880 --> 00:00:39,660 from the dashboard go in your browser to collecting data on the server side and 12 00:00:39,660 --> 00:00:42,360 now to the electronics themselves. 13 00:00:42,360 --> 00:00:46,226 Dealing with JavaScript allows you to take architect solutions and 14 00:00:46,226 --> 00:00:47,595 so end in one language. 15 00:00:47,595 --> 00:00:51,237 There are three types of strategies when it comes to JavaScript and 16 00:00:51,237 --> 00:00:52,609 the Internet of Things. 17 00:00:52,609 --> 00:00:55,273 First, Single Board Computers. 18 00:00:55,273 --> 00:00:58,153 Second, JavaScript Microcontroller. 19 00:00:58,153 --> 00:00:59,873 Third, Client-Host Model. 20 00:00:59,873 --> 00:01:02,510 We'll take a look at each one in detail. 21 00:01:02,510 --> 00:01:06,630 First, let's take a look at single board computers, which are computers that have 22 00:01:06,630 --> 00:01:11,180 all the processing power, RAM and storage space on a single board. 23 00:01:11,180 --> 00:01:13,806 Often, credit card sized, but they're getting smaller. 24 00:01:13,806 --> 00:01:17,450 Because they're full computers, they can node.js. 25 00:01:17,450 --> 00:01:19,947 There are other JavaScript one times two. 26 00:01:19,947 --> 00:01:23,290 So, check the teacher's notes for more details on those. 27 00:01:23,290 --> 00:01:27,026 One of the most common single board computers is the Raspberry Pi. 28 00:01:27,026 --> 00:01:30,526 The Raspberry Pi 3 cost anywhere between 35 and 29 00:01:30,526 --> 00:01:35,120 $40 and has Wi-Fi, internet and Bluetooth built-in. 30 00:01:35,120 --> 00:01:40,027 There are a 40 pins at the top edge of the board, which can be used for inputs and 31 00:01:40,027 --> 00:01:40,698 outputs. 32 00:01:40,698 --> 00:01:44,502 An input is used to sense things like the Amazon dash button, 33 00:01:44,502 --> 00:01:48,190 that sensed whether if there was a press or not. 34 00:01:48,190 --> 00:01:52,170 The smart sign was an example of an output printing pricing information. 35 00:01:52,170 --> 00:01:57,407 These pins can be pro grammatically checked and modified easing node,js. 36 00:01:57,407 --> 00:02:04,370 All must be pies require a micro SD card to install a Linux based operating system. 37 00:02:04,370 --> 00:02:10,692 The Pi 3 and Pi 2 can also run a version of Windows 10 called the Core IoT edition. 38 00:02:10,692 --> 00:02:14,973 There are cheaper models, but don't have the IoT connectivity, 39 00:02:14,973 --> 00:02:17,200 but still can be extended via USB. 40 00:02:17,200 --> 00:02:19,603 This Raspberry Pi is about $25 and 41 00:02:19,603 --> 00:02:24,450 has a single USB port that could be used to connect to Wi-Fi dongle. 42 00:02:24,450 --> 00:02:28,140 This is the Pi 0, which is only $5. 43 00:02:28,140 --> 00:02:34,120 And again, it doesn't have connectivity out of the box, but can still run node.js. 44 00:02:34,120 --> 00:02:36,300 Raspberry Pis have ARM-based CPU's, 45 00:02:36,300 --> 00:02:39,386 the processors that are commonly found in smartphones. 46 00:02:39,386 --> 00:02:43,930 The Intel Edison has an Intel Atom processor. 47 00:02:43,930 --> 00:02:47,809 WiFi and Bluetooth built-in, and it's really small. 48 00:02:47,809 --> 00:02:52,740 It also comes with 4 gigabytes of storage, so you don't need an SD card. 49 00:02:52,740 --> 00:02:57,029 It comes in around about $50, then there's the Tessel 2. 50 00:02:57,029 --> 00:03:00,570 The Tessel 2 is built with JavaScript in mind from the GetGo. 51 00:03:00,570 --> 00:03:03,310 It has node.js pre-installed already. 52 00:03:03,310 --> 00:03:06,882 It has Wi-Fi built-in, as well as an Ethernet port. 53 00:03:06,882 --> 00:03:11,442 It also has a way to use USB dongles to extend functionality as well as 54 00:03:11,442 --> 00:03:15,442 expression ports to put in modules with various senses, so 55 00:03:15,442 --> 00:03:19,360 you can get up and running without soldering. 56 00:03:19,360 --> 00:03:21,614 This is about $45. 57 00:03:21,614 --> 00:03:24,592 There are a couple of JavaScript frameworks that you can use on 58 00:03:24,592 --> 00:03:26,290 single board computers. 59 00:03:26,290 --> 00:03:29,525 For example, Johnny-Five and Cylon.js. 60 00:03:29,525 --> 00:03:33,498 You can talk to the IO pins on all of these boards and 61 00:03:33,498 --> 00:03:37,754 read information from sensors and control outputs, 62 00:03:37,754 --> 00:03:41,480 like speakers, lights screens and mortise. 63 00:03:41,480 --> 00:03:45,778 The pros of single board computers that they are folk computers and 64 00:03:45,778 --> 00:03:49,552 most open source projects are mature in terms of support. 65 00:03:49,552 --> 00:03:54,280 You can one phone node.js on these devices and any of the frameworks, and 66 00:03:54,280 --> 00:03:56,340 modules written a node. 67 00:03:56,340 --> 00:04:00,620 You also have the luxury of using anything that can be installed Linux, 68 00:04:00,620 --> 00:04:03,310 like computer vision libraries. 69 00:04:03,310 --> 00:04:04,761 There are some cons though. 70 00:04:04,761 --> 00:04:08,670 For example, you have to wait for the computer to boot up. 71 00:04:08,670 --> 00:04:10,544 It's not an instant on. 72 00:04:10,544 --> 00:04:15,960 The IO is slow, because there's a full Linux kernel running on top of the chip. 73 00:04:15,960 --> 00:04:18,421 It's hard to get super fast ratings. 74 00:04:18,421 --> 00:04:19,899 Because there is a fellow west, 75 00:04:19,899 --> 00:04:22,860 there's more points of failure in the software stack. 76 00:04:22,860 --> 00:04:27,279 Also, it can be quite costly to have a general purpose computer to do a few 77 00:04:27,279 --> 00:04:31,640 simple tasks not only costly in price, but also in power consumption. 78 00:04:31,640 --> 00:04:36,024 In the next video, we'll take a look at another class of devices that can be a lot 79 00:04:36,024 --> 00:04:38,000 cheaper and more power efficient.