Code Example - Joy-it ESP-01S Quick Start Manual

Remotely controllable relay module
Table of Contents

Advertisement

3. CODE EXAMPLE

Now you can simply copy the following code example into your Arduino
IDE and upload it to your ESP-01S.
#include <ESP8266WiFi.h>
const
char* ssid = "MeineWlanSSID";
WiFi SSID here
const
char* password = "MeinWlanPasswort";
ter or WiFi password here
#define RELAY 0
// connected to GPIO0
WiFiServer server(80);
void
setup(){
Serial.begin(115200);
the serial monitor
pinMode(RELAY,OUTPUT);
digitalWrite(RELAY, LOW);
// Connect to the 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
// Start the Server
server.begin();
Serial.println("Server
// Output of the IP address
Serial.print("Use this URL to connect:
Serial.print("https://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void
loop(){
// Check whether a user has established a connection
WiFiClient client = server.available();
if
(!client){
return;
}
// Wait until the user sends data
Serial.println("new
while(!client.available()){
delay(1);
}
// Reading the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Enter your router or
// must have the same baud rate as
");
connected");
started");
client");
// Enter your rou-
");

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?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Esp01Esp01-rel

Table of Contents