{"id":21014990,"url":"https://github.com/ishwar-ikm/collision-detection-using-iot","last_synced_at":"2026-04-19T05:32:52.709Z","repository":{"id":263116708,"uuid":"878595980","full_name":"ishwar-ikm/Collision-Detection-using-IoT","owner":"ishwar-ikm","description":"This project uses an ESP32 to detect collisions by monitoring impact, orientation (via gyroscope), temperature, and GPS location. The data is sent to a Node.js backend using Socket.IO for real-time processing and secure user authentication. The system provides a seamless way to track and respond to collision events.","archived":false,"fork":false,"pushed_at":"2024-11-16T09:37:19.000Z","size":82,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-13T16:40:27.684Z","etag":null,"topics":["collision-detection","esp32","internet-of-things-iot","mern-stack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ishwar-ikm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-25T17:23:54.000Z","updated_at":"2024-11-16T09:48:20.000Z","dependencies_parsed_at":"2024-11-16T10:20:28.665Z","dependency_job_id":"844a898d-eddc-4ec9-a494-ea8b6f59c2e9","html_url":"https://github.com/ishwar-ikm/Collision-Detection-using-IoT","commit_stats":null,"previous_names":["ishwar-ikm/collision-detection-using-iot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ishwar-ikm/Collision-Detection-using-IoT","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishwar-ikm%2FCollision-Detection-using-IoT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishwar-ikm%2FCollision-Detection-using-IoT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishwar-ikm%2FCollision-Detection-using-IoT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishwar-ikm%2FCollision-Detection-using-IoT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ishwar-ikm","download_url":"https://codeload.github.com/ishwar-ikm/Collision-Detection-using-IoT/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishwar-ikm%2FCollision-Detection-using-IoT/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280965076,"owners_count":26421548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collision-detection","esp32","internet-of-things-iot","mern-stack"],"created_at":"2024-11-19T10:08:08.040Z","updated_at":"2025-10-25T13:48:57.731Z","avatar_url":"https://github.com/ishwar-ikm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Collision Detection System Using ESP32, Node.js, and React\n\n## Project Overview\n\nThis project is a **Collision Detection System** that utilizes an ESP32 microcontroller equipped with an MPU6050 sensor and an impact sensor (YL-99) to detect accidents or collisions. The system records data such as **impact level**, **orientation**, **temperature**, and **location**, and sends it to a **Node.js backend** via HTTP. The backend stores the data in a MongoDB database, notifies connected clients in real-time using Socket.IO, and provides APIs for data retrieval. A **React-based frontend** is included to display and visualize collision data in real time.\n\n### Features:\n1. **ESP32 Sensor Integration:**\n   - Detects acceleration, gyroscopic changes, and temperature using the MPU6050.\n   - Monitors impact levels using the YL-99 sensor.\n   - Hardcoded GPS coordinates simulate real-time location data.\n\n2. **Backend Integration:**\n   - A Node.js server stores collision data in a MongoDB database.\n   - Provides APIs for recording and fetching collision data.\n   - Notifies connected clients of new collision events using Socket.IO.\n\n3. **Frontend Integration:**\n   - Displays real-time collision data using a React app.\n\n4. **Real-time Updates:**\n   - The backend broadcasts new collision data to all connected clients in real-time.\n\n---\n\n## How It Works\n\n1. **Collision Detection:**\n   - The ESP32 continuously monitors sensor data (acceleration, temperature, impact).\n   - A collision is detected when predefined thresholds are crossed (e.g., acceleration \u003e 14 m/s², temperature \u003e 35°C, or an impact is detected) threshold values can be changed accordingly.\n\n2. **Data Transmission:**\n   - When a collision is detected, the ESP32 formats the data as a JSON object and sends it to the backend API using HTTP.\n\n3. **Data Storage:**\n   - The backend stores the collision data in a MongoDB database, ensuring it is timestamped for historical analysis.\n\n4. **Real-time Notifications:**\n   - The backend continuously monitors new collision events and uses Socket.IO to broadcast updates to connected clients.\n\n5. **Frontend Visualization:**\n   - The React frontend fetches collision data from the backend and displays it in a user-friendly dashboard, updating in real-time.\n\n---\n\n## Prerequisites\n\n### Hardware Requirements:\n- ESP32 Development Board\n- MPU6050 Accelerometer and Gyroscope\n- YL-99 Impact Sensor\n- Breadboard and Connecting Wires\n- WiFi Access Point for ESP32\n\n### Software Requirements:\n- Node.js (v14+ recommended)\n- MongoDB\n- Ngrok (for exposing the local server to the internet)\n- React (included in the `frontend` folder)\n- ESP32 Arduino Core (installed via Arduino IDE or PlatformIO)\n\n---\n\n## Project Setup\n\n### Step 1: Clone the Repository\nClone the project repository to your local machine:\n```bash\ngit clone \u003crepository-url\u003e\ncd \u003crepository-folder\u003e\n```\n\n---\n\n### Step 2: Configure the Backend\n\n1. **Install Dependencies:**\n   Navigate to the root directory and install dependencies:\n   ```bash\n   npm install\n   ```\n\n2. **Set Up Environment Variables:**\n   Create a `.env` file in the project root with the following content:\n   ```env\n   MONGODB_URI=mongodb://localhost:27017/collision_detection\n   NODE_ENV=development\n   ```\n\n3. **Start the Server:**\n   Start the backend server:\n   ```bash\n   npm run dev\n   ```\n   You should see messages confirming the server and MongoDB connection:\n   ```\n   Connected to MongoDB\n   Server listening on port 3000\n   ```\n\n---\n\n### Step 3: Set Up the Frontend\n\n1. **Install Dependencies:**\n   Navigate to the `frontend` folder:\n   ```bash\n   cd frontend\n   npm install\n   ```\n\n2. **Start the Frontend:**\n   Run the following command to start the React app:\n   ```bash\n   npm run dev\n   ```\n   The frontend will be accessible at `http://localhost:5173`.\n\n---\n\n### Step 4: Expose the Backend Using Ngrok\n\n1. **Install Ngrok:**\n   Install Ngrok if not already installed:\n   ```bash\n   npm install -g ngrok\n   ```\n\n2. **Start Ngrok:**\n   Expose the backend server to the internet:\n   ```bash\n   ngrok http 3000\n   ```\n   Copy the generated public URL (e.g., `https://xyz.ngrok.io`) for use in the ESP32 code.\n\n---\n\n### Step 5: Configure the ESP32 Code\n\n1. **Update WiFi Credentials:**\n   Replace the placeholders in the ESP32 code with your WiFi SSID and password:\n   ```cpp\n   const char* ssid = \"Your wifi username\";\n   const char* password = \"Your wifi password\";\n   ```\n\n2. **Set the Server URL:**\n   Update the `serverUrl` variable with the Ngrok URL:\n   ```cpp\n   const char* serverUrl = \"https://xyz.ngrok.io/api/collisions\";\n   ```\n\n3. **Upload the Code to ESP32:**\n   Compile and upload the ESP32 code using the Arduino IDE or PlatformIO.\n\n---\n\n### Step 6: Monitor the System\n\n1. **ESP32 Serial Monitor:**\n   Open the serial monitor on your IDE to view sensor readings and HTTP response logs.\n\n2. **Frontend Dashboard:**\n   Open the React app in your browser (`http://localhost:5173`) to visualize collision data in real-time.\n\n---\n\n## API Endpoints\n\n### POST `/api/collisions`\n- **Description:** Stores collision data sent by the ESP32.\n- **Request Body:**\n  ```json\n  {\n    \"impact\": \"High\",\n    \"temperature\": 37,\n    \"orientation\": \"Tilted\",\n    \"location\": { \"lat\": \"12.9716\", \"long\": \"77.5946\" }\n  }\n  ```\n- **Response:**\n  ```json\n  {\n    \"message\": \"Collision data saved successfully!\"\n  }\n  ```\n\n### WebSocket `/`\n- **Description:** Broadcasts real-time collision data to connected clients.\n- **Event:** `newCollisionData`\n- **Payload:**\n  ```json\n  [\n    {\n      \"impact\": \"High\",\n      \"temperature\": 37,\n      \"orientation\": \"Tilted\",\n      \"location\": { \"lat\": \"12.9716\", \"long\": \"77.5946\" },\n      \"createdAt\": \"2024-11-16T12:34:56.789Z\"\n    }\n  ]\n  ```\n\n---\n\n## Future Enhancements\n\n1. **GPS Integration:**\n   - Use a GPS module with the ESP32 for dynamic location tracking.\n\n2. **Enhanced Frontend:**\n   - Add charts, filters, and search functionality to the React dashboard.\n\n3. **Alert System:**\n   - Integrate SMS or email notifications for critical collisions.\n\n---\n\nThis project demonstrates a fully integrated IoT solution with sensor data acquisition, real-time data processing, and interactive visualization. 🚀","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishwar-ikm%2Fcollision-detection-using-iot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishwar-ikm%2Fcollision-detection-using-iot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishwar-ikm%2Fcollision-detection-using-iot/lists"}