Specification Document - Arduino-Based Barrier
Control System
1. Introduction
1.1 Objective
Develop a reliable, secure, and user-friendly program for an ESP32-based Arduino system that
controls a barrier motor via GPIO, triggered by authenticated HTTP POST requests. The system is
designed for demo purposes, to be installed inside a presentation box in an office environment.
1.2 Intended Use
The barrier will be opened remotely through network requests, showcasing secure IoT motor
control via Wi-Fi in a real-time setting to clients or stakeholders.
2. System Overview
- Microcontroller: ESP32 (recommended for built-in Wi-Fi and multiple GPIO support).
- Connectivity: Wi-Fi (default), Ethernet optional.
- Motor: Servo motor (e.g., SG90), requiring minimal power (few mA).
- Control Method: HTTP POST requests received by Arduino (acting as HTTP server).
- Security: Static token-based authentication.
- Interface: Serial monitor for logging.
3. Functional Requirements
3.1 Wi-Fi Configuration
- Automatically connect to predefined SSID and password.
- Optional fallback to captive portal (via WiFiManager) for dynamic setup if needed.
3.2 HTTP Server on ESP32
- Host a minimal HTTP server listening on port 80.
- Expose an endpoint (e.g., /open) that accepts HTTP POST requests.
3.3 Authentication
- Accept request only if a predefined token is included in:
- Authorization header (Authorization: Bearer <TOKEN>)
- Return appropriate HTTP status:
- 200 OK for success.
- 401 Unauthorized for invalid/missing token.
- 405 Method Not Allowed for non-POST requests.
3.4 Barrier Control via GPIO
- Use a servo motor connected to a digital GPIO pin (e.g., D12).
- Move servo from 0° to 90°, hold for 3 seconds, then return to 0°.
3.5 Serial Monitoring
- Output logs via serial interface (115200 baud), including:
- Wi-Fi connection status
- Incoming requests
- Authentication status
- Barrier open/close actions
4. Deliverables
4.1 Source Code
- Clean and well-commented .ino file.
- Includes:
- Wi-Fi connection logic
- HTTP server setup
- Token authentication
- GPIO control for servo motor
- Serial debug output
4.2 Wiring Diagram
- Simple diagram showing:
- ESP32 pin to servo (e.g., GPIO12)
- Power supply (typically USB for demo)
- Ground connections
4.3 README File
- Plain text or Markdown file including:
- Hardware requirements
- Pin mapping
- Setup instructions (Wi-Fi, token)
- How to test with curl or Postman
- Troubleshooting tips
5. Hardware Specification
Component | Description
------------- | ---------------------------
Microcontroller | ESP32 (NodeMCU ESP32 DevKit or similar)
Motor | SG90 micro servo (3-pin, 5V)
Power | 5V USB (typical via computer or power bank)
Wiring | Jumper wires for GPIO/servo connection
6. Security Considerations
- Authentication based on static token.
- No sensitive operations without valid token.
- Optional: Add IP whitelist or rate limiting if needed in future.
- HTTPS not implemented due to ESP32 constraints, but can be discussed.
7. Environmental Context
- The project is a demo in a controlled, indoor office setting.
- Enclosure (box) will be used to visually show the movement of the servo.
- No external power or harsh conditions expected.
8. Optional Enhancements (future)
- Support for HTTPS with client certificate
- Web-based configuration portal (WiFiManager)
- Over-the-air (OTA) updates
- Logging to external cloud service
- Local dashboard interface for manual control