NomDs7GLRitLwuwktZp273kYf8N33o9gTRKntDAX.pdf
This ESP-01S Relay based on AI-Thinker ESP-01S WIFI module. It is designed for smart home, Internet of thing and others DIY project. With this smart relay, you will easy to DIY your smart switch to control any device by your phone anywhere. We support the APP and LUA source code. We had upload a demo code in the ESP0-01S, just supply a DC5V power, then you can control it. In the version, we use the GPIO0 of ESP-01S to control the Relay by Hight level.

32

1) Hardware connection: Just plug the ESP-01S to the 2*4 pin header after download the code to ESP-01S. Show as below:
2) Power supply Connect a DC 5V power to the GND and VCC.
3) Open your phone WLAN then connect the WiFi ESP8266-XXXX, Power word:12345678
4) Open the ESP8266 Controller.app (Installed it in your android phone before)
5) Set IP Address: 192.168.1.1 than you can control your device via the wifi relay module:

Soweit die Theorie...
... es geht erst mal gar nichts!
Wie programmiere ich das Teil überhaupt - JA - es gibt einen Programmiermodus....
was ich dann auch im Internet so belegt bekommen habe (DANKE! ... schafft Freizeit aber auch Faulheit)
2 Änderungen sind notwendig, damit überhaupt was passiert:
![]()
Dann muss der Chip geflashed werden, die originalen machen überhaupt nichts...
Programm ergoogled:
https://www.instructables.com/id/ESP0101S-RELAY-MODULE-TUTORIAL/
configuriert
#include <ESP8266WiFi.h>
const char* ssid = "HORN"; // fill in here your router or wifi SSID
const char* password = "******"; // fill in here your router or wifi password
#define RELAY 0 // relay connected to GPIO0
WiFiServer server(80);
void setup()
{
Serial.begin(115200); // must be same baudrate with the Serial Monitor
pinMode(RELAY,OUTPUT);
digitalWrite(RELAY, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop()
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client)
{
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available())
{
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/RELAY=ON") != -1)
{
Serial.println("RELAY=ON");
digitalWrite(RELAY,HIGH);
value = HIGH;
}
if (request.indexOf("/RELAY=OFF") != -1)
{
Serial.println("RELAY=OFF");
digitalWrite(RELAY,LOW);
value = LOW;
}
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // this is a must
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head><title>ESP8266 RELAY Control</title></head>");
client.print("Relay is now: ");
if(value == LOW)
{
client.print("OFF");
}
else
{
client.print("ON");
}
client.println("<br><br>");
client.println("Turn <a href=\"/RELAY=OFF\">OFF</a> RELAY<br>");
client.println("Turn <a href=\"/RELAY=ON\">ON</a> RELAY<br>");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
} |
#include <ESP8266WiFi.h>
const char* ssid = "HORNn"; // fill in here your router or wifi SSID
const char* password = "********"; // fill in here your router or wifi password
#define RELAY 0 // relay connected to GPIO0
WiFiServer server(80);
void setup()
{
Serial.begin(115200); // must be same baudrate with the Serial Monitor
pinMode(RELAY,OUTPUT);
digitalWrite(RELAY, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop()
{
// Check if a client has connected
WiFiClient client = server.available();
if (!client)
{
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available())
{
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/RELAY=ON") != -1)
{
Serial.println("RELAY=ON");
digitalWrite(RELAY,HIGH);
value = HIGH;
}
if (request.indexOf("/RELAY=OFF") != -1)
{
Serial.println("RELAY=OFF");
digitalWrite(RELAY,LOW);
value = LOW;
}
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // this is a must
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head><title>ESP8266 RELAY Control</title></head><body>");
client.println("<h1>ESP8266 RELAY Control</h1><I>Development version 0.0.0.1 pre alpha :-)</I><br>");
client.println("<I>© UH 02/2019</I><br><br>");
client.println("<table border=\"0\"><TR><TH bgcolor=\"#D0D0D0\">parameter</TH><TH bgcolor=\"#D0D0D0\">value</TH></TR>");
client.print("<tr><td bgcolor=\"#E0E0E0\"><I>MAC-Adresse:</I></td><td bgcolor=\"#F0F0F0\">");
client.print(WiFi.macAddress());
client.println("</td></tr>");
client.print("<tr><td bgcolor=\"#E0E0E0\"><I>IP-Adresse:</I></td><td bgcolor=\"#F0F0F0\">");
client.print(WiFi.localIP());
client.println("</td></tr>");
client.print("<tr><td bgcolor=\"#E0E0E0\"><I>Netmask:</I></td><td bgcolor=\"#F0F0F0\">");
client.print(WiFi.subnetMask());
client.println("</td></tr>");
client.print("<tr><td bgcolor=\"#E0E0E0\"><I>Gateway:</I></td><td bgcolor=\"#F0F0F0\">");
client.print(WiFi.gatewayIP());
client.println("</td></tr>");
client.print("<tr><td bgcolor=\"#E0E0E0\"><I>Status:</I></td><td bgcolor=\"#F0F0F0\">");
client.print(WiFi.status());
client.println("</td></tr></table><br><hr>");
client.print("Relay is now: ");
if(value == LOW)
{
client.print("OFF");
}
else
{
client.print("ON");
}
client.println("<br><br>");
client.println("Turn <a href=\"/RELAY=OFF\">OFF</a> RELAY<br>");
client.println("Turn <a href=\"/RELAY=ON\">ON</a> RELAY<br>");
client.println("</body></html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
|
Serial.print(WiFi.localIP());
