This shows you the differences between two versions of the page.
pm:prj2021:agrigore:accesscontrol [2021/05/31 01:33] alexandru.dragus [Software Design] |
pm:prj2021:agrigore:accesscontrol [2021/05/31 10:51] (current) alexandru.dragus [Download] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Access control system ====== | ====== Access control system ====== | ||
- | ** Demo: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] ** | + | ** Demo: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] **\\ |
+ | ** Wiki: {{:pm:prj2021:agrigore:access_control_system_pdf_wiki_final.pdf|Access Control System Tutorial}} ** | ||
===== Autor ===== | ===== Autor ===== | ||
**[[alexandru.dragus@stud.acs.upb.ro|Dragus Alexandru]]**\\ | **[[alexandru.dragus@stud.acs.upb.ro|Dragus Alexandru]]**\\ | ||
Line 17: | Line 18: | ||
==== Schema bloc ==== | ==== Schema bloc ==== | ||
- | {{:pm:prj2021:agrigore:sch_bloc_access_control_system.png?700|}} | + | {{:pm:prj2021:agrigore:sch_bloc_access_control_system-011.jpg?700|}} |
Device-ul din partea de sus, conectat la interfon, va fi referit in continuare prin **''Device interfon''**, si reprezinta un server care asculta pe /door si activeaza un releu. | Device-ul din partea de sus, conectat la interfon, va fi referit in continuare prin **''Device interfon''**, si reprezinta un server care asculta pe /door si activeaza un releu. | ||
Line 62: | Line 64: | ||
=== Device interfon === | === Device interfon === | ||
Device-ul interfon se poate alimenta direct la 3.3V sau la o tensiune intre 7 si 24V. Acesta are atasat un modul de relee prin care poate controla dispozitive cu tensiuni mari. In cazul de fata, releul face contactul la butonul pentru deschiderea portii, semnalul venind printr-un tranzistor, pentru a putea transmite 5V. | Device-ul interfon se poate alimenta direct la 3.3V sau la o tensiune intre 7 si 24V. Acesta are atasat un modul de relee prin care poate controla dispozitive cu tensiuni mari. In cazul de fata, releul face contactul la butonul pentru deschiderea portii, semnalul venind printr-un tranzistor, pentru a putea transmite 5V. | ||
- | {{ :pm:prj2021:agrigore:access_control_system_colaj-2-interfon.png?700 |}} | + | {{ :pm:prj2021:agrigore:access_control_system_colaj-2-interfon-01.jpg?700 |}} |
Device-urile se pot produce si pe placi PCB proiectate in software, dupa cum se vede in exemplul de mai jos, realizat in Eagle. Totodata, Eagle ofera suport pentru proiectarea 3D a placutei, cu ajutorul Fusion360. | Device-urile se pot produce si pe placi PCB proiectate in software, dupa cum se vede in exemplul de mai jos, realizat in Eagle. Totodata, Eagle ofera suport pentru proiectarea 3D a placutei, cu ajutorul Fusion360. | ||
- | {{ :pm:prj2021:agrigore:access_control_system_colaj-1-interfon.png?600 |}} | + | {{ :pm:prj2021:agrigore:access_control_system_colaj-1-interfon-01.jpg?600 |}} |
Imaginile de proiectare PCB/ 3D sunt exemplificative, placa finala avand atasate modulele de releu si regulator 5V in plus. | Imaginile de proiectare PCB/ 3D sunt exemplificative, placa finala avand atasate modulele de releu si regulator 5V in plus. | ||
Line 80: | Line 83: | ||
Imagini din timpul procesului de lipire: | Imagini din timpul procesului de lipire: | ||
- | {{ :pm:prj2021:agrigore:access_control_system_colaj-hub.png?700 |}} | + | {{ :pm:prj2021:agrigore:access_control_system_colaj-hub-01.jpg?700 |}} |
===== Software Design ===== | ===== Software Design ===== | ||
- | * Mediu de dezvoltare: **Arduino IDE** | + | * Mediu de dezvoltare: **Arduino IDE** |
- | * Placute de dezvoltare: **NodeMCU ESP8266** | + | * Placute de dezvoltare: **NodeMCU ESP8266** |
- | * Biblioteci folosite: **ESP8266WiFi, ESPAsyncWebServer, ESP8266HTTPClient** | + | * Biblioteci folosite: **ESP8266WiFi, ESPAsyncWebServer, ESP8266HTTPClient** (link la resurse) |
Aplicatia trebuie sa fie cat mai usor de folosit de catre un utilizator obisnuit, astfel ca am ales o interfata web simpla, cu 3 butoane, cate unul pentru fiecare 'usa' de deschis. Programarea se realizeaza Arduino-like pe placutele NodeMCU ESP8266. | Aplicatia trebuie sa fie cat mai usor de folosit de catre un utilizator obisnuit, astfel ca am ales o interfata web simpla, cu 3 butoane, cate unul pentru fiecare 'usa' de deschis. Programarea se realizeaza Arduino-like pe placutele NodeMCU ESP8266. | ||
+ | |||
+ | ==== Device interfon ==== | ||
+ | Codul are urmatoarea logica: | ||
+ | - Se conecteaza dispozitivul la reteaua de wifi setata | ||
+ | - Se initializeaza un server HTTP, pe portul 80 | ||
+ | - Se asteapta un request ''GET /door'' | ||
+ | - La request, se transmite un semnal HIGH pe pinul D2, care va activa tranzistorul si, in consecinta, releul. Astfel, butonul interfonului va face contact si se va deschide poarta. | ||
+ | - Se returneaza o pagina HTML care redirecteaza utilizatorul la adresa IP statica a ''Device Hub'' | ||
+ | |||
+ | |||
+ | |||
+ | GET /door handler: | ||
+ | <code> | ||
+ | server.on("/door", HTTP_GET, [](AsyncWebServerRequest *request) { | ||
+ | // Send webpage | ||
+ | request->send(200, "text/html", doorWebpage()); | ||
+ | Serial.println("Door pressed"); | ||
+ | timePressDoor = millis(); | ||
+ | doorState = "on"; | ||
+ | | ||
+ | // Send signal for door (relay) | ||
+ | digitalWrite(doorPin, HIGH); | ||
+ | }); | ||
+ | </code> | ||
+ | ==== Device hub ==== | ||
+ | Codul are urmatoarea logica: | ||
+ | - Se conecteaza dispozitivul la reteaua de wifi setata | ||
+ | - Se initializeaza un server HTTP, pe portul 80 | ||
+ | - Se asteapta request-uri: ''GET /garage'', ''GET /carGate'', ''GET /door'' | ||
+ | - Pentru fiecare request, exista un handler care se apeleaza | ||
+ | - Pentru request-urile garage si carGate, se returneaza o pagina care confirma actiunea, redirecteaza utilizatorul la home si seteaza pin-ul corespunzator pe HIGH | ||
+ | - Pentru request-ul ''GET /door'', se redirecteaza utilizatorul spre adresa ''Device interfon'' pentru a face GET acolo | ||
+ | - Dupa un delay prestabilit, se reseteaza pe LOW toti pinii, dupa ce a fost apasat un buton | ||
+ | |||
+ | |||
+ | Exemplu handler GET request: | ||
+ | <code> | ||
+ | server.on("/cargate", HTTP_GET, [](AsyncWebServerRequest *request) { | ||
+ | // Send webpage | ||
+ | request->send(200, "text/html", buttonWebpage("cargate")); | ||
+ | Serial.println("Car gate pressed"); | ||
+ | timePressCarGate = millis(); | ||
+ | carGateState = "on"; | ||
+ | |||
+ | // Send signal for Car gate | ||
+ | digitalWrite(carGatePin, HIGH); | ||
+ | }); | ||
+ | </code>\\ | ||
+ | |||
+ | |||
+ | Functie care returneaza o pagina web simpla: | ||
+ | <code> | ||
+ | String buttonWebpage(String which) { | ||
+ | String webpage = ""; | ||
+ | webpage = webpage + ("<!DOCTYPE html><html>"); | ||
+ | webpage = webpage + ("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"); | ||
+ | webpage = webpage + (""); | ||
+ | webpage = webpage + ("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}"); | ||
+ | webpage = webpage + ("</style>"); | ||
+ | webpage = webpage + ("<meta http-equiv=\"refresh\" content=\"1;url=http://192.168.0.103\" />"); | ||
+ | webpage = webpage + ("</head>"); | ||
+ | webpage = webpage + ("<body><h1>Access system</h1>"); | ||
+ | webpage = webpage + ("<h2>Se deschide "); | ||
+ | if (which == "garage") | ||
+ | webpage = webpage + "garajul"; | ||
+ | else if (which == "cargate") | ||
+ | webpage = webpage + "poarta auto"; | ||
+ | else | ||
+ | webpage = webpage + "poarta mica"; | ||
+ | webpage = webpage + ("</h2>"); | ||
+ | webpage = webpage + ("<br></br><br></br><br></br>"); | ||
+ | webpage = webpage + ("<h3>Proiect realizat in cadrul materiei<br></br>"); | ||
+ | webpage = webpage + ("Proiectarea pe Microprocesoare<br></br>"); | ||
+ | webpage = webpage + ("</body></html>"); | ||
+ | return webpage; | ||
+ | } | ||
+ | </code>\\ | ||
+ | |||
+ | |||
+ | Snippet cod care reseteaza butonul la starea 'neapasat': | ||
+ | <code> | ||
+ | currentTime = millis(); | ||
+ | // Release button if delay time passed | ||
+ | if (garageState == "on" && currentTime - timePressGarage > timeoutButtons) { | ||
+ | garageState = "off"; | ||
+ | digitalWrite(garagePin, LOW); | ||
+ | Serial.println("Garage unpressed"); | ||
+ | } | ||
+ | </code>\\ | ||
+ | == Interfata web minimalista == | ||
+ | {{ :pm:prj2021:agrigore:access_control_system_interfata-01.jpg?300 |}} | ||
===== Rezultate Obtinute ===== | ===== Rezultate Obtinute ===== | ||
** Demo: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] ** | ** Demo: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] ** | ||
Line 96: | Line 191: | ||
Consider ca proiectul la PM a fost o activitate placuta, care mi-a adus mai multa experienta hands-on in domeniul embedded. | Consider ca proiectul la PM a fost o activitate placuta, care mi-a adus mai multa experienta hands-on in domeniul embedded. | ||
===== Download ===== | ===== Download ===== | ||
- | ** [[https://github.com/AlexDragus/access-control|Code and schematics (GitHub)]] ** | + | ** [[https://github.com/AlexDragus/access-control|Code and schematics (GitHub)]] **\\ |
+ | ** {{:pm:prj2021:agrigore:access_control_system_pdf_wiki_final.pdf|Pagina wiki PDF}} **\\ | ||
+ | ** {{:pm:prj2021:agrigore:proiect_pm_access_control_system.zip|Arhiva cod si scheme}} ** | ||
===== Jurnal ===== | ===== Jurnal ===== | ||
Line 116: | Line 213: | ||
* **20 aprilie**: Alegere tema proiect | * **20 aprilie**: Alegere tema proiect | ||
===== Bibliografie/ Resurse ===== | ===== Bibliografie/ Resurse ===== | ||
- | **Demo**: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] | ||
- | |||
- | [[https://ocw.cs.pub.ro/courses/pm/prj2021/agrigore/accesscontrol|Access control system]] | ||
- | [[https://github.com/AlexDragus/access-control|Code and schematics (GitHub)]] | + | * **Demo**: [[https://youtu.be/iJzq9vdDJWI|Control gate and door with ESP8266 via web interface | PM2021 @ ACS, UPB ]] |
+ | * {{:pm:prj2021:agrigore:access_control_system_pdf_wiki_final.pdf|Pagina wiki Final}} | ||
+ | * {{:pm:prj2021:agrigore:access_control_systempdf.pdf|Pagina wiki Etapa 1}} | ||
+ | * [[https://ocw.cs.pub.ro/courses/pm/prj2021/agrigore/accesscontrol|Access control system]] | ||
+ | * [[https://github.com/AlexDragus/access-control|Code and schematics (GitHub)]] | ||
+ | * [[https://randomnerdtutorials.com/esp8266-nodemcu-client-server-wi-fi/|NodeMCU ESP8266 Client and Server tutorial]] | ||
+ | * [[https://github.com/me-no-dev/ESPAsyncWebServer|Biblioteca ESPAsyncWebServer]] | ||
+ | * [[https://github.com/me-no-dev/ESPAsyncTCP|Biblioteca ESPAsyncTCP]] | ||
+ | * [[https://www.componentsinfo.com/wp-content/uploads/2018/11/2n3904-transistor-pinout-equivalent.gif|Schema conectare tranzistor]] | ||
+ | * [[https://components101.com/asset/sites/default/files/component_pin/NodeMCU-ESP8266-Pinout.jpg|Pinout NodeMCU ESP8266]] | ||
- | {{:pm:prj2021:agrigore:access_control_systempdf.pdf|}} | + | <html><a class="media mediafile mf_pdf" href="?do=export_pdf">Export to PDF</a></html> |