ESP8266 Developer Zone The Official ESP8266 Forum 2017-04-26T13:33:50+08:00 https://bbs.espressif.com:443/feed.php?f=65&t=4020 2017-04-26T13:33:50+08:00 2017-04-26T13:33:50+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4020&p=12597#p12597 <![CDATA[Re: let gpio2 be input control button]]> I am not familiar with Arduino interface for ESP8266, but you should try to reload the WDT between every few milliseconds of delay, rather than add a long delay with no WDT reload.

Statistics: Posted by Guest — Wed Apr 26, 2017 1:33 pm


]]>
2017-04-21T17:07:03+08:00 2017-04-21T17:07:03+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4020&p=12468#p12468 <![CDATA[let gpio2 be input control button]]> it's will work but without long press
when long press the button it will come out like this
is there any suggest for me or how to avoid it ran out to be ,thanks all
========================================================
Soft WDT reset

ctx: cont
sp: 3ffef380 end: 3ffef590 offset: 01b0

>>>stack>>>
3ffef530: 3fffdad0 00000000 3ffee53c 40201e20
3ffef540: 3ffe84f0 00000000 000003e8 40202af6
3ffef550: 3ffee410 3fff04c4 00000000 402010a3
3ffef560: 00000000 00000000 00000001 40203499
3ffef570: 3fffdad0 00000000 3ffee560 402034c4
3ffef580: feefeffe feefeffe 3ffee570 40100718
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(1,6)
========================================================


it's for bootloader
usb->ttL esp8266
********************************************
TX -> RX
RX -> TX
VCC -> VCC , CH_PD
GND -> GND, gpio0
*********************************************
it's for work

********************************************
TX -> RX
RX -> TX
VCC -> VCC , CH_PD
GND -> GND






Code:

#include<WiFiClient.h>
#include<ESP8266WiFi.h>
const char* ssid = "";
const char* pass = "";
char thisChar = 0;
unsigned long int timer = 0;
boolean alreadyConnected = false;
WiFiServer Server(8087);
WiFiClient client;
void setup()
{
  pinMode(0,OUTPUT);
  digitalWrite(0,LOW);
  pinMode(2,INPUT);
  Serial.begin(115200);
  WiFi.begin(ssid, pass);
  Serial.println("Connecting");
  // wifi connecting
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(500);
  }
  printout();
 
  Server.begin();
}

void loop() {
  //wait for new client
  WiFiClient client = Server.available();
  if (!client) {
    return ;
  }
  Serial.println("Client connected");
  client.println("connected");
  while (client.connected()) {
    if(client.available()){
    String req = client.readStringUntil('\r');
    Serial.println(req);
    client.flush();
    int val;
    if(req.indexOf("0"))
      val=0;
    if(req.indexOf("1"))
      val=1;   
    if((req=="OFF")||(req=="off"))
    {
      Serial.println("Stop");
      client.println("Stop");
      client.stop();
      return;
    }     
   
    //digitalWrite(0,val);
    client.println(val);
    }   
    if(digitalRead(2)==1)
    {
      client.println("DOWN");
      Serial.println("DOWN");
      while(digitalRead(2)==1){
          if(digitalRead(2)==0){
             break;
            }         
        }
         client.println("UP");
         Serial.println("UP");
      }
  }
}



void printout() {
  Serial.println("");
  Serial.print("connected to SSID:  ");
  Serial.println(WiFi.SSID()); 
  Serial.print("Server status:  ");
  Serial.println(Server.status());
  IPAddress ip = WiFi.localIP();
  Serial.print("localIP:  ");
  Serial.println(ip);
  long rssi = WiFi.RSSI();
  Serial.print("signal strength:  ");
  Serial.print(rssi);
  Serial.println(" dBm");

}


未命名.png

Statistics: Posted by superme55557 — Fri Apr 21, 2017 5:07 pm


]]>