This was a 2 second search on Amazon, using "Wemos Relay". Don't have to dink with pull-ups/down, dc-to-dc converters, regulators or anything else. Solder the headers, snap together. Bam! Program, Bam!
w/ GUI Admin Client, Drag & Drop File Manager, OTA Built-In, Access Point Manager,
Performance Metrics, Web Socket Comms, App API, All running on ESP8266...
Even usable on ESP-01S --- Please check it out!
https://inqonthat.com/inqportal-the-three-line-promise/
https://InqOnThat.com/inqportal
I have it just turning the WeMos LED on/off. If change the pin to the relay's and setup the home router in question. You'd be able to access the included UI from either your home router network or the ParentsRule network. Obviously once you turn your home router off, you could only use the ParentsRule network to turn it back on. Once your home router is back on, the ESP8266 should reconnect.
#include <InqPortal.h>
#define ADULT_SSID "ParentsRule" // ESP8266 Direct SSID
#define ADULT_PW "passW0rd" // ESP8266 Direct PW
#define ALL_SSID "YourSSID" // Home SSID
#define ALL_PW "YourPW" // Home PW
#define RELAY_PIN LED_BUILTIN // Change LED_BUILTIN to pin used by relay.
InqPortal svr;
void setup()
{
svr.publishRW("PT", NULL, "Play time on/off",
[]()->u8 { return !digitalRead(RELAY_PIN); }, // <-- might remove !
[](u8 sw) { digitalWrite(RELAY_PIN, !sw); }); // <-- might remove !
svr.begin(ADULT_SSID, ADULT_PW, ALL_SSID, ALL_PW);
pinMode(RELAY_PIN, OUTPUT);
}
void loop() { }
Client UI is ugly, but it works. Also, doing this self imposed challenge illustrated a few places I can improve the library. I'll reduce the mess in the next version.
Edit: This has been modified to use version InqPortal 5.2.3 or greater.
<!DOCTYPE html>
<html>
<head>
<title>Parents Rule</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='InqPortal.js'></script>
<link rel='stylesheet' type='text/css' href='InqStyle.css'>
</head>
<body class='space'>
<h1 class='space'>
<input id='PT' type='checkbox' style='height:1em;width:1em;'
onclick='set();' >
<label for='PT'>Play Time</label>
</h1>
</body>
</html>
w/ GUI Admin Client, Drag & Drop File Manager, OTA Built-In, Access Point Manager,
Performance Metrics, Web Socket Comms, App API, All running on ESP8266...
Even usable on ESP-01S --- Please check it out!
https://inqonthat.com/inqportal-the-three-line-promise/
https://InqOnThat.com/inqportal
<!DOCTYPE html>
<html>
<head>
<title>Parents Rule</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script src='InqPortal.js'></script>
<link rel='stylesheet' type='text/css' href='InqStyle.css'>
</head>
<body class='space'>
<h1 class='space'>
<input id='PT' type='checkbox' style='height:1em;width:1em;'
onclick='set();' >
<label for='PT'>Play Time</label>
</h1>
</body>
</html>
If you use InqPortal or not, I'd be curious how you flesh out your project... i.e. schedules and such.
VBR,
Inq
w/ GUI Admin Client, Drag & Drop File Manager, OTA Built-In, Access Point Manager,
Performance Metrics, Web Socket Comms, App API, All running on ESP8266...
Even usable on ESP-01S --- Please check it out!
https://inqonthat.com/inqportal-the-three-line-promise/
https://InqOnThat.com/inqportal