0
我使用arduino ide來編程esp8266(wifi模塊),我在模塊上創建了一個tcp服務器,然後我用tcp客戶端測試程序發送和接收數據。這是我正在使用的代碼 我設法從模塊發送數據,但無法從手機接收任何數據,任何人都可以幫助我嗎? 這是我使用esp8266創建tcp服務器,但無法接收數據
#include <ESP8266WiFi.h>
int i =0;
char ssid[] = "moataz";
char pass[] = "58295829";
int status = WL_IDLE_STATUS;
WiFiServer server(1050);
void setup()
{
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) {
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);
}
}
你在手機上做什麼來接收數據? – leetibbett