It's now time to start the final project of this course.
You have now completed all the learning steps and have a great knowledge foundation that you can use
for any new project, including the one you are about to start right now.
The project will be great for you to practice on everything you have seen in this course, and it will
be your first real big project with a Raspberry Pi.
So what is this project about?
Here is the final result you will get at the end.
So I am on the Raspberry Pi and I'm going to start the project.
Actually we will have two different Python files for this project.
So I will go in my documents and Python programs.
I'm just going to put the programs here.
And the first one I'm going to start with Python three is project step four.
So that's the first program.
I named it step four because for step one, two, three and four of the solution, I'm going to work
on that program.
So let's start this Python program and let's see what we get first.
So you see we have email setup okay.
So we're going to set up email.
So those are logs that I print in the program.
We're going to set up a mail client to send an email.
We're going to also set up the camera.
We are going to create a log file.
So whenever we take a photo we're going to put the path to the photo inside a log file.
So first we remove it when we start the program.
And then every time we take a photo we add the photo in the log file.
Then we set some gpios with an LED and a Pir sensor.
And finally everything has been set up.
Now what we want to achieve.
So I'm going to show you with the circuit.
So when I make a movement in front of the Pir sensor here.
So I'm going to make a movement for five seconds.
You see whenever the Pir sensor has the motion detected, I also turn on the LED.
Okay, so now I'm making movement, the LED is on and I'm going to stop making movement and stay.
So stay in front of the camera and you see that it's going to take a photo and send it by email okay.
So the rule here is that if you make a movement in front of the Pir sensor so for more than five seconds
and then you stop.
Then the camera is going to take a photo and send it by email.
It's also going to add the path to a log file.
And I am on my email address here.
So you see that I receive a new image.
So those were the the different tests I made.
And those are the two last ones.
So you see we receive a new email from the email address that we have created.
You see check out the new photo and we see the photo that we have taken.
Okay.
So this is the first program.
You monitor the Pir sensor.
So you can use the callback function for example to know when the motion is detected and when the motion
is not detected anymore, and then check that at least five seconds have passed to take a photo and
you send the photo by email.
You also write it inside the log file.
And that's basically, well, that's the main functionality of this project.
Step four of the first program I'm going to stop this one.
Actually you can still run it.
It's not a problem.
And I'm also going to go to my programs again here and run.
So Python three Project Step.
And that's going to be step six okay.
Because in step five and step six we're going to work on the second Python program.
And this one is going to start a flask web server okay I'm going to click here to open this.
Okay.
So that's the home page.
It just says hello.
But then we have slash check photos.
All right so we have a URL check photos.
That's going to say how many new photos were taken since we last checked okay.
Since we last actually went to this page.
It's going to also give us the path to the last photo.
And then.
Well, that's the that's the last photo that was taken by my camera.
Now if I refresh you see we have zero new photo because that's since the last time that I refreshed
this page.
But we still have the last photo here.
All right.
So one program is going to take photos after a movement has been detected for at least five seconds.
And then the other program is going to, well, print the photos and give you some information here
on a web server.
And that's going to be it for this project.
To complete this project, you will need to use each part of this course.
If you are stuck with one part, don't hesitate to come back to the corresponding lessons and watch
them again.
For some parts, you will also need to do your own research.
One thing I encourage you to do is to use Google when you are stuck, or if you want to use a new feature
that we didn't cover before.
If you don't have the habit of searching stuff on Google, it's something you should definitely start
to do right now.
It will help you a lot when programming or using software, and it's something developers do all day
long.
Okay, because here.
Not that I will give you some tips and instructions to get started with the project.
You can also download the PDF with this lesson, but I'm not necessarily going to detail Every instruction
before you get started.
Okay, so it's also up to you to find a way to solve the challenge.
And when working on the project, it's important that you take actually some time to really work by
yourself before you watch the solution.
This is the best way you can make progress and fully understand what you learned before, and I will
provide you with a step by step solution.
Just be aware that the solution I provide is just one solution.
It's not necessarily the solution.
If you can get the same result with a different code, and if it works well, then it's completely valid
as well.
Now the solution I provide will help you in three ways.
First, if you are really stuck in one part, don't waste ten days being stuck.
After some point, it's best to watch the solution and try to understand it.
Second, after you finish the project, you can also see how someone else is thinking about the same
problem.
And third, I will try to give you a solution with clean code and best practices so you can use those
tips to make your programs cleaner and more readable.
All right, and let's start the project.