WEBVTT

00:00.080 --> 00:03.410
It's now time to start the final project of this course.

00:03.410 --> 00:08.690
You have now completed all the learning steps and have a great knowledge foundation that you can use

00:08.690 --> 00:13.130
for any new project, including the one you are about to start right now.

00:13.160 --> 00:18.260
The project will be great for you to practice on everything you have seen in this course, and it will

00:18.260 --> 00:21.500
be your first real big project with a Raspberry Pi.

00:21.530 --> 00:23.660
So what is this project about?

00:23.660 --> 00:27.230
Here is the final result you will get at the end.

00:27.770 --> 00:31.010
So I am on the Raspberry Pi and I'm going to start the project.

00:31.010 --> 00:35.240
Actually we will have two different Python files for this project.

00:35.240 --> 00:38.390
So I will go in my documents and Python programs.

00:38.390 --> 00:40.700
I'm just going to put the programs here.

00:40.700 --> 00:46.850
And the first one I'm going to start with Python three is project step four.

00:46.850 --> 00:48.320
So that's the first program.

00:48.320 --> 00:53.120
I named it step four because for step one, two, three and four of the solution, I'm going to work

00:53.120 --> 00:54.560
on that program.

00:54.560 --> 00:59.840
So let's start this Python program and let's see what we get first.

00:59.840 --> 01:02.030
So you see we have email setup okay.

01:02.030 --> 01:03.800
So we're going to set up email.

01:03.800 --> 01:06.370
So those are logs that I print in the program.

01:06.580 --> 01:09.640
We're going to set up a mail client to send an email.

01:09.640 --> 01:11.530
We're going to also set up the camera.

01:11.830 --> 01:13.990
We are going to create a log file.

01:14.230 --> 01:20.290
So whenever we take a photo we're going to put the path to the photo inside a log file.

01:20.290 --> 01:22.450
So first we remove it when we start the program.

01:22.450 --> 01:25.510
And then every time we take a photo we add the photo in the log file.

01:25.510 --> 01:29.890
Then we set some gpios with an LED and a Pir sensor.

01:29.890 --> 01:31.870
And finally everything has been set up.

01:31.870 --> 01:33.670
Now what we want to achieve.

01:33.670 --> 01:36.460
So I'm going to show you with the circuit.

01:36.700 --> 01:40.510
So when I make a movement in front of the Pir sensor here.

01:40.510 --> 01:43.210
So I'm going to make a movement for five seconds.

01:43.210 --> 01:49.900
You see whenever the Pir sensor has the motion detected, I also turn on the LED.

01:50.140 --> 01:56.050
Okay, so now I'm making movement, the LED is on and I'm going to stop making movement and stay.

01:56.080 --> 02:03.940
So stay in front of the camera and you see that it's going to take a photo and send it by email okay.

02:04.480 --> 02:10.620
So the rule here is that if you make a movement in front of the Pir sensor so for more than five seconds

02:10.620 --> 02:11.730
and then you stop.

02:11.730 --> 02:15.120
Then the camera is going to take a photo and send it by email.

02:15.120 --> 02:17.970
It's also going to add the path to a log file.

02:18.360 --> 02:21.180
And I am on my email address here.

02:21.180 --> 02:24.870
So you see that I receive a new image.

02:25.170 --> 02:28.650
So those were the the different tests I made.

02:28.650 --> 02:30.180
And those are the two last ones.

02:30.180 --> 02:35.280
So you see we receive a new email from the email address that we have created.

02:35.280 --> 02:39.960
You see check out the new photo and we see the photo that we have taken.

02:39.990 --> 02:40.470
Okay.

02:41.310 --> 02:43.410
So this is the first program.

02:43.440 --> 02:45.120
You monitor the Pir sensor.

02:45.120 --> 02:50.160
So you can use the callback function for example to know when the motion is detected and when the motion

02:50.160 --> 02:56.700
is not detected anymore, and then check that at least five seconds have passed to take a photo and

02:56.700 --> 02:58.170
you send the photo by email.

02:58.200 --> 03:00.300
You also write it inside the log file.

03:00.300 --> 03:04.080
And that's basically, well, that's the main functionality of this project.

03:04.080 --> 03:08.190
Step four of the first program I'm going to stop this one.

03:08.220 --> 03:09.810
Actually you can still run it.

