Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Banditoka
#91435 Hi,

I am new to ESP8266 and have a problem i cant solve.
I want to set up a TCP/IP connection with Matlab do send and receive data.

I set already did set up the ESP8266 as a AP and can connect my PC to it. I also can Ping it from the Terminal.
Matlab sends data as bytes and i already set up the connection to the esp8266, but dont know if it works.

The Problem is i dont want to set up a Webserver so i dont send any POST or GET request and i dont use http protocol.

As far as im now i dont get the data send from Matlab. Can somebody tell me if its even possible to use the ESP8266 in the form i want to and maybe somebody knows what im missing.

Thank you.

Code: Select all#include <ESP8266WiFi.h>



/*SSID and Password for Connection*/
const char* ssid="ESP8266";
const char* password ="symphony";

IPAddress local_ip(192,168,11,1);
IPAddress gateway(192,168,1,1);
IPAddress subnet(255,255,255,0);

bool ledstatus = LOW;
int GreenLed = 5;

WiFiServer server(1045);



void setup() {

  WiFi.mode(WIFI_AP);
  WiFi.softAPConfig(local_ip,gateway,subnet);
  WiFi.softAP(ssid,password);


  Serial.begin(115200);
  Serial.println();
  Serial.print("IP Adresse: "); Serial.println(WiFi.softAPIP());

 

 
  pinMode(GreenLed,OUTPUT);
 
 
 

  Serial.println("Wifi connected");
  /*WiFi.softAPConfig(local_ip,gateway, subnet);*/
  delay(100);

  server.begin();
  Serial.println("Server started");

 
}

void loop() {

  WiFiClient client = server.available();


   
   while(client.available()){
    uint8_t data = client.read();
    Serial.println(data);
    Serial.write(data);

    switch(data){
      case  '1':
                digitalWrite(GreenLed,HIGH);
      break;

      case  '0':
                digitalWrite(GreenLed,LOW);
      break;
    }
   
   }
   /*digitalWrite(GreenLed,ledstatus);*/
 
 
}