Skip to content

OmarTemsah99/ESP_WebSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

40 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒŸ ESP32-S3 Sensor Monitor

ESP32-S3 Platform License Build

A powerful, feature-rich ESP32-S3 sensor monitoring system with real-time web interface, OTA updates, and RGB status indicators.

๐Ÿš€ Quick Start โ€ข ๐Ÿ“– Documentation โ€ข ๐ŸŽฏ Features โ€ข ๐Ÿค Contributing โ€ข ๐Ÿ’ฌ Support


๐ŸŽฏ Features

๐ŸŒ Web Interface

  • Clean, responsive dashboard
  • Real-time sensor data visualization
  • Mobile-friendly design
  • RESTful API endpoints

๐Ÿ“Š Sensor Management

  • Multi-client sensor support
  • Real-time data collection
  • JSON-based data format
  • Automatic client detection

๐Ÿ”ง System Management

  • Over-the-air (OTA) firmware updates
  • SPIFFS file system management
  • Upload/download/delete files
  • Static IP configuration

๐Ÿ’ก Visual Feedback

  • RGB LED status indicators
  • Connection state visualization
  • Sensor value representation
  • Custom color control

๐Ÿš€ Quick Start

โšก One-Line Setup

git clone https://github.com/OmarTemsah99/ESP_WebSocket && cd ESP_WebSocket && pio run -t upload

๐Ÿ“‹ Prerequisites

  • Hardware: ESP32-S3 Development Board
  • LED: WS2812B RGB LED (NeoPixel)
  • Software: PlatformIO IDE or CLI
  • Network: WiFi connection

๐Ÿ› ๏ธ Hardware Setup

๐Ÿ“Œ Pin Configuration

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚    ESP32-S3     โ”‚
โ”‚                 โ”‚
โ”‚  GPIO 48 โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€ WS2812B RGB LED
โ”‚                 โ”‚      (Data In)
โ”‚                 โ”‚
โ”‚  GND     โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€ LED GND
โ”‚  3V3     โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€ LED VCC
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ”Œ Wiring Diagram

Component ESP32-S3 Pin Notes
WS2812B Data GPIO 48 Digital signal
WS2812B VCC 3.3V Power supply
WS2812B GND GND Ground connection

โš ๏ธ Important: Ensure stable 3.3V power supply for reliable operation.


๐Ÿ’ป Software Installation

1๏ธโƒฃ Environment Setup

# Install PlatformIO CLI
pip install platformio

# Clone repository
git clone https://github.com/OmarTemsah99/ESP_WebSocket
cd ESP_WebSocket

2๏ธโƒฃ Configuration

Create src/config.cpp:

#include "config.h"

// ๐Ÿ“ถ WiFi Settings
const char *WIFI_SSID = "YourWiFiNetwork";
const char *WIFI_PASSWORD = "YourWiFiPassword";

// ๐ŸŒ Network Configuration
const IPAddress STATIC_IP(192, 168, 1, 200);    // Device IP
const IPAddress GATEWAY(192, 168, 1, 1);        // Router IP
const IPAddress SUBNET(255, 255, 255, 0);       // Subnet mask
const IPAddress DNS_SERVER(8, 8, 8, 8);         // DNS server

3๏ธโƒฃ Build & Upload

# ๐Ÿ”จ Build project
pio run

# ๐Ÿ“ค Upload firmware (USB)
pio run -t upload -e esp32-s3-usb

# ๐Ÿ’พ Upload web files
pio run -t uploadfs -e esp32-s3-usb

# ๐Ÿ“ก Monitor serial output
pio device monitor

4๏ธโƒฃ OTA Updates (After initial setup)

# Update IP in platformio.ini, then:
pio run -t upload -e esp32-s3-ota

๐ŸŒ Web Interface

