1
00:00:00,720 --> 00:00:04,470
Hi and welcome to a new section in this course in this section.

2
00:00:04,500 --> 00:00:11,990
I'm going to show you how to use the Wi-Fi capabilities of the ESPN three to my controller using micro

3
00:00:12,000 --> 00:00:12,680
python.

4
00:00:13,140 --> 00:00:21,180
And I'm going to do that by guiding you through a series of lectures which contain examples on how to

5
00:00:21,390 --> 00:00:30,900
interact with various Web resources to send and receive data using simple requests, especially to get

6
00:00:30,900 --> 00:00:33,750
and post hated requests.

7
00:00:34,260 --> 00:00:40,380
In this first lecture of the section, I want to walk you through some of the fundamental resources

8
00:00:40,380 --> 00:00:46,740
that will be using again and again throughout these lectures and in a way set the ground for what you're

9
00:00:46,740 --> 00:00:48,990
about to learn and what you're about to see.

10
00:00:49,770 --> 00:00:50,510
So let's begin.

11
00:00:51,240 --> 00:00:55,970
First of all, let's talk a little bit about the practical examples that you're about to see.

12
00:00:56,070 --> 00:01:03,960
I'm going to be using resources such as DeWit, DOD, Eyo, and if this and that and open weather map

13
00:01:03,960 --> 00:01:12,420
do it as well as my own website in order to play around with the capabilities of micro python when it

14
00:01:12,420 --> 00:01:19,890
comes to interacting with Web resources, for example, with the DOD, I will show you how you can use

15
00:01:19,890 --> 00:01:25,830
tweets to API and rest API to Sentara with.

16
00:01:25,920 --> 00:01:34,350
If this event, I'll show you how to generate an email from a post requests coming from your HP 32 with

17
00:01:34,350 --> 00:01:34,650
dummy.

18
00:01:34,650 --> 00:01:41,820
Since the data, I'm going to show you how to get the current weather conditions for anywhere on the

19
00:01:41,820 --> 00:01:45,950
planet using a weather map, dot org and its open API.

20
00:01:46,410 --> 00:01:51,180
And to begin with, I'm going to show you something very simple, which is how to read this text file,

21
00:01:51,180 --> 00:01:57,190
which I have uploaded onto my own website, a very simple way to get started.

22
00:01:57,840 --> 00:02:03,600
So these are some of the things that we'll be doing and will be, of course, analyzing in detail what's

23
00:02:03,600 --> 00:02:08,220
happening with each one of these examples, especially in terms of the software.

24
00:02:08,790 --> 00:02:14,940
Now, having said software, let's flip over to the other side, have a look at the hardware and basically

25
00:02:14,940 --> 00:02:20,970
this is it to conduct all of the experiments in this section, you just need to be able to microcontroller

26
00:02:21,270 --> 00:02:22,550
connected to your computer.

27
00:02:22,800 --> 00:02:27,870
And we're not going to use any pitfalls around that just to keep things as simple as possible.

28
00:02:28,380 --> 00:02:36,150
Whenever we need to use some sensor data to send them to our remote web resource or just simulate the

29
00:02:36,150 --> 00:02:44,700
sense of data with random numbers, that's just good enough since our focus here is on the Wi-Fi and

30
00:02:44,700 --> 00:02:52,080
communications capabilities and methodologies instead of the hardware components that could generate

31
00:02:52,080 --> 00:02:54,150
real world data sets of data.

32
00:02:54,810 --> 00:02:55,410
All right.

33
00:02:55,410 --> 00:03:03,150
Now about the individual software components that pretty much all of our examples groups will be using

34
00:03:03,540 --> 00:03:06,820
a first one to show you the networking module.

35
00:03:06,840 --> 00:03:14,220
So I'm looking at the quick reference for the E.S.P three to here and there that you'll find networking.

36
00:03:14,460 --> 00:03:22,980
And this is just an example of how you can set your ISP 32 to use your Wi-Fi network.

37
00:03:23,490 --> 00:03:27,930
All you've got to do is to create the wireless LAN object.

38
00:03:28,660 --> 00:03:32,990
Basically, you posted this comment here and it will land.

39
00:03:33,180 --> 00:03:39,060
And then inside the parentheses, you pass a parameter that indicates a type of network that you want

40
00:03:39,060 --> 00:03:41,580
to connect to or that you want to create.

41
00:03:41,880 --> 00:03:43,830
So you got really two options.

42
00:03:43,840 --> 00:03:48,120
The first one is the one that you will be using in the examples that follow.

43
00:03:48,510 --> 00:03:54,210
You are connecting to a station that exists to a hotspot, in other words.

44
00:03:54,680 --> 00:04:01,380
Alternatively, if you need, you can create an access point interface, which means that you can get

45
00:04:01,380 --> 00:04:04,730
your authority to act as an access point.

46
00:04:05,100 --> 00:04:10,830
I'm not going to be using this mode of operation, but if anyone is interested in this enough interest

47
00:04:10,830 --> 00:04:17,400
out there, I may consider creating one or more lectures exploring this capability as well.

48
00:04:18,180 --> 00:04:21,080
After that, we activate the interface.

49
00:04:21,090 --> 00:04:26,850
Then you can use this scan method to look around for wi fi hotspots in this command would actually list

