پاسخ : اتصال دو esp8266
یه سوال دیگه من چجوری میتونم فلش این بنویسم که دیگه هر وقت برقش قطع میشه اطلاعات نپره؟
یه سوال دیگه من چجوری میتونم فلش این بنویسم که دیگه هر وقت برقش قطع میشه اطلاعات نپره؟
AT+CWMODE=3
AT+CIPMUX=1
AT+CIPSERVER=1
void loop() { SendToESP8266("AT+CIPSEND=0,1"); WaitForESP8266(5000); Serial.print('a'); WaitForESP8266(5000); }
[FONT=Yekan]void loop()[/FONT] [FONT=Yekan]{[/FONT] [FONT=Yekan] SendToESP8266("AT+CIPSEND=0,1");[/FONT] [FONT=Yekan] WaitForESP8266(5000);[/FONT] [FONT=Yekan] Serial.print('a');[/FONT] [FONT=Yekan] WaitForESP8266(5000);[/FONT] [FONT=Yekan] [/FONT] [FONT=Yekan]}[/FONT] [FONT=Yekan][/FONT]
[FONT=Yekan]AT+CIPSTART="TCP","192.168.4.1",333[/FONT] [FONT=Yekan][/FONT]
void loop() { SendToESP8266("AT+CIPSEND=0,1"); WaitForESP8266(5000); Serial.print('a'); WaitForESP8266(5000); }
AT+RESTORE
AT+CWMODE=3
AT+CIFSR
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const char* ap_ssid = "eca";
const char* ap_password = "aa123123";
const int LED_PIN = 2;
IPAddress apIP(192, 168, 4, 1);
WiFiServer server(80);
WiFiClient client;
void setup() {
Serial.begin(115200);
delay(10);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP(ap_ssid, ap_password);
Serial.println();
Serial.print("Connecting to: ");
Serial.println(ap_ssid);
server.begin();
Serial.println("Server started");
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
// Match the request
int val;
if (req.indexOf("/gpio/0") != -1)
val = 0;
else if (req.indexOf("/gpio/1") != -1)
val = 1;
else {
Serial.println("invalid request");
client.stop();
return;
}
// Set GPIO2 according to the request
digitalWrite(2, val);
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n";
s += (val)?"high":"low";
// Send the response to the client
client.print(s);
delay(1);
Serial.println("Client disonnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
}
دیدگاه