This project provides a versatile WiFi-controlled relay module for the ESP-01 using the ESP8266 microcontroller. The device offers remote relay control through a web interface, WebSocket, and optional Adafruit IO integration.
- WiFi-enabled relay control
- Captive portal for easy device configuration
- Persistent device state storage
- Web-based user interface
- WebSocket real-time control
- Optional Adafruit IO cloud integration
- mDNS support for easy device discovery
- ESP-01 module
- Relay module
- Power supply (3.3V recommended)
RELAY_PIN
: GPIO0 (Controls relay)LED_PIN
: GPIO1 (Status indicator)
- Power on the device
- If no WiFi credentials are configured, the device will create a captive portal
- Connect to
ESP8266-Setup
WiFi network (password:configme123
) - Open
http://192.168.4.1
in your web browser
- WiFi SSID and Password
- Custom mDNS name (e.g.,
my-relay.local
) - Optional Adafruit IO integration
- Adafruit IO Username
- Adafruit IO Key
- Relay Feed Name
- IP Feed Name
- Access via
http://[device-mdns-name].local
- Toggle relay on/off directly from the web page
- Real-time relay control
- Supports
ON
andOFF
commands
- Cloud-based control and monitoring
- Publish and subscribe to relay state
- Periodic IP address updates
- Automatic WiFi reconnection
- Configurable connection timeout
- Fallback to setup mode after multiple connection failures
- mDNS support for easy local network discovery
- Device settings stored in EEPROM
- Persistent relay state memory
- Supports default configuration if no valid config found
- Serial output at 115200 baud
- Detailed logging for WiFi and Adafruit IO connections
- If WiFi connection fails, device enters captive portal mode
- Reset device or reconfigure WiFi credentials if needed
- ESP8266WiFi
- ESP8266WebServer
- ESP8266mDNS
- WebSocketsServer
- EEPROM
- DNSServer
- AdafruitIO_WiFi
- 3.3V, minimum 500mA
- Stable power source recommended for reliable operation
- Use Arduino IDE or PlatformIO
- Select "Generic ESP8266 Module"
- Configure appropriate flash settings
- Upload the firmware
- Change default AP password
- Use strong WiFi credentials
- Consider using Adafruit IO's security features
Pull requests and issues are welcome. Please follow standard GitHub contribution guidelines.
For issues or questions, please open a GitHub issue or contact the maintainer.