Can not initialize ESP8266

I recently started doing networking with the Arduino, and I'm finding it rather difficult. I have the ESP8266 chip connected to an Arduino Uno board. The chip is supplied with 3.3 V (not from the arduino board), and I start by connecting it to the TX and RX ports so that I can change the baud rate to 9600 via the terminal. Everything works great this far. I change the terminal from 115200 to 9600 and send an AT command which returns OK. I can list networks and even connect to one, via the terminal.

However, when trying to run my code, the problems arise. I move the TX and RX to pins 6 and 7 before running the code, just to clarify. Here it is:

// WiFiEsp - Version: 2.2.1
#include <WiFiEsp.h>
#include <WiFiEspClient.h>
#include <WiFiEspServer.h>
#include <WiFiEspUdp.h>
// WireData - Version: Latest
#include <WireData.h>
#include <SoftwareSerial.h>
#include <Wire.h>

SoftwareSerial Serial1(6, 7);
char ssid[] = "my_SSID";
char pass[] = "my_password";
int status = WL_IDLE_STATUS;
void printWifiStatus() {
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
}

void setup() {
  Serial.begin(115200);
  Serial1.begin(9600);
  delay(1000);
  WiFi.init(&Serial1);
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true);
  }
  while (status != WL_CONNECTED) {
    Serial.print("Attemting to connect to SSID: ");
    Serial.print(ssid);
    status = WiFi.begin(ssid, pass);
  }
  Serial.println("You're connected to the network");
  printWifiStatus();
}

void loop() {}

When monitoring the terminal, I see this:

[WiFiEsp] Initializing ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] Cannot initialize ESP module
[WiFiEsp] >>> TIMEOUT >>>
[WiFiEsp] No tag found
WiFi shield not present

Are there any obvious errors on my part?

to talk to AT firmware from sketch swap RX and TX. connect RX of Uno to TX of esp module

I'm pretty sure those are correct. Pin 7 is connected to RXD and pin 6 is connected to TXD. I tried swapping just to be sure, but that didn't change anything.

what AT firmware or SDK version do you have?

This is the output from the chip running AT+GMR:

AT version:1.1.0.0(May 11 2016 18:09:56)
SDK version:1.5.4(baaeaebb)
Ai-Thinker Technology Co. Ltd.
Dec 20 2017 10:13:56

The chip was included with the book that contains my posted code, so it would be strange if the AT version or SDK version would stop this from working.

PelleS:
The chip was included with the book that contains my posted code, so it would be strange if the AT version or SDK version would stop this from working.

I asked because I have a new WiFiEspAT library for SDK 3 (AT 1.7.x)

So, the solution is to use a newer library?

PelleS:
So, the solution is to use a newer library?

it is on you. you would need to flash AT firmware version 1.7 (SDK 3) first.

I think I have more or less the same problem as PelleS.
I searched all over the web, particulary on this forum to find an answer to my simple question : How do I establish SIMPLE communication between Uno and ESP ? e.g. send an AT command and receive the answer from the ESP. My final goal is to send data over WiFi collected by the Uno (or even Nano) to another arduino or smartphone.
I use an arduino Uno because I can't find instructions anywhere about Nano+ESP, and connect it to an 8 pin ESP-01 (8266EX) The RX-TX goes through a 3.3 /5 converter board, 3.3V and ground, I take from the Arduino board. It might be necessary to add a seperate 3.3V power supply, but because I'm not using the Wifi (yet) I know that the 3.3V output delivers enough power (for now). The current that I measured for the ESP + converter boards is about 12mA, so shouldn't be a problem for the Uno.

Here's how I connect the boards :
ESP---Arduino ESP---Arduino

TX --- TX (7) GND --- GND
CH --- NC IO2 --- NC
RST --- NC IO1 --- NC
VCC --- 3.3V RX --- RX(6)

Because I don't want to use WiFi etc. (yet) I'm only interested in simple communication with the ESP using this code :

#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX : from,to ESPString incomingString;

String incomingString = "";
String cmd = "AT+RST";

void setup() {
  Serial.begin(9600);   // COM
  Serial1.begin(9600);// ESP
}

void loop()
{
  Serial1.print(cmd);
  incomingString = Serial1.readString();
  Serial.println(incomingString);
  Serial.println("-----");
  incomingString = "";
  delay(500);
}

I should get
OK

OK

etc...

well ... I get this :

(10 spaces)

(10 spaces)

etc.

I do see the blue LED on the ESP board blink every +/- 500mS. If I swap RX and TX : NO blinking blue LED.

Who knows (where I can find) a SIMPLE solution for this (very basic) problem ?
After I master this, I'll try to get the WiFi working... and then Blynk, and then merge all this with my data collecting Nano... But I wanna go step by step ! :slight_smile: So please no complete setups for webservers, etc (yet ! :slight_smile: )

Thanks in advance !

