-
Notifications
You must be signed in to change notification settings - Fork 0
/
wemos-iot-relay.ino
62 lines (48 loc) · 1.35 KB
/
wemos-iot-relay.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* Create a WiFi access point and provide a web server on it. */
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
#include <ArduinoJson.h>
#include "Relay.h"
#include "RelayCollection.h"
#include "WifiCredentials.h"
/* Default credentials for wemos AP */
const char *ssid = "wemos-iot-relay";
const char *password = "iotpassword";
char ssidClient[32];
char passwordClient[64];
bool providedCredentials = false;
wifiCredentials credentials;
ESP8266WebServer server(80);
/* Default relays available */
Relay relays[] = {
Relay(16, 1, "Undefined"),
Relay(5, 2, "Pin 5 -> D1"),
Relay(4, 3, "Undefined"),
Relay(0, 4, "Undefined")
};
RelayCollection relayCollection(relays);
/* Just a little test message. Go to http://192.168.4.1 in a web browser
* connected to this access point to see it.
*/
void setup() {
delay(1000);
EEPROM.begin(512);
WiFi.mode(WIFI_AP_STA);
Serial.begin(115200);
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
setupServer();
server.begin();
Serial.println("HTTP server started");
Serial.println(relays[1].toString());
}
void loop() {
server.handleClient();
}