Joy-it ESP-01S Quick Start Manual page 5

Remotely controllable relay module
Table of Contents

Advertisement

// Assignment of the request
int
value = LOW;
if
(request.indexOf("/RELAY=ON") != -1){
Serial.println("RELAY=ON");
digitalWrite(RELAY,LOW);
value = LOW;
}
if
(request.indexOf("/RELAY=OFF") != -1){
Serial.println("RELAY=OFF");
digitalWrite(RELAY,HIGH);
value = HIGH;
}
// Return the answer
client.println("HTTP/1.1 200
client.println("Content-Type:
client.println("");
client.println("<!DOCTYPE
client.println("<html>");
client.println("<meta name='viewport' content='width=device
-width,
initial-scale=1'>");
client.println("<head><title>ESP8266 RELAY Control</
title></head>");
client.println("<style>");
client.println("* {text-align: center; font-family: Conso-
las;}");
client.println("");
client.println(".container {position: absolute; top:
50%;");
client.println("left: 50%; transform: translateX(-50%)
translateY(-50%);}");
client.println("");
client.println("a {display: inline-block;
client.println("color: #FFFFFF; background-color:
#275C6B;");
client.println("margin-top: 15px; padding: 10px
client.println("text-decoration: none; border-radius:
5px;");
client.println("font-weight:
client.println("</style>");
client.println("<div
client.println("<div
client.print("Relay is now:
if(value == HIGH){client.print("OFF");}
else{client.print("ON");}
client.println("<br>");
client.println("<a
client.println("<a
client.println("</div>");
client.println("</div>");
client.println("</html>");
Serial.println("");
}
After you have uploaded the code to your Esp-01S, you need to pull the
ESP-01S programmer out of your PC and set the small switch on the side
of PROG to UART so that you can see the serial output of the ESP-01S in
your IDE. Once you have flipped the switch, you can put the programmer
of your ESP-01S back into your PC and view the serial output of your ESP-
01S to see if the connection to your WiFi was successful.
OK");
text/html");
//
this is necessary
HTML>");
800;}");
class='container'>");
class='inner'>");
");
href=\"/RELAY=OFF\">OFF</a>");
href=\"/RELAY=ON\">ON</a>");
width:
50px;");
20px;");

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP-01S and is the answer not in the manual?

This manual is also suitable for:

Esp01Esp01-rel

Table of Contents