Blog Adi Sanjaya Global Techno Solution

Delphi, Mikrokontroler , Embedded system...Menerima Pembuatan alat berbasis mikrokontroller

LightBlog
Responsive Ads Here

Sunday, May 28, 2017

Membuat chat server wemos

Membuat chat server wemos,  salah satu fungsi nya adalah kontrol melalui wifi, tentunya ini setelah anda kembangkan ya , ini hanya basic concept saja

Membuat chat server wemos
Membuat chat server wemos


berikut kode nya

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <WiFiServer.h>

#define PORT 1000

WiFiClient client;
WiFiServer server(PORT);

String dataClient;
String dataServer;

const char* ssid = "HUAWEI-3962";  //  your network SSID (name)
const char* pass = "71538701";       // your network password

void setup() {
  Serial.begin(115200);
  Serial.print("Koneksi TCPIP ");
  Serial.println("Port : ");
  Serial.print(PORT);
  pinMode(BUILTIN_LED,OUTPUT);// output LED
  pinMode(12,OUTPUT);//output buzzer
  WiFi.begin(ssid,pass);
  while(WiFi.status()!=WL_CONNECTED){
    Serial.print(".");
    delay(500);
  }
Serial.println("Anda Terkoneksi ke Akses Point : ");
Serial.print(ssid);
Serial.println("Alamat IP : ");
Serial.print(WiFi.localIP());
delay(200);
server.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
 while(!client.connected()){
  client=server.available();
 }
 while(client.connected()){
 if (client.available() > 0) {
      char thisChar = client.read();
      server.write(thisChar);
      client.print(thisChar);
      Serial.write(thisChar);
 }
}
}

selamat berexperiment..

No comments:

Post a Comment

Silakan dikomentari