# SoA Course Project - Intelligent Doorbell
###### tags: `Python3` `SoA`
## Introduction
Smart Doorbell is a home monitoring system that contains monitoring devices - ESP32 and web services, This project involoved IoT, Web design and server management. The device can easilly connect to the Wi-Fi by smartphone app "ESP SmartConfig", after successfully connected to internet, it will start detection and post picture to server, then user can use the browser to see all the picture which captured by devices.
The monitoring device uses PIR sensors to detect people or objects and uses a camera module to take pictures, and then sends the pictures to a file server, and it can be multiple devices.
The webpage can view the pictures on the file server and provide some command to control the monitoring device, like reboot device, take picture manually, set device name.
### Video
{%youtube b9Y3Rg6tNjM %}
### Slide
<iframe src="https://www.slideshare.net/slideshow/embed_code/key/juVLW1oN7VXEC" width="750" height="450" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe> <div style="margin-bottom:5px"> <strong> <a href="https://www.slideshare.net/ssuser94c119/soa-course-project-intelligent-doorbellnovideopptx" title="SoA Course Project Intelligent Doorbell_No_Video.pptx" target="_blank">SoA Course Project Intelligent Doorbell_No_Video.pptx</a> </strong> from <strong><a href="https://www.slideshare.net/ssuser94c119" target="_blank">TsunPing Chen</a></strong> </div>
## Mind chart
```markmap
# intelligent door bell
## System Architecture
### Server
- WebServer
- Django - “Base on Python”
- Picture gallery
- Sent commands.
- Reset module
- Set module name
- Take picture manually
- Get/Sync module time
- File server
- Save Picture to Folder
### Module
- PIR Sensor
- ESP32-CAM
- Take picture
- UDP Client recv. commands.
- FTP Client Sent. images.
- SNTP (Time Sync) Time as picture name
## Features
### WiFi SmartConfig
### Reset WiFi config by button
### Indicate LED
### BSD Socket API
### Take Picture and Post to server
- Use the ESP32-CAM’s MAC Address as the Tag, and this tag can modify on web page.
## Power
### Power Adapter USB 5V
## Device appearance
### Use the existed 3D models.
```
## Gantt chart
```mermaid
gantt
title Intelligent doorbell
section ESP32-CAM Firmware
Learn the ESP-IDF :a1, 2022-04-09, 14d
Coding from examples :after a1 , 24d
section Webpage design
Webpage design :a2, 2022-04-17 , 30d
Deploy server : 2022-05-12 ,7d
section System test & Debug
Debug :2022-05-13 , 14d
section Prepare for final project demo
Final test :2022-05-25 , 7d
```
## Web page design
Using a Django web framework to provide a web page.
### which provide...
* Photo gallery
* Access the photos which stored in the server.
* Device control
* Developer profile
#### References
* Bootstrap 4:[Link](https://getbootstrap.com)
* Profile card:[Link](https://codepen.io/littlesnippets/pen/PPqNXY)
* How to create Photo Gallery with Django:[Link](https://roytuts.com/how-to-create-photo-gallery-with-django/)
* css-doodle background:[Link](https://codepen.io/oliverturner/pen/ROpZwB)
* Web page icon:[Link](https://ionic.io/ionicons/v4)
* Gallery Layout:[Link](https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_image_grid_responsive)
## Device Firmware design
### Materials
* Device:Espressif ESP-32 CAM Module
* Device Features:[Link](https://www.seeedstudio.com/ESP32-CAM-Development-Board-with-camer-p-3153.html)
* Programming language:C
* DEV Tools
* ESP-IDF [espressif official guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/vscode-setup.html)
### Flowchart
The system is using FreeRTOS as operating system, the code is modified and combined from espressif official examples.
1. Power up process
<iframe frameborder="0" style="width:100%;height:582px;" src="https://viewer.diagrams.net/?highlight=0000ff&nav=1&title=IntelligentDoorBell.drawio.svg#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1jFotUqHj1DWcXRsDq6cmi1qC1LBBAqWH%26export%3Ddownload"></iframe>
2. Main task
<iframe frameborder="0" style="width:100%;height:471px;" src="https://viewer.diagrams.net/?highlight=0000ff&nav=1&title=IntelligentDoorBell_Main.drawio.svg#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1rI5WoWQSTm4U2R3MxmHvyhnKgIcbHQNt%26export%3Ddownload"></iframe>
3. Initialize WiFi
<iframe frameborder="0" style="width:100%;height:373px;" src="https://viewer.diagrams.net/?highlight=0000ff&nav=1&title=IntelligentDoorBell_WiFi.drawio.svg#Uhttps%3A%2F%2Fdrive.google.com%2Fuc%3Fid%3D1Iwx9env44kykWTieZZADScSs-I7zaPqZ%26export%3Ddownload"></iframe>
### Reference
* Wi-Fi SmartConfig API [espressif official guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_smartconfig.html)
* Using smartphone to config esp32's Wi-Fi connection。
* FreeRTOS API [espressif official guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/freertos.html)
* BSD Sockets API [espressif official guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/lwip.html)
* SNTP API [espressif official guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/system_time.html)
* ESP32 FTP client [GitHub](https://github.com/JohnnyB1290/ESP32-FTP-Client)
* ESP32 camera driver [GitHub](https://github.com/espressif/esp32-camera)
## Device Prototype
### Final Prototype

### Prototype 01
