Problems connecting to the esp8266

Hi All,

I am having real problems access the AT commands.

I have the following set up between a nano and the ESP-8266:

GND------->GND
VCC-------->+3.3v
CH_PD---->+3.3v
TX--------->RX
RX--------->tx

I am using the flowing code as a serial through:

#include <SoftwareSerial.h>
SoftwareSerial softSerial(2, 3); // RX, TX

void setup() 
{
  uint32_t baud = 9600;
  Serial.begin(baud);
  softSerial.begin(baud);
  Serial.print("SETUP!! @");
  Serial.println(baud);
}

void loop() 
{
    while(softSerial.available() > 0) 
    {
      char a = softSerial.read();
      if(a == '\0')
        continue;
      if(a != '\r' && a != '\n' && (a < 32))
        continue;
      Serial.print(a);
    }
    
    while(Serial.available() > 0)
    {
      char a = Serial.read();
      Serial.write(a);
      softSerial.write(a);
    }
}

When i send AT the blue led flashes once very quickly on the ESP-8266 but i get no response back.

I have tried various baud rates but to no avail.

I have been searching for day on the web, but to no avail, anyone see what I am missing?

thanks in advance

see if Arduino to ESP8266 By Serial Communication | Martyn Currey helps

Thank you,

I have already tried this, and again i receive nothing back from the esp8266.
I get the blue led flash on the esp8266 as if it is receiving data, but no response to the Arduino

and are you sure that there is the AT firmware in your esp8266?

Juraj:
and are you sure that there is the AT firmware in your esp8266?

According to the information on ebay, yes:

put Blink into Arduino, connect esp8266 to USB of Arduino connecting esp8266 with Tx to TX and Rx to RX of the Arduino. then open Serial Monitor, set baud rate to 115200 set CR/LF and try sending AT.

Many thanks, I will give that a go when i get home.

I did try it with a completely blank sketch, but will try it with blink too.

JonMiles:
Many thanks, I will give that a go when i get home.

I did try it with a completely blank sketch, but will try it with blink too.

It is the same, empty or Blink. And it didn't work? For most people it works. With my boards (Uno WiiFi, Seeduino) it didn't work either and the module was OK.

You should use an USB to TTL 3.3 V adapter to setup the esp8266, because the AT firmware has default baud rate 115200 and SoftwareSerial can't go so fast.

Have you checked voltage on 8266 vcc pin using a multimeter?
On your hardware do you have a voltage regulator to generate +3,3v from +5v? Arduino's +3,3 cannot supply 8266 due to maximun current 70ma, 8255 requires 250ma.

default baudrate is 115kb, not 9600

bye

realmeteo:
Have you checked voltage on 8266 vcc pin using a multimeter?
On your hardware do you have a voltage regulator to generate +3,3v from +5v? Arduino's +3,3 cannot supply 8266 due to maximun current 70ma, 8255 requires 250ma.

default baudrate is 115kb, not 9600

bye

its external power at 3.28v

I have success using an Arduino Mega + 8266 connected at serial3 with this sketch.

/*
Arduino Mega 2560 + ESP-05(ESP8266)

ESP-05 running firmware:
AT version:0.40.0.0(Aug  8 2015 14:45:58)
SDK version:1.3.0
Ai-Thinker Technology Co.,Ltd.
Build:1.3.0.2 Sep 11 2015 11:48:04

Connection between Mega & ESP-05, 
refer "Connect with Arduino Mega 2560 via Level Converter" in:
http://goo.gl/wtG89i

Mega + ESP_05 act as station, join WiFi AP of my phone.
Once server setup, you can visit the webpage in ESP-05
by visit the IP show in Serial Monitor, under the command:
AT+CIFSR
+CIFSR:STAIP,"192.168.43.15"

If always show "Module have no response.",
check your connection, or reset ESP-05 by power OFF and ON.

 */
#define ASCII_0 48
#define ESP8266 Serial3

//WiFi hotspot setting on my phone
String SSID = "Neffos";
String PASSWORD = "password";

int LED = 10;
int RESET_8266 = 8;

boolean FAIL_8266 = false;

String strHTML1 = "<!doctype html>\
<html>\
<head>\
<title>arduino-er</title>\
</head>\
<body>\
<H1>Arduino web server</H1>";

String strHTML2 = "</body>\
</html>";

//String strHTML = "arduino-er.blogspot.com";

#define BUFFER_SIZE 128
char buffer[BUFFER_SIZE];

