Smart Socket is a simple solution for remote control of a relay socket based on ESP8266 (ESP-01S).
The device periodically polls a server, receives an ON / OFF command, and controls the relay accordingly.
- Wi-Fi connection via WiFiManager (AP + Captive Portal)
- Relay control through a server API (
https://smart.udfsoft.com/api/device/status) - HTTPS support (with keep-alive for faster requests)
- Simple ON/OFF logic for the smart socket
- Optional LED indicator (GPIO1)
- Non-blocking loop using
millis()+yield()for stable Wi-Fi and watchdog operation
- ESP8266 (ESP-01S)
- Arduino IDE or PlatformIO
- Arduino libraries:
- Clone the repository:
git clone https://github.com/yourusername/smart-socket.git-
Open the project in Arduino IDE or PlatformIO.
-
Install the required libraries via Library Manager:
- ESP8266WiFi
- ESP8266HTTPClient
- WiFiManager
-
In the code, replace the following with your( support@udfsoft.com ) values:
#define DEVICE_ID "YOUR_DEVICE_ID" #define API_KEY "YOUR_API_KEY"
-
Upload the firmware to your ESP8266 (ESP-01S).
-
On startup, ESP will create an access point SMART_SOCKET_AP.
-
Connect to it and configure Wi-Fi through the WiFiManager portal.
-
The device will connect to your network and start polling the server every 10 seconds:
- HTTP 200 → relay ON
- HTTP 423 → relay OFF
- RELAY_PIN: GPIO0 (connect to your relay)
- LED_PIN: GPIO1 (TX, optional for status LED)
- HIGH / LOW to turn ON/OFF depends on your relay module type.
client.setInsecure() is used for HTTPS — certificate verification is disabled.
The loop uses yield() and millis() to keep Wi-Fi stable and avoid watchdog resets.
If Wi-Fi is lost, ESP automatically tries to reconnect.
This project is licensed under the [Apache 2.0 License(https://www.apache.org/licenses/LICENSE-2.0).
Copyright 2025 UDFOwner
🔗 Useful Links



