0

I have an Arduino nano and an ESP8266-01.

The first thing to do seems to be to send AT commands via the serial monitor and see the replies.

ESP connect as follows:

  GND   GND   
  GPIO2 not connected
  GPIO0 not connected
  RX    to Arduino RX via level shifter
  TX    to Arduino TX via level shifter
  CHPD  3.3V
  RST   3.3V
  VCC   3.3V

Image of breadboard (imgur rejects) https://www.dropbox.com/s/aif8afi29amy02h/20180807_135218.jpg?dl=0

When connecting the red light comes on and the blue light flashes quickly (and the Arduino RX light flashes with it) then goes out.

Here is the sketch I'm using. (The ESP8266 must be disconnected from RX+TX for uploading of the sketch to work.)

     void setup() { 
  Serial.begin(115200); 

  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH); 
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH); 
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  delay(3000);
 }

(I like to blink the LED to demonstrate that uploading worked.)

With the serial monitor set to 115200 (NL&CR) I sent AT and nothing happens.

What have I got wrong? I really don't understand! Thanks in advance for any suggestions.

(This is actually my third ESP8266. The first worked fine on 5V but stopped working after I set the baud rate to 9600. I presume 5V killed it but it's strange that it worked for so long. The second, connected as above, when powered up made that power supply red hot and melted the jumpers.)

0

2 Answers 2

1

First problem is that io 0 of the esp8266 must be pulled HIGH for normal boot. With io 0 not HIGH, the esp8266 starts in flashing mode.

Your other problem is the reset pin connection. It must be connected with pull-up resistor or not connected.

See ESP8266 Hardware Design Guidelines

Pin32 serves as an RST pin which can be left floating when it is not used. The reset pin is held low when the chip is enabled. In order to avoid resets caused by external interference, the lead is generally required to be short, and no external pull-up resistor is necessary

I suspect that "The reset pin is held low when the chip is enabled." is a bad translation. They say in pin description "32 EXT_RSTB I External reset signal (Low voltage level: Active)". What they mean is that the chip resets when reset pin is set LOW.

10
  • Disconnecting it hasn't made any difference. Aug 7, 2018 at 15:34
  • remove the level shifter from esp8266 TX pin
    – Juraj
    Aug 7, 2018 at 16:56
  • With TX connected directly to Arduino TX: no change except that the ESP8266 blue light does not now flash when powering it on. Aug 7, 2018 at 17:04
  • important! set io0 of esp8266 HIGH with a pullup resistor
    – Juraj
    Aug 7, 2018 at 17:26
  • 1
    remove Serial.begin from Nano sketch or better put Nano in permanent reset connecting reset pin of Nano to ground
    – Juraj
    Aug 7, 2018 at 18:00
1

So:

  • Connect the ESP8266 RX/TX directly to the Arduino, not via the level shifter.
  • No need to connect GPIO0.
  • RST can be either left floating or connected to 3.3V; it makes no difference.
  • No need to Serial.begin; an empty sketch will work.

This is what you want to see in the terminal:

AT


OK
AT+CWMODE?

+CWMODE:2

OK
AT+CWMODE=1

OK
AT+CWLAP

+CWLAP:(3,"SKY61611",-83,"90:21:06:79:fb:0a",1,110,0)
+CWLAP:(3,"SKY3CA89",-90,"60:38:e0:d4:7d:7d",6,96,0)
+CWLAP:(3,"PLUSNET-TS2H",-75,"a4:08:f5:ae:ab:c2",6,103,0)
+CWLAP:(3,"SKY3CA89",-79,"90:21:06:c6:1f:6d",6,120,0)
+CWLAP:(3,"MY WIFI 6739",-38,"18:e3:bc:2c:67:39",6,127,0)
+CWLAP:(3,"BTHub6-CF7H",-88,"88:a6:c6:27:53:a4",6,108,0)
+CWLAP:(3,"SKY7A62E",-79,"7c:4c:a5:1c:7f:59",11,130,0)
+CWLAP:(4,"EE-mce6kx",-86,"e4:3e:d7:71:35:f3",11,128,0)

OK

The next thing to do is to set the ESP8266's baud rate to 9600 so that it can be used with SoftwareSerial. The command to do this is

AT+UART_DEF=9600,8,1,0,0

Then we can move the ESP8266 off the Arduino's RX/TX pins onto some other pins and forward commands from the terminal to the ESP8266 and print the responses.

#include <SoftwareSerial.h>

#define RX 10
#define TX 11
SoftwareSerial esp8266(RX, TX);

void setup() {
  Serial.begin(9600);
  esp8266.begin(9600);
  Serial.println("setup() done");
}


    // Check for messages form the ESP8266 and process them.
void processEsp() {
  while (esp8266.available() > 0) {
    String line = esp8266.readStringUntil('\n');
    processLine(line);
  }
}


void loop() {
  if (Serial.available() > 0)
  {
    String command = Serial.readStringUntil('\n'); // AT+CWLAP
    Serial.println("Command Sent: " + command);
    esp8266.println(command);
  }

  processEsp();
  //Serial.println("...");
  //delay(1000);
  // We wait once.
  // During that wait the buffer fills, and we only see what's in the buffer.
}


void processLine(String line) {
  Serial.println(line);
}

The serial reader must run in a tight loop; a delay causes it's buffer to fill and characters beyond the buffer length are lost. Enabling the delay causes the AT+CWLAP response to be truncated.

There is no way to detect the end of a response to an AT command. The ESP8266 can send anything at any time. What it sends should be processed line by line; the line/record delimiter is \r\n.

1
  • 1
    the WiFiEsp library has standard Arduino networking API over esp8266 AT commnands. the library can detect the end of the response. (you could al least upvote my answer)
    – Juraj
    Aug 10, 2018 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.