Differences

This shows you the differences between two versions of the page.

Link to this comparison view

iothings:proiecte:2023sric:customizablealarmsystem [2024/05/29 23:11]
sergiu.moga
iothings:proiecte:2023sric:customizablealarmsystem [2024/05/30 00:07] (current)
sergiu.moga
Line 3: Line 3:
   * Email: sergiu.moga@protonmail.com   * Email: sergiu.moga@protonmail.com
   * Master: SAS   * Master: SAS
-  * Demo:+  * [[https://​www.youtube.com/​watch?​v=A9WB-9ukaUA|Demo]]
  
 ===== 1. Introduction ===== ===== 1. Introduction =====
Line 17: Line 17:
   * Web interface shows distance to obstacle   * Web interface shows distance to obstacle
  
-{{:​iothings:​proiecte:​2023sric:​esp32_customizable_parking_sensor_layout.jpeg?​200| }}+{{:​iothings:​proiecte:​2023sric:​esp32_customizable_parking_sensor_layout.jpeg?​400x400| }} 
 + 
 +{{:​iothings:​proiecte:​2023sric:​esp32_customizable_alarm_system_poza.jpeg?​400x600|}}
  
 ====== 3. Software ====== ====== 3. Software ======
Line 122: Line 124:
     tone(buzzer_pin,​ (int)current_melody[note],​ note_duration);​     tone(buzzer_pin,​ (int)current_melody[note],​ note_duration);​
     int pause_between_notes = note_duration * 1.30;     int pause_between_notes = note_duration * 1.30;
-    Serial.println(pause_between_notes);​ 
     delay(pause_between_notes);​     delay(pause_between_notes);​
     noTone(buzzer_pin);​     noTone(buzzer_pin);​
Line 215: Line 216:
 } }
 </​code>​ </​code>​
 +
 +====== Setup ======
 +
 +  * Begin Serial Communication:​ Initializes the serial communication for debugging.
 +  * Mount SD Card: Attempts to mount the SD card. If successful, it checks if the root directory exists and is accessible.
 +  * Retrieve File Information:​ Iterates through each file in the root directory, reads the duration, melody, and name of each file, and stores them in respective arrays.
 +  * Initialize Pins: Sets the pinMode for the buzzer, trigger, and echo pins.
 +  * Connect to WiFi: Attempts to connect to the specified WiFi network.
 +  * Start Web Server: Begins hosting a web server on port 80.
 +  * Sets the initial melody, duration, and size to the first music file.
 +
 +====== Loop ======
 +
 +  * Check for Client Connection: Listens for incoming client connections on the web server.
 +  * Handle Client Requests: If a client connects, the code checks for available data from the client.
 +  * Parse HTTP Request: Reads the HTTP request and extracts the requested file name.
 +  * Find Matching File: Searches for the requested file name in the list of available music files.
 +  * Generate HTML Response: Constructs an HTML response containing buttons for each music file, highlighting the currently selected file.
 +  * Respond to Client: Sends the HTML response to the client.
 +  * Handle Note Playback and Distance Update: While waiting for client requests or after responding to a request, the code continuously plays notes from the selected melody and updates the distance reading from the sensor. The playback speed of the melody is adjusted based on the proximity of obstacles detected by the distance sensor.
 +
 +====== File format ======
 +In this project, music files are stored on the SD card using a specific format. Each track is divided into two separate files: <​trackname>​.notes and <​trackname>​.durations. The .notes file contains the musical notes represented by 2 bytes each, while the .durations file stores the corresponding durations for each note, with each duration being one byte.
 +
 +This file organization ensures efficient data management and retrieval during playback. The separation of notes and durations allows for flexibility in managing musical data. The system can easily access and interpret the musical notes and their durations independently,​ enabling seamless playback of various melodies and compositions.
 +
 +The tracks were taken from [[https://​github.com/​hibit-dev/​buzzer|hibit-dev'​s buzzer repository]].
 +
 +====== Web UI ======
 +This is where the user can select the tracks.
 +
 +{{:​iothings:​proiecte:​2023sric:​esp_32_customizable_alarm_system_web_ui.png?​1000x200|}}
 +
 +
 +===== References =====
 +
 +https://​github.com/​hibit-dev/​buzzer
 +
 +https://​ocw.cs.pub.ro/​courses/​iothings/​laboratoare/​2022/​lab3
 +
 +https://​randomnerdtutorials.com/​esp32-microsd-card-arduino/​
 +
 +https://​randomnerdtutorials.com/​esp32-hc-sr04-ultrasonic-arduino/​
 +
 +https://​randomnerdtutorials.com/​esp32-web-server-arduino-ide/​
 +
  
iothings/proiecte/2023sric/customizablealarmsystem.1717013472.txt.gz · Last modified: 2024/05/29 23:11 by sergiu.moga
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0