Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By Joel
#37724 Just got my ESP8266 and I can successfully talk with it in the Serial Monitor with a Arduino uno r3. I have connected it to a network and it seems to be stable. I haven't done anything with the firmware (AT version:0.25.0.0 and SDK version:1.1.1). I can only talk with it over baud rate 115200. When I was going to start to write my project I found out that as soon the Arduino reads "Serial.begin(115200)" the ESP8266 doesn't respond anymore.

Do I have to use any library to be able to talk with the ESP8266 through a sketch? I've seen several guides without any libraries. Or have I just missed something important to get it to work



Code: Select alllong milli;

void setup() {
  milli = millis();
}

void loop() {
  //As long as as start(); isn't executed I can talk to ESP8266
  if(milli+10000 < millis()){
  start();
  }
}

void start(){
  Serial.begin(115200);
  Serial.println("AT");
  //After Serial.begin I can't talk to it anymore and it doesn't respond with OK
  delay(5000);
 
  if(Serial.find("OK")){
    //Do something
    Serial.println("OK");
  }
}


//First 10 seconds when I can talk to it
AT


OK
//After Serial.begin
AT
AT
AT
AT
AT
AT
Last edited by Joel on Sat Jan 09, 2016 2:58 pm, edited 1 time in total.
User avatar
By Joel
#37743
pipi61 wrote:Hi!
serial.begin don't call periodically, only call once in setup routine

Ohh yeah that's true. Just wrote something together to show my problem. But regardless it doesn't work. Just something simple as this still doesn't give me any response
Code: Select allvoid setup()
{
  Serial.begin(115200);
  Serial.println("AT");
  delay(5000);
  if(Serial.find("OK")){
    Serial.println("OK");
}
}

void loop(){
}