simple sketch for ESP8266 of using ESPAsyncWebServer to switch relays on GPIO pins, serves a simple website with toggle buttons for each relay and uses AsyncWiFiManager to configure WiFi network.
- Data is encoded as JSON object
- get and set relay states also by simple GET requests
- Bootstrap and jQuery for beautiful Web Pages for both Mobile and Desktop Screens
- ESPAsyncWebServer Library to use syncronous communication
- ArduinoOTA updates
- MDNS support
- An ESP8266 module or development board like WeMos or NodeMcu with at least 32Mbit Flash (equals to 4MBytes)
- 4 Relay Modules
Please install Arduino IDE if you didn't already, then add ESP8266 Core (Beware! Install Git Version) on top of it. Additional Library download links are listed below:
- Arduino IDE - The development IDE (tested with 1.8.3)
- ESP8266 Core for Arduino IDE - ESP8266 Core
- ESPAsyncWebServer - Asynchrone WebServer with WebSocket Plug-in
- ESPAsyncTCP - Mandatory for ESPAsyncWebServer
- ArduinoJson - JSON Library for Arduino IDE
You also need to upload web files to your ESP with ESP8266FS Uploader.
- ESP8266FS Uploader - Arduino ESP8266 filesystem uploader
Unlisted libraries are part of ESP8266 Core for Arduino IDE, so you don't need to download them.
- First, flash firmware by Arduino IDE or with your favourite flash tool
- Flash webfiles data to SPIFFS either using ESP8266FS Uploader tool or with your favourite flash tool
- (optional) Fire up your serial monitor to get informed
- Power on your ESP8266
- Search for Wireless Network "wifi-relay" and connect to it (default password is adminadmin)
- Normally your system will open a page; otherwise open your browser and type either "http://192.168.4.1" or "http://wifi-relay.local" (.local needs Bonjour installed on your computer) on address bar.
- Scan for available networks and fill in your password and press save.
- ESP8266 will reboot and connects to your network.
- Check your new IP address from serial monitor or DHCP network settings and connect to your ESP8299 again. (You can also use "http://wifi-relay.local").
- Toggle relay 1, relay 2, relay 3 and relay 4 buttons on or off and enjoy your WiFi relay device.
- Congratulations, everything went well, if you encounter any issue feel free to ask help on GitHub.