void setup() {
  pinMode(LED, OUTPUT);
  pinMode(RESET_8266, OUTPUT);
  
  
  digitalWrite(RESET_8266, HIGH);
  digitalWrite(LED, LOW);
  delay(300);
  digitalWrite(RESET_8266, LOW);
  digitalWrite(LED, HIGH);
  delay(200);
  digitalWrite(LED, LOW);
  delay(300);
  digitalWrite(LED, HIGH);
  delay(200);
  digitalWrite(LED, LOW);

  do{
    Serial.begin(115200);
    ESP8266.begin(115200);
  
    //Wait Serial Monitor to start
    while(!Serial);
    Serial.println("--- Start ---");

    ESP8266.println("AT+RST");
    delay(1000);
    if(ESP8266.find("ready"))
    {
      Serial.println("Module is ready");
      
      ESP8266.println("AT+GMR");
      delay(1000);
      clearESP8266SerialBuffer();
      
      ESP8266.println("AT+CWMODE=1");
      delay(2000);
      
      //Quit existing AP, for demo
      Serial.println("Quit AP");
      ESP8266.println("AT+CWQAP");
      delay(1000);
      
      clearESP8266SerialBuffer();
      if(cwJoinAP())
      {
        Serial.println("CWJAP Success");
        FAIL_8266 = false;
        
        delay(3000);
        clearESP8266SerialBuffer();
        //Get and display my IP
        sendESP8266Cmdln("AT+CIFSR", 1000);  
        //Set multi connections
        sendESP8266Cmdln("AT+CIPMUX=1", 1000);
        //Setup web server on port 80
        sendESP8266Cmdln("AT+CIPSERVER=1,80",1000);
        
        Serial.println("Server setup finish");
      }else{
        Serial.println("CWJAP Fail");
        delay(500);
        FAIL_8266 = true;
      }
    }else{
      Serial.println("Module have no response.");
  digitalWrite(RESET_8266, LOW);
  digitalWrite(LED, HIGH);
  delay(300);
  digitalWrite(RESET_8266, HIGH);
  digitalWrite(LED, LOW);
  delay(200);

      
      delay(500);
      FAIL_8266 = true;
    }
  }while(FAIL_8266);
  
  digitalWrite(LED, HIGH);
  
  //set timeout duration ESP8266.readBytesUntil
  ESP8266.setTimeout(1000);
}

void loop(){
  int connectionId;
  
  if(ESP8266.readBytesUntil('\n', buffer, BUFFER_SIZE)>0)
  {
    Serial.println("Something received");
    Serial.println(buffer);
    if(strncmp(buffer, "+IPD,", 5)==0){
      Serial.println("+IPD, found");
      sscanf(buffer+5, "%d", &connectionId);
      Serial.println("connectionId: " + String(connectionId));
      delay(1000);
      clearESP8266SerialBuffer();
      
      sendHTTPResponse(connectionId, strHTML1);
      sendHTTPResponse(connectionId, "<hr/>-END-
");
      sendHTTPResponse(connectionId, strHTML2);

      //Close TCP/UDP
      String cmdCIPCLOSE = "AT+CIPCLOSE="; 
      cmdCIPCLOSE += connectionId;
      sendESP8266Cmdln(cmdCIPCLOSE, 1000);
    }
  }
}

void sendHTTPResponse(int id, String response)
{
  String cmd = "AT+CIPSEND=";
  cmd += id;
  cmd += ",";
  cmd += response.length();
  
  Serial.println("--- AT+CIPSEND ---");
  sendESP8266Cmdln(cmd, 1000);
  
  Serial.println("--- data ---");
  sendESP8266Data(response, 1000);
}

boolean waitOKfromESP8266(int timeout)
{
  do{
    Serial.println("wait OK...");
    delay(1000);
    if(ESP8266.find("OK"))
    {
      return true;
    }

  }while((timeout--)>0);
  return false;
}

boolean cwJoinAP()
{
  String cmd="AT+CWJAP=\"" + SSID + "\",\"" + PASSWORD + "\"";
  ESP8266.println(cmd);
  return waitOKfromESP8266(10);
}

//Send command to ESP8266, assume OK, no error check
//wait some time and display respond
void sendESP8266Cmdln(String cmd, int waitTime)
{
  ESP8266.println(cmd);
  delay(waitTime);
  clearESP8266SerialBuffer();
}

//Basically same as sendESP8266Cmdln()
//But call ESP8266.print() instead of call ESP8266.println()
void sendESP8266Data(String data, int waitTime)
{
  //ESP8266.print(data);
  ESP8266.print(data);
  delay(waitTime);
  clearESP8266SerialBuffer();
}

//Clear and display Serial Buffer for ESP8266
void clearESP8266SerialBuffer()
{
  Serial.println("= clearESP8266SerialBuffer() =");
  while (ESP8266.available() > 0) {
    char a = ESP8266.read();
    Serial.write(a);
  }
  Serial.println("==============================");
}

open serial monitor at 115kb
active wifi hotspot of your smartphone.

String SSID = "Neffos"; is name of smartphone wifi hotspot
String PASSWORD = "password"; hotspot password

then oper browser on smartphone and surf ip address that read on serial monitor ;
browser show

Arduino web server

note: SoftwareSerial cannot work at 115kb.. use a real serial port (Mega has 4 serial ports)

Will dig out a mega and try this, its buried in a project at the moment.

Thank you all

You don't need a Mega.

You can do this with a Uno; I have done it.

http://www.martyncurrey.com/arduino-to-esp8266-serial-commincation/