esp8266 create tcp server but can't receive data
Posted: Thu Aug 04, 2016 9:27 am
I am using arduino ide to program esp8266 (wifi module) and I created a tcp server on the module then i used tcp client tester program to send and receive data .this is the code i am using
I managed to send data from the module but can't receive any data from my phone , Can anyone help me?
this is the code i am using
I managed to send data from the module but can't receive any data from my phone , Can anyone help me?
this is the code i am using
Code: Select all
#include <ESP8266WiFi.h>
int i =0;
char ssid[] = "moataz"; // your network SSID (name)
char pass[] = "58295829"; // your network password
int status = WL_IDLE_STATUS;
WiFiServer server(1050);
void setup()
{
// initialize serial:
Serial.begin(115200);
WiFi.mode(WIFI_AP_STA);
WiFi.begin("moataz", "58295829");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("connectedd");
server.begin();
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);
delay(200);
}
bool alreadyConnected = 0;
void loop() {
WiFiClient client = server.available();
if (client) {
if (!alreadyConnected) {
// clear out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
}
if (client.available() > 0) {
char thisChar = client.read();
Serial.println("We got data");
Serial.println(thisChar);
delay(200);
}
}