50
00:04:26,850 --> 00:04:33,480
them onto the schill or we're not going to be doing that because we know which network we want to connect

51
00:04:33,480 --> 00:04:36,260
to by the network name and password.

52
00:04:37,080 --> 00:04:40,380
So then we can use the connect.

53
00:04:41,550 --> 00:04:47,090
Method, we passed the name of the network in a password and that achieves connection.

54
00:04:47,670 --> 00:04:57,030
After that, we can start using the wi fi connection and sent out HATSUKO requests and send and receive

55
00:04:57,030 --> 00:04:58,980
data from around the Internet.

56
00:04:59,520 --> 00:05:00,490
So this is the first one.

57
00:05:01,120 --> 00:05:10,680
Next, I'll be using Jason or the Jason module, and in particular the some of the micro Jason module

58
00:05:10,980 --> 00:05:15,990
that comes with my code python to help me deal with Jason files.

59
00:05:16,350 --> 00:05:27,060
Either Jason files that code wi fi or remote asset credentials in a separate file outside of the Micro

60
00:05:27,060 --> 00:05:34,350
Python script, or in some cases, for example, with the DOD does enter open a weather map that's there

61
00:05:34,350 --> 00:05:34,740
as well.

62
00:05:34,950 --> 00:05:39,660
The response coming from those resources is Jason formatted file.

63
00:05:39,990 --> 00:05:47,010
And therefore, I'm going to use you, Jason, to decode it or to encode it as I'm sending data in and

64
00:05:47,010 --> 00:05:58,290
out of the you Jason module that comes with micro python is a micro implementation of the C or C language

65
00:05:58,650 --> 00:06:01,340
python module called Jason.

66
00:06:01,590 --> 00:06:09,060
So I've also linked to the actual C Python Jason module because here you can see full examples of how

67
00:06:09,060 --> 00:06:10,260
to use Jason.

68
00:06:10,830 --> 00:06:18,810
You, Jason, is a partial implementation of the full C language Python Jason module and it only implements

69
00:06:18,810 --> 00:06:20,630
certain functions here.

70
00:06:21,450 --> 00:06:25,600
So as I said, it's a micro implementation of the full chasten module.

71
00:06:26,340 --> 00:06:36,150
So basically the way that you can use this is to use this documentation to see which of the Jason functions

72
00:06:36,150 --> 00:06:38,340
have been implemented in Micro Jason.

73
00:06:38,730 --> 00:06:46,800
And then you can go to the full Jason documentation and look at how those particular implemented functions

74
00:06:46,800 --> 00:06:50,670
works at this dump, for example, which is implemented in micro.

75
00:06:50,690 --> 00:06:59,070
Jason, you can learn about its actual use by looking at the full C language python implementation of

76
00:06:59,070 --> 00:07:00,030
the same function.

77
00:07:00,570 --> 00:07:05,490
Of course, I'll be showing you how I'm using Micro Jason in the example scripts.

78
00:07:06,420 --> 00:07:15,330
Another very important module that I'll be using in all of the examples is your requests, which is

79
00:07:15,330 --> 00:07:23,430
a micro implementation of the full requests module that is available in Python.

80
00:07:23,680 --> 00:07:30,810
So this is not a core component of the Python language, but it's a third party module and it basically

81
00:07:30,810 --> 00:07:39,000
makes it very easy to do get post delete in other types of requests so you can see the full vocabulary

82
00:07:39,000 --> 00:07:40,020
that's available here.

83
00:07:40,410 --> 00:07:46,890
And what I really like about your requests and requests, of course, is how easy it is to learn and

84
00:07:46,890 --> 00:07:47,430
to use.

85
00:07:47,730 --> 00:07:48,900
So basically, here it is.

86
00:07:49,290 --> 00:07:56,720
You just need to import requests or requests in our case and to do a simple get request.

87
00:07:57,210 --> 00:08:05,070
It's easy as one line of code another that we can just simply read and interact with the response that

88
00:08:05,070 --> 00:08:11,340
we're getting from the server that is now stored in this example, our object, which is the response

89
00:08:11,340 --> 00:08:12,540
object you can see here.

90
00:08:12,870 --> 00:08:20,280
So in other words, just to finish with this segment, the requests module that will be using in all

91
00:08:20,280 --> 00:08:28,020
of the examples that are coming up is a implementation or micro implementation of the full Python requests

92
00:08:28,020 --> 00:08:30,150
module it provides us with.

93
00:08:30,150 --> 00:08:35,780
These features will be using the get and post verbs here for the vocabulary.

94
00:08:36,000 --> 00:08:40,530
And if you want to learn more about how to use it, you can refer to the documentation.

95
00:08:40,800 --> 00:08:44,040
But of course, it's, as I said, so simple to use that.

96
00:08:44,040 --> 00:08:50,040
Just looking at the example scripts that I have prepared will be enough to get you a long way through

97
00:08:50,040 --> 00:08:54,750
implementing your own scripts and your own requirements from your scripts.

98
00:08:55,510 --> 00:08:56,640
OK, so that's about it.

99
00:08:56,640 --> 00:08:59,820
With the preliminaries, let's jump into the next lecture.

100
00:08:59,820 --> 00:09:02,340
We'll show you how to do that simple yet request.