PaulVdB:
I think I have more or less the same problem as PelleS.
I searched all over the web, particulary on this forum to find an answer to my simple question : How do I establish SIMPLE communication between Uno and ESP ? e.g. send an AT command and receive the answer from the ESP. My final goal is to send data over WiFi collected by the Uno (or even Nano) to another arduino or smartphone.
I use an arduino Uno because I can't find instructions anywhere about Nano+ESP, and connect it to an 8 pin ESP-01 (8266EX) The RX-TX goes through a 3.3 /5 converter board, 3.3V and ground, I take from the Arduino board. It might be necessary to add a seperate 3.3V power supply, but because I'm not using the Wifi (yet) I know that the 3.3V output delivers enough power (for now). The current that I measured for the ESP + converter boards is about 12mA, so shouldn't be a problem for the Uno.

Here's how I connect the boards :
ESP---Arduino ESP---Arduino

TX --- TX (7) GND --- GND
CH --- NC IO2 --- NC
RST --- NC IO1 --- NC
VCC --- 3.3V RX --- RX(6)

Because I don't want to use WiFi etc. (yet) I'm only interested in simple communication with the ESP using this code :

#include "SoftwareSerial.h"

SoftwareSerial Serial1(6, 7); // RX, TX : from,to ESPString incomingString;

String incomingString = "";
String cmd = "AT+RST";

void setup() {
  Serial.begin(9600);  // COM
  Serial1.begin(9600);// ESP
}

void loop()
{
  Serial1.print(cmd);
  incomingString = Serial1.readString();
  Serial.println(incomingString);
  Serial.println("-----");
  incomingString = "";
  delay(500);
}




I should get 
OK
-----
OK
-----
etc...

well ... I get this :

(10 spaces)
-----
(10 spaces)
-----
etc.

I do see the blue LED on the ESP board blink every +/- 500mS. If I swap RX and TX : NO blinking blue LED.

Who knows (where I can find) a SIMPLE solution for this (very basic) problem ? 
After I master this, I'll try to get the WiFi working... and then Blynk, and then merge all this with my data collecting Nano... But I wanna go step by step ! :) So please no complete setups for webservers, etc (yet ! :) )

Thanks in advance !

wire RX to TX. transmit to receive

Juraj:
wire RX to TX. transmit to receive

OK. Thanks Juraj.
It's getting better ...
Now I get

!eIE⸮

!eIE⸮

Baud rates are set right... (both 9600)
When I change the baud rate :

void setup() 
{
  Serial.begin(9600);   // COM
  Serial1.begin(19200);// ESP
}

I see on my monitor :

AT+RST

AT+RST

etc..

When I disconnect and reconnect the CH pin to VCC I see this :

B⸮…⸮e⸮⸮P⸮^⸮§⸮⸮)[8⸮⸮⸮⸮A⸮⸮⸮R⸮[8⸮⸮⸮⸮A⸮⸮⸮R⸮[8⸮{⸮{⸮⸮⸮⸮r ⸮⸮⸮⸮⸮⸮⸮⸮⸮
Ai-Thinker Technology Co. Ltd.

ready


AT+RSTWIFI DISCONNECT


AT+RST

AT+RST

etc...

what am I doing wrong ?

did you set the AT firmware to 9600 baud with AT+UART command?

Juraj:
did you set the AT firmware to 9600 baud with AT+UART command?

Thanks for your reply ! but nope, I hadn't done that. But after changing my setup() to :

  Serial.begin(9600);   // COM
  Serial1.begin(9600);// ESP
  Serial1.print("AT+UART_DEF=9600,8,1,0,0");

I found another way to set baud to 9600 :

void setup() 
{
  Serial.begin(9600);   // COM
  Serial1.begin(9600);// ESP
  Serial1.print("AT+CIOBAUD=9600");
}

both times the same "garbage" returns...

What's still wrong ? ? ?

PaulVdB:
Thanks for your reply ! but nope, I hadn't done that. But after changing my setup() to :

  Serial.begin(9600);   // COM

Serial1.begin(9600);// ESP
  Serial1.print("AT+UART_DEF=9600,8,1,0,0");



I found another way to set baud to 9600 : 


void setup()
{
  Serial.begin(9600);  // COM
  Serial1.begin(9600);// ESP
  Serial1.print("AT+CIOBAUD=9600");
}




both times the same "garbage" returns...

What's still wrong ? ? ?

you must send the command at current baud rate

Juraj:
you must send the command at current baud rate

Thanks Juraj,
Is there a way to find out what the "current baudrate" is ?
Or is it just trial and error ?
What baudrate is standard on new ESP's ?
Anyhow... thanks for your interest !

PaulVdB:
Thanks Juraj,
Is there a way to find out what the "current baudrate" is ?
Or is it just trial and error ?
What baudrate is standard on new ESP's ?
Anyhow... thanks for your interest !

on new AT firmware versions default is 115200 baud.

Juraj:
on new AT firmware versions default is 115200 baud.

Thanks again Juray !
I've read about this, but there's lots of confusion, so I thought that 9600 always works.
Now next thing I read :
Software Serial is not reliable or even not supporting 115200...
Maybe I have to hook it up to e.g. a Mega on one of it's "hardware" serials... ?
But again... tanx for the info !

PaulVdB:
Thanks again Juray !
I've read about this, but there's lots of confusion, so I thought that 9600 always works.
Now next thing I read :
Software Serial is not reliable or even not supporting 115200...
Maybe I have to hook it up to e.g. a Mega on one of it's "hardware" serials... ?
But again... tanx for the info !

SoftwareSerial has problems to receive at 115200. but you can send the command at 115200