Skip to content

arman41nb/OTA-ESP32

Repository files navigation

<<<<<<< HEAD

ESP32 Remote File Manager & Code Deployment System

A comprehensive MicroPython-based file management and remote code deployment system for ESP32 boards. This system allows you to manage files, upload code wirelessly, and configure WiFi settings through a captive portal interface.

🌟 Features

  • Hardware Button Mode Selection: Choose between different operation modes using physical buttons
  • Smart WiFi Management: Automatic connection to stored WiFi credentials with fallback to captive portal
  • Captive Portal: Easy WiFi configuration through a web interface
  • Remote Code Upload: Upload Python files via HTTP API
  • File Management: List, read, write, and delete files on ESP32 filesystem
  • Auto-Restart: Automatic restart after uploading main.py
  • Multiple Operation Modes: Different file managers for various use cases

📋 Requirements

  • ESP32 board (tested on ESP32-WROOM-32)
  • MicroPython firmware installed
  • WiFi connectivity
  • Two push buttons (optional, for mode selection)

🚀 Quick Start

Hardware Setup

  1. Button Configuration (Optional):

    • Connect Button A to GPIO14 (with pull-up resistor)
    • Connect Button B to GPIO27 (with pull-up resistor)
  2. Upload Files: Upload all Python files to your ESP32 board root directory

Software Setup

  1. Initial Boot:

    # The system will automatically start based on button states:
    # - No buttons pressed: runs main.py (LED blinker demo)
    # - Button A pressed: runs file_manager_A.py
    # - Button B pressed: runs file_manager_B.py
  2. WiFi Configuration:

    • On first run, the system creates a captive portal
    • Connect to "PoulStar" WiFi network (password: 12345678)
    • Configure your WiFi credentials through the web interface

📁 Project Structure

esp32-file-manager/
├── boot.py              # Boot manager with hardware button selection
├── main.py              # Default LED blinker program
├── file_manager.py      # Main file management system
├── captive_portal_lib.py # Captive portal library for WiFi setup
├── config.txt           # WiFi credentials storage (auto-generated)
├── config.json          # Additional configuration storage (auto-generated)
└── README.md           # This file

🔧 Configuration Files

config.txt

Stores WiFi credentials in the format:

YourWiFiSSID
YourWiFiPassword

config.json

Stores additional configuration:

{
  "ssid": "YourWiFiSSID",
  "password": "YourWiFiPassword"
}

📖 Usage

Mode Selection

Boot Modes:

  • Normal Mode: No buttons pressed - runs main.py
  • File Manager Mode: Press Button A or B during boot - runs file_manager.py

File Operations

The file manager provides:

  • List Files: Displays all files in the root directory
  • Read Files: Shows content of existing files
  • Upload Code: HTTP endpoint for remote code upload

Code Upload API

Endpoint: http://esp32-ip-address/

Method: POST

Content-Type: application/json

Payload:

{
  "filename": "my_script.py",
  "code": "print('Hello from ESP32!')"
}

Response:

Code written to my_script.py

🔌 API Reference

HTTP Endpoints

  • POST / - Upload code file
    • Content-Type: application/json
    • Body: {"filename": "name.py", "code": "python code"}

Boot Process

  1. Check button states on GPIO14 and GPIO27
  2. Attempt to connect to WiFi using stored credentials
  3. If WiFi fails, start captive portal for configuration
  4. List existing files and show main.py content
  5. Enter code upload mode (HTTP server on port 80)

🎯 Use Cases

  • IoT Development: Remote code deployment for IoT projects
  • Education: Teaching ESP32 programming and file management
  • Prototyping: Quick testing and deployment of MicroPython scripts
  • Device Management: Remote configuration and code updates

🛠️ Development

Adding New Features

  1. Modify the appropriate file manager (A, B, or create new variant)
  2. Test in both WiFi connected and captive portal modes
  3. Update this README with new functionality

Code Structure

  • boot.py: Hardware initialization and mode selection
  • captive_portal_lib.py: WiFi and web server management
  • file_manager_*.py: File operations and HTTP API

🔒 Security Considerations

  • Default captive portal password should be changed for production use
  • Consider implementing authentication for code upload in production
  • Validate uploaded code to prevent malicious execution

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly on ESP32 hardware
  5. Submit a pull request

📞 Support

For support and questions:

  • Create an issue in the GitHub repository
  • Check existing documentation and examples

📈 Changelog

v1.0.0

  • Initial release
  • Basic file management functionality
  • Captive portal WiFi configuration
  • Remote code upload via HTTP API
  • Hardware button mode selection

Made with ❤️ for the ESP32 community

esp32-file-manager

ESP32 Remote File Manager & Code Deployment System

96b3ef4896b8bfe2b0fdcb28f1df56355ba0fe27

About

ESP32 Remote File Manager & Code Deployment System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages