Friday, August 25, 2017

code for ESP01 to setup an ACCESS POINT etc.....

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

#define MODE_AP

const char *ssid = "adhirvu_alavi";  //hotspot's name
const char *pw = "kathirnilavan"; //hotspot's password
IPAddress ip(120, 120, 120, 120); //hotspot's IP
IPAddress netmask(255, 255, 255, 0);
const int port = 265; // port#

WiFiServer server(port);
WiFiClient client;

uint8_t buf[1024];
uint8_t x = 0;

void setup() {
  delay(500);
  Serial.begin(250000);
  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(ip, ip, netmask);
  WiFi.softAP(ssid, pw);
  server.begin(); // start TCP server

}

void loop() {

  if (!client.connected()) { // if client not connected
    client = server.available(); // wait for it to connect
    client.setNoDelay(1);
    return;
  }

  if (Serial.available()) {
    while (Serial.available()) {
      buf[x] = (char)Serial.read(); // reading from arduino serial....
      if (x < 1023) x++;
    }
    //data to client.....
    client.write((char*)buf, x);
    x = 0;
  }

}



video:
 

No comments:

Post a Comment