SMS/WhatsApp: 08564-999-1225
buka Senin-Jumat 08-00 - 17.00
(datang ke lokasi diluar jam kerja mohon konfirmasi terlebih dahulu)
kunjungi juga web resmi kami di sarpinto.com

jual esp8266 programmer di Malang

Jual esp8266 iot programmer include relay - usb to ttl - kabel jumper hanya 230000.0, lihat gambar klik https://www.tokopedia.com/sarpinto/esp8266-iot-programmer-include-relay-usb-to-ttl-kabel-jumper


video tutorial  control relay via wifi web server



berikut program / sourcode / script / coding untuk control relay via wifi web server yang kami ambil dari sumbernya yaitu http://randomnerdtutorials.com  

/*********
  Rui Santos
  Complete project details at http://randomnerdtutorials.com  
*********/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

MDNSResponder mdns;

// Replace with your network credentials
const char* ssid = "freewifi";
const char* password = "12341111";

ESP8266WebServer server(80);

String webPage = "";

int gpio0_pin = 0;
int gpio2_pin = 2;

void setup(void){
  webPage += "<h1>ESP8266 Web Server</h1><p>Socket #1 <a href=\"socket1On\"><button>ON</button></a>&nbsp;<a href=\"socket1Off\"><button>OFF</button></a></p>";
  webPage += "<p>Socket #2 <a href=\"socket2On\"><button>ON</button></a>&nbsp;<a href=\"socket2Off\"><button>OFF</button></a></p>";
  
  // preparing GPIOs
  pinMode(gpio0_pin, OUTPUT);
  digitalWrite(gpio0_pin, LOW);
  pinMode(gpio2_pin, OUTPUT);
  digitalWrite(gpio2_pin, LOW);
  
  delay(1000);
  Serial.begin(115200);
  WiFi.begin(ssid, password);
  Serial.println("");

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println(ssid);
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  
  if (mdns.begin("esp8266", WiFi.localIP())) {
    Serial.println("MDNS responder started");
  }
  
  server.on("/", [](){
    server.send(200, "text/html", webPage);
  });
  server.on("/socket1On", [](){
    server.send(200, "text/html", webPage);
    Serial.println("1 on");
    digitalWrite(gpio0_pin, HIGH);
    delay(1000);
  });
  server.on("/socket1Off", [](){
    server.send(200, "text/html", webPage);
    Serial.println("1 off");
    digitalWrite(gpio0_pin, LOW);
    delay(1000); 
  });
  server.on("/socket2On", [](){
    server.send(200, "text/html", webPage);
    Serial.println("2 on");
    digitalWrite(gpio2_pin, HIGH);
    delay(1000);
  });
  server.on("/socket2Off", [](){
    server.send(200, "text/html", webPage);
    Serial.println("2 off");
    digitalWrite(gpio2_pin, LOW);
    delay(1000); 
  });
  server.begin();
  Serial.println("HTTP server started");
}

void loop(void){
  server.handleClient();

1 komentar:

  1. Betway Casino & Hotel - MapyRO
    Betway Casino & 청주 출장마사지 Hotel 평택 출장샵 is located in Thackerville, Texas and is part of the 김천 출장샵 Texas Gaming Commission. Betway Casino & Hotel is situated in 광주광역 출장마사지 Thackerville, 천안 출장샵 Texas

    BalasHapus