A feature-rich ESP8266-based relay controller with web interface and Alexa integration using FauxmoESP.
- 🌐 Web Interface: Modern, responsive control panel
- 🎤 Alexa Integration: Voice control through FauxmoESP
- 🔄 OTA Updates: Over-the-air firmware updates
- 🔐 Secure Configuration: Environment-based credentials (no hardcoded secrets)
- ⚡ Relay Inversion: Support for active-low/active-high relays
- 📡 WiFi Monitoring: Automatic reconnection with connection health checks
- 📊 Real-time Status: Live relay state feedback
- ESP8266 (ESP-01 or similar)
- Relay module (5V/3.3V compatible)
- Power supply
All configuration is managed through the .env file. Copy .env.example to .env and customize according to your needs.
- PlatformIO installed
- Python 3.x (for build scripts)
-
Clone the repository:
git clone https://github.com/alixti/ESP8266SmartRelay.git cd ESP8266SmartRelay -
Create your
.envfile:cp .env.example .env
-
Edit
.envwith your configuration -
Build and upload:
# Initial upload via USB pio run -e usb -t upload # Subsequent uploads via OTA pio run -e ota -t upload
Access the device at http://<DEVICE_IP> to:
- View real-time relay status
- Turn relay ON/OFF
- Reset the device
- Say "Alexa, discover devices"
- Control with voice: "Alexa, turn on [FAUXMO_DEVICE_NAME]"
GET /- Web interfaceGET /status- Get relay state (JSON)GET /on- Turn relay ONGET /off- Turn relay OFFGET /reset- Restart device
ESP8266SmartRelay/
├── src/
│ ├── main.cpp # Main application code
│ └── config.h # Configuration header (IDE hints)
├── .env # Your configuration
├── .env.example # Configuration template
├── load_env.py # Build script for loading .env
├── platformio.ini # PlatformIO configuration
└── README.md
- usb: Upload via serial (COM port)
- ota: Upload over-the-air (WiFi)
Simply add them to .env:
MY_NEW_VARIABLE="value"They're automatically available in code as MY_NEW_VARIABLE define.
- Check SSID and password in
.env - Verify WiFi network is 2.4GHz (ESP8266 doesn't support 5GHz)
- Ensure
OTA_UPLOAD_PORTmatches device IP - Check that device is on the same network
- Verify
OTA_PASSWORDis correct
- Check
RELAY_PINmatches your hardware - Try toggling
RELAY_INVERTED(some relays use active-low logic)
- Ensure device and Echo are on the same network
- Wait 20-30 seconds after device boot before discovering
- Try "Alexa, forget all devices" then rediscover
- FauxmoESP - Alexa integration
- ESPAsyncWebServer - Async web server
- ESPAsyncTCP - Async TCP library
- ArduinoOTA - Over-the-air updates
MIT License - see LICENSE file for details
Pull requests are welcome! For major changes, please open an issue first.