Table of Contents

Sistem Usa Smart

Introducere

Un sistem pentru o usa inteligenta ce va avea următorul comportament:

Prezentare

Proiectul consta intr-un sistem de securitate pentru usi bazat pe recunoastere faciala si control remote asupra usii.

Ideea

Sunt o persoana foarte dezordonata care uita/pierde cheile tot timpul. Asa ca m-am gandit sa-mi usurez viata folosind acest sistem.

Descriere generală

Placuta de Arduino este alimentata la o sursa obisnuita introdusa in priza. Senzorii (de proximitate) sunt conectati la placuta si vor citi mereu datele din mediul inconjurator. Modulul de camera este conectat la placuta si asteapta ca senzorii sa detecteze miscare pentru a transmite imaginile catre server. Un releu conectat la placuta si o sursa pentru alimentarea yalei electromagnetice.

Schema Bloc

Hardware Design

Schema Circuit

Aici puneţi tot ce ţine de hardware design:

Software Design

Mediu De Dezvoltare

Biblioteci

Organizarea Codului

Arduino

#include "setup.h"
 
// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
const int outPin = 11;
// defines variables
long duration;
int distance;
 
void setup() {
  CLKPR = 0x80; // enter clock rate change mode
  CLKPR = 0; // set prescaler to 0. WAVGAT MCU has it 3 by default.
 
  pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
  pinMode(echoPin, INPUT); // Sets the echoPin as an Input
  pinMode(outPin, OUTPUT);
  Serial.begin(9600); // Starts the serial communication
 
  initializeScreenAndCamera();
}
 
void loop() {
 
  // Clears the trigPin
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  // Sets the trigPin on HIGH state for 10 micro seconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Reads the echoPin, returns the sound wave travel time in microseconds
  duration = pulseIn(echoPin, HIGH);
  // Calculating the distance
  distance = duration * 0.034 / 2;
 
  if(distance < 20){
    for(int i = 0; i < 10; i++){
      char serverResponse = processFrame();
      if(serverResponse == 1){
        digitalWrite(outPin, HIGH);
        delay(25000);
        digitalWrite(outPin, LOW);
        break;
      }
    }
  }
}
char processFrame() {
  processedByteCountDuringCameraRead = 0;
  commandStartNewFrame(uartPixelFormat);
  noInterrupts();
  processFrameData();
  interrupts();
  frameCounter++;
  commandDebugPrint("Frame " + String(frameCounter)/* + " " + String(processedByteCountDuringCameraRead)*/);
 
  // wait for the server to check the frame
  while(!Serial.available()){}
  char serverResponse = Serial.read(); 
 
  return serverResponse;
}

Java

Functia adaugata de mine este urmatoarea:
  private void sendImageToServer(BufferedImage image, File toFolder) {
    try {
      // Save image to PNG file
      File newFile = new File(toFolder.getAbsolutePath(), getNextFileName());
      ImageIO.write(image, "png", newFile);
 
      // Read the image file as bytes
      byte[] imageData = Files.readAllBytes(newFile.toPath());
 
      // Encode the image bytes as Base64
      String base64Image = Base64.getEncoder().encodeToString(imageData);
 
      // Set up the URL and connection
      URL url = new URL("http://localhost:5000/upload");
      HttpURLConnection connection = (HttpURLConnection) url.openConnection();
      connection.setRequestMethod("POST");
      connection.setRequestProperty("Content-Type", "application/json");
      connection.setDoOutput(true);
 
      // Create the JSON payload
      JSONObject jsonPayload = new JSONObject();
      jsonPayload.put("image", base64Image);
 
      // Write the JSON payload to the request body
      OutputStream outputStream = connection.getOutputStream();
      outputStream.write(jsonPayload.toString().getBytes());
      outputStream.flush();
 
      // Read the response from the server
      int responseCode = connection.getResponseCode();
      if (responseCode == HttpURLConnection.HTTP_OK) {
        System.out.println("Server response: OK");
        serialReader.sendResponse(1);
      } else {
        System.out.println("Unexpected server response code: " + responseCode);
        serialReader.sendResponse(0);
      }
 
      // Close the connection
      connection.disconnect();
 
      saveCountLabel.setText(" (" + (++saveCounter) + ")");
    } catch (IOException e) {
      System.out.println("Sending file failed: " + e.getMessage());
    }
  }

Flask - Flutter

Am facut o aplicatie full-stack minimalista care are urmatoarele functionalitati in cadrul proiectului

Rezultate Obţinute

In urma proiectului, am obtinut o usa inteligenta care permite intrarea persoanelor autorizate si o aplicatie mobila pentru gestionarea usii.

Concluzii

A fost un proiect interesant in care am intampinat foarte multe probleme din care am putut invata. Totodata, pe langa cunostintele practice obtinute, am dobandit si o intelegere teoretica asupra diferitelor concepte utilizate.

Download

barbuta_app_final.zip barbuta_arduino.zip barbuta_java_final.zip

Bibliografie/Resurse

Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe *Resurse Software* şi *Resurse Hardware*.

Export to PDF