03:09.810 --> 03:10.950
It's not a problem.

03:10.950 --> 03:15.800
And I'm also going to go to my programs again here and run.

03:15.800 --> 03:20.960
So Python three Project Step.

03:21.110 --> 03:22.940
And that's going to be step six okay.

03:22.940 --> 03:27.980
Because in step five and step six we're going to work on the second Python program.

03:27.980 --> 03:35.810
And this one is going to start a flask web server okay I'm going to click here to open this.

03:38.120 --> 03:38.540
Okay.

03:38.540 --> 03:40.010
So that's the home page.

03:40.010 --> 03:42.320
It just says hello.

03:42.350 --> 03:47.720
But then we have slash check photos.

03:52.280 --> 03:54.860
All right so we have a URL check photos.

03:54.890 --> 04:00.590
That's going to say how many new photos were taken since we last checked okay.

04:00.620 --> 04:03.590
Since we last actually went to this page.

04:03.620 --> 04:07.310
It's going to also give us the path to the last photo.

04:07.310 --> 04:08.240
And then.

04:08.270 --> 04:12.110
Well, that's the that's the last photo that was taken by my camera.

04:12.140 --> 04:18.740
Now if I refresh you see we have zero new photo because that's since the last time that I refreshed

04:18.740 --> 04:19.700
this page.

04:19.730 --> 04:21.470
But we still have the last photo here.

04:21.500 --> 04:21.920
All right.

04:21.920 --> 04:27.410
So one program is going to take photos after a movement has been detected for at least five seconds.

04:27.410 --> 04:33.320
And then the other program is going to, well, print the photos and give you some information here

04:33.350 --> 04:34.880
on a web server.

04:34.880 --> 04:37.010
And that's going to be it for this project.

04:37.370 --> 04:41.180
To complete this project, you will need to use each part of this course.

04:41.210 --> 04:46.340
If you are stuck with one part, don't hesitate to come back to the corresponding lessons and watch

04:46.340 --> 04:47.150
them again.

04:47.150 --> 04:50.330
For some parts, you will also need to do your own research.

04:50.360 --> 04:55.640
One thing I encourage you to do is to use Google when you are stuck, or if you want to use a new feature

04:55.640 --> 04:57.410
that we didn't cover before.

04:57.440 --> 05:02.420
If you don't have the habit of searching stuff on Google, it's something you should definitely start

05:02.420 --> 05:03.350
to do right now.

05:03.350 --> 05:08.690
It will help you a lot when programming or using software, and it's something developers do all day

05:08.690 --> 05:09.260
long.

05:09.290 --> 05:10.160
Okay, because here.

05:10.160 --> 05:14.210
Not that I will give you some tips and instructions to get started with the project.

05:14.240 --> 05:21.130
You can also download the PDF with this lesson, but I'm not necessarily going to detail Every instruction

05:21.130 --> 05:22.150
before you get started.

05:22.180 --> 05:26.230
Okay, so it's also up to you to find a way to solve the challenge.

05:26.230 --> 05:31.660
And when working on the project, it's important that you take actually some time to really work by

05:31.660 --> 05:34.030
yourself before you watch the solution.

05:34.030 --> 05:39.250
This is the best way you can make progress and fully understand what you learned before, and I will

05:39.250 --> 05:41.230
provide you with a step by step solution.

05:41.230 --> 05:46.030
Just be aware that the solution I provide is just one solution.

05:46.030 --> 05:48.640
It's not necessarily the solution.

05:48.640 --> 05:54.280
If you can get the same result with a different code, and if it works well, then it's completely valid

05:54.280 --> 05:54.820
as well.

05:54.820 --> 05:57.940
Now the solution I provide will help you in three ways.

05:57.940 --> 06:02.740
First, if you are really stuck in one part, don't waste ten days being stuck.

06:02.770 --> 06:07.150
After some point, it's best to watch the solution and try to understand it.

06:07.180 --> 06:12.550
Second, after you finish the project, you can also see how someone else is thinking about the same

06:12.550 --> 06:13.300
problem.

06:13.300 --> 06:19.060
And third, I will try to give you a solution with clean code and best practices so you can use those

06:19.060 --> 06:22.660
tips to make your programs cleaner and more readable.

06:22.690 --> 06:24.910
All right, and let's start the project.