๐Ÿ“Š Dashboard (http://192.168.1.200/)

  • Real-time Metrics: Live sensor data updates
  • Client Management: View all connected sensors
  • Status Monitoring: System health indicators
  • LED Control: RGB color management

๐Ÿ“ˆ Sensor Data Viewer (http://192.168.1.200/sensor_data)

  • Live Refresh: Automatically updates every 200ms
  • Detailed Display:
  • IP Address
  • Client ID
  • Sensor Value
  • Error Handling: Displays fallback message on failure
  • Clean UI: Styled via shared /styles.css
  • Navigation: Includes back button to main dashboard

๐Ÿ“ File Manager (http://192.168.1.200/upload)

  • Upload Files: Drag & drop interface
  • File Browser: View SPIFFS contents
  • Download: Retrieve stored files
  • Delete: Remove unwanted files

๐Ÿ”„ Firmware Update (http://192.168.1.200/firmware)

  • OTA Updates: Upload new firmware
  • Progress Tracking: Real-time update status
  • Rollback Support: Automatic recovery
  • Verification: Checksum validation

๐Ÿšจ LED Status Guide

LED Color Status Description
๐Ÿ”ด Red Disconnected No WiFi connection
๐Ÿ”ต Blue (Blinking) Connecting Attempting WiFi connection
๐ŸŸข Green Connected Ready and operational
๐Ÿ”ต Blue (Solid) Sensor Active Sensor value = 1
๐Ÿ”ด Red (Solid) Sensor Inactive Sensor value = 0

๐Ÿ”— API Reference

๐Ÿ“ค Send Sensor Data

POST /sensor
Content-Type: application/x-www-form-urlencoded

clientId=sensor1&value=1

Response: 200 OK

๐Ÿ“ฅ Get Sensor Data

GET /sensorData

Response:

{
  "192.168.1.100": {
    "clientId": "sensor1",
    "value": 1,
    "timestamp": "2025-06-23T10:30:00Z"
  }
}

๐ŸŽจ Control LED

GET /color?r=255&g=128&b=0

Parameters:

  • r: Red value (0-255)
  • g: Green value (0-255)
  • b: Blue value (0-255)

๐Ÿ“‚ File Operations

GET /list                    # List all files
POST /delete?file=config.txt # Delete specific file
POST /upload                 # Upload file (multipart/form-data)

๐Ÿ—๏ธ Project Structure

ESP_WebSocket/
โ”œโ”€โ”€ ๐Ÿ“ data/                    # Web interface files
โ”‚   โ”œโ”€โ”€ ๐ŸŒ index.html          # Main dashboard
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ file_manager.html   # File management
โ”‚   โ”œโ”€โ”€ ๐Ÿ”„ firmware_update.html # OTA interface
โ”‚   โ””โ”€โ”€ ๐ŸŽจ styles.css          # Styling
โ”œโ”€โ”€ ๐Ÿ“ include/                # Header files
โ”‚   โ”œโ”€โ”€ โš™๏ธ config.h           # Configuration
โ”‚   โ”œโ”€โ”€ ๐Ÿ’ก led_controller.h   # LED management
โ”‚   โ”œโ”€โ”€ ๐Ÿ“Š sensor_manager.h   # Sensor handling
โ”‚   โ”œโ”€โ”€ ๐ŸŒ web_handlers.h     # Web routes
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ถ wifi_manager.h     # Network management
โ”‚   โ””โ”€โ”€ ๐Ÿ’พ filesystem_utils.h # File operations
โ”œโ”€โ”€ ๐Ÿ“ src/                   # Source code
โ”‚   โ”œโ”€โ”€ ๐Ÿš€ main.cpp          # Main application
โ”‚   โ”œโ”€โ”€ ๐Ÿ’ก led_controller.cpp
โ”‚   โ”œโ”€โ”€ ๐Ÿ“Š sensor_manager.cpp
โ”‚   โ”œโ”€โ”€ ๐ŸŒ web_handlers.cpp
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ถ wifi_manager.cpp
โ”‚   โ””โ”€โ”€ ๐Ÿ’พ filesystem_utils.cpp
โ””โ”€โ”€ โš™๏ธ platformio.ini        # Build configuration

โš™๏ธ Configuration Options

๐Ÿ”ง Hardware Customization

// config.h
#define RGB_LED_PIN 48        // GPIO pin for RGB LED
#define NUM_PIXELS 1          // Number of LEDs
#define LED_BRIGHTNESS 100    // Brightness (0-255)

โฑ๏ธ Timing Settings

#define RECONNECT_INTERVAL 10000    // WiFi reconnect delay (ms)
#define SENSOR_UPDATE_INTERVAL 50   // Sensor refresh rate (ms)
#define WEB_SERVER_TIMEOUT 5000     // HTTP timeout (ms)

๐ŸŒ Network Configuration

#define WEB_SERVER_PORT 80          // HTTP server port
#define OTA_PORT 3232              // OTA update port
#define MAX_CLIENTS 10             // Maximum concurrent clients

๐ŸŽฏ Use Cases

๐Ÿ  Home Automation

  • Temperature monitoring
  • Motion detection
  • Light control
  • Security systems

๐Ÿญ Industrial IoT

  • Equipment monitoring
  • Environmental sensing
  • Predictive maintenance
  • Data logging

๐ŸŒฑ Agriculture

  • Soil moisture monitoring
  • Weather station
  • Greenhouse automation
  • Irrigation control

๐Ÿ”ฌ Research & Education

  • Sensor data collection
  • IoT prototyping
  • Remote monitoring
  • Educational projects

๐Ÿš€ Advanced Features

๐Ÿ“ˆ Performance Optimization

  • Memory Management: Efficient SPIFFS usage
  • Power Efficiency: Deep sleep support ready
  • Network Optimization: Keep-alive connections
  • Real-time Updates: WebSocket ready architecture

๐Ÿ”’ Security Features

  • OTA Security: Password-protected updates
  • Access Control: IP-based restrictions ready
  • Data Validation: Input sanitization
  • Secure Headers: CORS and security headers

๐Ÿ”ง Extensibility

  • Modular Design: Easy feature addition
  • Plugin Architecture: Sensor plugin support
  • Custom Protocols: Multiple communication options
  • Database Integration: Ready for external databases

๐Ÿ› Troubleshooting

๐Ÿ” WiFi Connection Issues

Problem: Device not connecting to WiFi

Solutions:

  1. โœ… Verify credentials in config.cpp
  2. โœ… Check signal strength (LED should blink blue)
  3. โœ… Confirm 2.4GHz network (ESP32 doesn't support 5GHz)
  4. โœ… Reset network settings: Hold reset during power-on

Debug Commands:

Serial.println("WiFi Status: " + String(WiFi.status()));
Serial.println("RSSI: " + String(WiFi.RSSI()));
๐Ÿ’พ SPIFFS Mount Failed

Problem: Web interface not loading

Solutions:

  1. โœ… Upload filesystem: pio run -t uploadfs
  2. โœ… Format SPIFFS via serial monitor
  3. โœ… Check partition table in platformio.ini
  4. โœ… Verify file sizes don't exceed partition

Recovery:

# Force filesystem upload
pio run -t uploadfs --force
๐Ÿ”„ OTA Update Failed

Problem: Firmware update not working

Solutions:

  1. โœ… Ensure stable power supply (use USB power)
  2. โœ… Check IP address in platformio.ini
  3. โœ… Verify .bin file integrity
  4. โœ… Close other applications using the network

Prevention:

// Add to main.cpp for better OTA reliability
ArduinoOTA.setRebootOnSuccess(true);
ArduinoOTA.setTimeout(30000);
๐Ÿ’ก LED Not Working

Problem: RGB LED not responding

Solutions:

  1. โœ… Check wiring (GPIO 48, VCC, GND)
  2. โœ… Verify power supply (3.3V stable)
  3. โœ… Test with different LED
  4. โœ… Check pin configuration in config.h

Test Code:

// Add to setup() for LED testing
pixels.setPixelColor(0, pixels.Color(255, 0, 0)); // Red
pixels.show();

๐Ÿ“Š Performance Metrics

Metric Value Notes
Boot Time ~3-5 seconds Including WiFi connection
Memory Usage ~180KB RAM With web server active
Flash Usage ~1.2MB Including SPIFFS data
Power Consumption ~150mA At 3.3V with LED
WiFi Range ~50m indoor Depends on environment
Update Rate 20Hz Sensor data refresh
Concurrent Clients 10+ Web interface users
File Upload Size 1MB max SPIFFS limitation

๐Ÿ”ฎ Roadmap

๐ŸŽฏ Version 2.0 (Planned)

  • WebSocket Support: Real-time bidirectional communication
  • Database Integration: SQLite for data persistence
  • Multi-sensor Support: I2C/SPI sensor integration
  • Advanced Visualization: Charts and graphs
  • Mobile App: Companion mobile application

๐Ÿš€ Version 3.0 (Future)

  • Machine Learning: On-device sensor prediction
  • Mesh Networking: ESP-NOW multi-device support
  • Cloud Integration: AWS/Azure IoT connectivity
  • Voice Control: Alexa/Google Assistant integration

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

๐Ÿ› Bug Reports

Found a bug? Open an issue with:

  • Detailed description
  • Steps to reproduce
  • Expected vs actual behavior
  • Serial monitor output
  • Hardware configuration

๐Ÿ’ก Feature Requests

Have an idea? Create a feature request with:

  • Clear description of the feature
  • Use cases and benefits
  • Implementation suggestions
  • Mockups or examples (if applicable)

๐Ÿ”ง Code Contributions

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ Documentation

  • Improve README sections
  • Add code comments
  • Create tutorials
  • Fix typos and grammar

๐Ÿ“„ License

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

MIT License - Free for personal and commercial use

๐ŸŒŸ Showcase

โœจ Official Project Overview

Get a comprehensive look at the ESP32-S3 Sensor Monitor's features and operation:

๐Ÿ† Featured Projects

Using ESP32-S3 Sensor Monitor

  • Smart Garden Monitor - Automated plant care system
  • Home Security Hub - Multi-sensor security monitoring
  • Weather Station - Environmental data collection
  • Industrial Monitor - Equipment health tracking

Want your project featured? Submit your implementation!


๐Ÿ’ฌ Support

๐Ÿ†˜ Get Help

  • ๐Ÿ“– Documentation: Check this README first
  • ๐Ÿ› Issues: GitHub Issues
  • ๐Ÿ’ฌ Discussions: GitHub Discussions
  • ๐Ÿ“ง Direct Contact: Open an issue for project-specific questions

๐ŸŒ Community

  • ๐Ÿ‘ฅ Contributors: See Contributors
  • โญ Star this repository if it helped you!
  • ๐Ÿด Fork to create your own version
  • ๐Ÿ“ข Share with the community

๐ŸŽ‰ Thank you for using ESP32-S3 Sensor Monitor!

Made with โค๏ธ by OmarTemsah99

GitHub followers GitHub stars

โฌ†๏ธ Back to Top

Releases

No releases published

Packages

 
 
 

Contributors