This project provides a modular firmware template for the ESP32 microcontroller, enabling Power over Ethernet (PoE) support, real-time communication using Socket.IO, and dynamic configuration based on hardware needs. The firmware is designed for scalability, adaptability, and reusability across various use cases such as home automation, industrial automation, or environmental monitoring.
Key goals:
- Develop firmware that supports PoE, dynamic configuration, and multi-protocol handling.
- Provide a reusable framework for creating ESP32-based applications with features like Over-the-Air (OTA) updates, digital I/O, and communication protocols (I2C, RS485).
- Enable real-time interaction with a JavaScript server via Socket.IO.
The project uses:
- arduinoWebSockets library for WebSocket communication.
- Socket.IO 4.8.1 for server-side real-time communication.
- Example Server Code is available to demonstrate the server-side implementation.
-
Network Connectivity:
- Wi-Fi or Ethernet: Flexible network options, including Power over Ethernet (PoE) for production scenarios.
- Ethernet Flashing: Firmware can be updated over Ethernet for ease of deployment.
-
Socket.IO Communication:
- Real-time two-way communication with a JavaScript server for sending and receiving commands.
-
Dynamic Configuration by Identifier Pin:
- An analog pin reads a voltage (0–5V) to dynamically configure hardware features (e.g., DI/DO, PWM, communication protocols).
-
OTA Updates:
- Enables remote updates for the firmware via a web-based interface.
-
Multi-Protocol Handling:
- Supports the following:
- Digital Inputs/Outputs (DI/DO): For controlling relays, switches, and sensors.
- PWM: Variable power control for motors and dimmers.
- Mosfet Switching: For high-power device control.
- I2C and RS485 Modbus: Communication with industrial peripherals.
- Analog Inputs: For sensors or voltage measurements.
- Supports the following:
-
Modular Design:
- Well-structured components for easy customization and reuse across multiple applications.
-
Example Server:
- Example server code demonstrates how to integrate with a JavaScript backend.
Example Server Code.
- Example server code demonstrates how to integrate with a JavaScript backend.
- ESP32 Development Board:
- ESP32 variant with built-in PoE support (e.g., ESP32-POE-ISO by Olimex or similar).
- Integrated Ethernet MAC or support for an external PHY for Ethernet communication.
- Development Board:
- Modular circuits for DI, DO, PWM, Mosfet switching, I2C, RS485, and analog inputs.
- Arduino IDE:
- Version 1.8.x or later with ESP32 board support.
- Required Libraries:
arduinoWebSockets
for WebSocket communication.ArduinoJson
for JSON parsing.- Built-in libraries like
WiFi
,ArduinoOTA
, and others for ESP32.
- Socket.IO Server:
- Version 4.8.1 or later.
Example server code is provided here.
- Version 4.8.1 or later.
project/
├── main.ino # Main program file
├── OTAsetup.cpp # Handles OTA update setup
├── OTAsetup.h # OTA update declarations
├── SocketIOCalls.cpp # Handles Socket.IO events
├── SocketIOCalls.h # Socket.IO events declarations
├── SocketIOSetup.cpp # Socket.IO setup and communication logic
├── SocketIOSetup.h # Socket.IO setup declarations
├── wifisetup.cpp # Wi-Fi/Ethernet setup logic
├── wifisetup.h # Wi-Fi/Ethernet setup declarations
-
PoE Support:
- Use an ESP32 variant with built-in PoE capabilities for power and data over Ethernet.
-
Ethernet Flashing:
- Simplify deployment with firmware flashing over Ethernet.
-
Dynamic Configuration:
- Use an analog identifier pin to determine the hardware configuration at boot.
-
Socket.IO Communication:
- Enable real-time data exchange with a JavaScript server.
-
Multi-Protocol Handling:
- Support DI, DO, PWM, Mosfet switching, I2C, RS485 Modbus, and analog inputs.
-
ESP32 and PoE Integration
- Procure an ESP32 PoE module and establish Ethernet connectivity.
-
Firmware Flashing Over Ethernet
- Implement Ethernet-based firmware updates.
-
Dynamic Configuration
- Develop identifier pin logic for dynamic hardware configuration.
-
Hardware Development Board
- Prototype modular circuits for DI, DO, PWM, Mosfet switching, I2C, RS485, and analog inputs.
-
Socket.IO Protocol Implementation
- Integrate and test real-time communication with a JavaScript server.
- Features:
- Control lights, fans, and appliances remotely.
- Event handlers for
setLight
ortoggleFan
.
- Features:
- Monitor and control industrial machines using RS485 Modbus.
- Use Ethernet connectivity for reliability.
- Features:
- Collect and report environmental data (e.g., temperature, humidity).
- Periodic sensor readings with real-time updates.
-
Custom A La Carte Boards:
- Create modular boards for specific hardware configurations.
-
Security:
- Add encryption for Socket.IO communication (e.g., TLS).
-
Modular Firmware:
- Ensure firmware is modular for easy integration of new features.