1 00:00:00,300 --> 00:00:06,060 Now, to make sure that you understand that a suitable request data that we just created, what we did 2 00:00:06,060 --> 00:00:08,240 is basically the following. 3 00:00:08,250 --> 00:00:17,160 We created variables and we have sent values or the values of these variables to the ACTU request. 4 00:00:17,700 --> 00:00:24,900 Now, you can't comment this line, the news, this ACTU request that a variable and as you can see, 5 00:00:24,900 --> 00:00:29,730 without the variables, you can actually pass the data directly. 6 00:00:29,970 --> 00:00:32,100 So the key here is this. 7 00:00:33,030 --> 00:00:34,320 This is our API key. 8 00:00:34,830 --> 00:00:42,570 And the concern is that Atchinson that you already mentioned, its location is at home office and it 9 00:00:42,570 --> 00:00:47,110 devalues one, two and three out of these random values. 10 00:00:47,280 --> 00:00:49,400 This can be used for testing purposes. 11 00:00:49,740 --> 00:00:52,320 You can come this and use this line. 12 00:00:53,100 --> 00:00:54,530 They both work the same. 13 00:00:54,930 --> 00:01:01,380 But if you have problems or if you are suspecting something, you can use this one for testing. 14 00:01:01,950 --> 00:01:05,190 Anyway, I will leave it to you if you wish. 15 00:01:05,550 --> 00:01:16,650 Now, to send the HTP post request, we need to create an integer and call it a P response called equal 16 00:01:16,840 --> 00:01:19,880 htp dot post. 17 00:01:21,300 --> 00:01:23,130 Now the post will take. 18 00:01:24,200 --> 00:01:33,740 This variable, the one that we created the data and it will send it through the HDTV, if you need 19 00:01:33,740 --> 00:01:38,740 an estimate request with a content type text or plain, you can change the header. 20 00:01:39,110 --> 00:01:45,920 But this is something I want to recommend because what we are doing here is more advanced. 21 00:01:45,920 --> 00:01:48,560 We are sending variables now. 22 00:01:48,740 --> 00:01:57,980 I will add other ways to add, let's say, text or plain text or adjacent file to the city request. 23 00:01:58,340 --> 00:02:06,770 But what we are doing here is simply sending sensor readings and variables so you can stick to the content 24 00:02:06,770 --> 00:02:13,490 header that we created, which is basically application and this is its type w w w we are all encoded 25 00:02:14,420 --> 00:02:17,480 and this is the encoding part. 26 00:02:19,960 --> 00:02:20,440 Now. 27 00:02:21,740 --> 00:02:30,710 To make sure that our request did go and we don't have any error, we initialize an integer so that 28 00:02:30,800 --> 00:02:35,330 the result of this request can be stored and this variable. 29 00:02:35,450 --> 00:02:46,400 Now, to check this variable, we need to ask using an if statement and ls now. 30 00:02:47,460 --> 00:02:57,690 Let's do this now, they've said and will be if the Stoebe response code is above zero, this means 31 00:02:58,260 --> 00:03:05,370 that we have seen data and we received a value above zero as a response to the post request. 32 00:03:05,670 --> 00:03:08,130 And that case we need to print on the Syrian monitor. 33 00:03:12,230 --> 00:03:19,670 Brent HTP response code. 34 00:03:23,790 --> 00:03:29,970 And we need to print the code to know if there is an issue so I don't print. 35 00:03:33,520 --> 00:03:42,700 And the response, quote, now, otherwise, we need to cover this, too, if the value isn't above 36 00:03:42,880 --> 00:03:44,850 zero, it means that there is an error. 37 00:03:45,460 --> 00:03:50,170 So in that case, we will use the Ayles and we will see error code. 38 00:03:52,930 --> 00:03:57,970 Code and words print the same code at the end. 39 00:03:58,150 --> 00:04:00,730 We need to end our request. 40 00:04:01,900 --> 00:04:04,540 So we need to add Test-tube and. 41 00:04:13,120 --> 00:04:17,500 This will end the city request process and we need to close this. 42 00:04:21,590 --> 00:04:22,130 Now. 43 00:04:23,240 --> 00:04:28,670 Else, as you can see, this is our F statement that we did close. 44 00:04:29,170 --> 00:04:37,030 Now, if the Wi-Fi is connected, it will do all of this, otherwise it will prevent that wi fi is not 45 00:04:37,030 --> 00:04:37,530 connected. 46 00:04:38,620 --> 00:04:51,880 So we can write serial, dot, print, new line and we can simply write wi fi disconnected. 47 00:04:55,180 --> 00:05:03,160 After that, we need to make sure that we are not receiving that continuously, so. 48 00:05:05,720 --> 00:05:06,660 Let's roll this one. 49 00:05:06,680 --> 00:05:08,540 OK, we need to either delay. 50 00:05:13,710 --> 00:05:17,610 Thirty thousand milliseconds, which is basically 30 seconds. 51 00:05:18,120 --> 00:05:26,170 So this will tell our ISP to send an active post request every 30 seconds to send since all that. 52 00:05:26,670 --> 00:05:33,630 Now, as I already mentioned, I will post the code, but you have to edit the following lines. 53 00:05:33,660 --> 00:05:38,490 The first thing that you need to edit is their society and password. 54 00:05:39,610 --> 00:05:46,730 And the second thing that you need to read is the Savani, which is this one, and you also need to 55 00:05:46,730 --> 00:05:49,210 read it, the AP Ikki. 56 00:05:53,210 --> 00:05:56,940 We did initialize the civil communication for debugging purposes. 57 00:05:56,960 --> 00:06:02,920 It's not something you have to do, but it's a good practice so that you can know if your code has errors. 58 00:06:03,500 --> 00:06:05,750 Now, after doing all of this. 59 00:06:08,220 --> 00:06:10,550 You can verify your code. 60 00:06:10,770 --> 00:06:12,430 We will check it if that is errors. 61 00:06:13,170 --> 00:06:18,420 I will solve them now to make sure that we can upload this code. 62 00:06:19,320 --> 00:06:22,590 OK, now that statements and capital letters. 63 00:06:25,300 --> 00:06:26,090 I did this. 64 00:06:26,110 --> 00:06:34,780 OK, now I think that we might have some spelling errors because I was writing as I was speaking and 65 00:06:34,780 --> 00:06:37,060 explaining so this might happen. 66 00:06:39,780 --> 00:06:41,730 OK, Duncan Barling, great. 67 00:06:41,750 --> 00:06:50,070 We do not have any rules now what you need to do is simply copy this code and based it on your ISP and 68 00:06:50,070 --> 00:06:51,180 we are going to do this. 69 00:06:51,180 --> 00:06:59,520 And the next lesson to test out our coding and to make sure that the server receives the data and everything 70 00:06:59,520 --> 00:07:00,250 is working fine. 71 00:07:00,930 --> 00:07:02,010 That's it for this lesson. 72 00:07:02,010 --> 00:07:04,610 If you have any questions, please ask in the Q&A board. 73 00:07:04,910 --> 00:07:05,700 Thanks for watching. 74 00:07:05,710 --> 00:07:08,250 This is Asharaf from educational engineering team.