A comprehensive IoT solution for remote door lock control using Laravel API backend and ESP32 microcontroller. This system enables secure, real-time communication between a web dashboard and physical door locks via WiFi.
- Web Dashboard: User-friendly interface for sending lock/unlock/status commands
- RESTful API: Secure endpoints for command management and status updates
- ESP32 Integration: Microcontroller polls for commands and controls relays/LEDs
- API Authentication: Key-based authentication for ESP32 communication
- Real-time Status: Live feedback on command execution and door status
- Mobile Responsive: Optimized for desktop and mobile devices
- WiFi Reconnection: Automatic reconnection handling for ESP32
- Backend: Laravel 11 (PHP)
- Database: SQLite/MySQL
- Frontend: Blade templates with Tailwind CSS
- Microcontroller: ESP32 with Arduino IDE
- Communication: HTTP REST API with JSON
- Authentication: API key middleware
- PHP 8.1+
- Composer
- Node.js & NPM
- Arduino IDE with ESP32 board support
- ESP32 microcontroller
-
Clone the repository:
git clone https://github.com/ginxFromYt/ARDUINO_API.git cd ARDUINO_API -
Install PHP dependencies:
composer install
-
Install Node dependencies:
npm install
-
Copy environment file:
cp .env.example .env
-
Generate application key:
php artisan key:generate
-
Set up database (SQLite by default):
php artisan migrate --seed
-
Build assets:
npm run build
-
Start the server:
php artisan serve --host=0.0.0.0 --port=8000
- Install Arduino IDE and ESP32 board support
- Open the provided ESP32 sketch
- Update WiFi credentials and API details
- Upload to ESP32 board
POST /api/login- User authenticationPOST /api/door/command- Send command (lock/unlock/status)GET /api/door/status- Get door status
GET /api/door/command- Fetch pending commandsPOST /api/door/status- Update door status
GET /- Welcome page
- GPIO 23: Relay control (door lock mechanism)
- GPIO 19: Green LED (locked indicator)
- GPIO 18: Red LED (unlocked indicator)
- GPIO 5: White LED (status indicator)
- GPIO 2: Built-in LED (fallback)
- S (Signal): ESP32 GPIO 23
-
- (VCC): ESP32 5V
-
- (GND): ESP32 GND
- COM/NO: Connect to solenoid lock
- Anode (+): GPIO via 330Ω resistor
- Cathode (-): ESP32 GND
- Access the web dashboard at
http://localhost:8000/dashboard - Log in with seeded user credentials
- Use the ESP32 Control Panel to send commands
- ESP32 will poll for commands every 5 seconds
- Commands are executed with LED/relay feedback
- Status updates are sent back to the API
APP_NAME: Application nameAPP_ENV: Environment (local/production)APP_KEY: Laravel app keyDB_CONNECTION: Database typeESP32_API_KEY: API key for ESP32 authentication
- Update
ssidandpasswordfor WiFi - Set
serverIPto your Laravel server IP - Ensure
apiKeymatches.envvalue
- API key authentication for ESP32 endpoints
- CSRF protection on web forms
- Input validation on all endpoints
- Secure password hashing
php artisan test./vendor/bin/pintnpm run dev
npm run build- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Open an issue on GitHub
- Check the documentation
- Review the code comments
Note: This is an educational/demo project. For production use, implement additional security measures and hardware safeguards.