ESP8266 won't work w/ Uno, Pro Mini 3.3v, or Standalone via FTDI Cable

Hello All,

I’ve been stuck with ESP8266 for the last 10 days with mixed results. I have tried with 5 different modules, and only once was I able to get to work and send AT commands - which was hooked up directly to my PC (OSX/Serial Monitor at 115200 BUAD) using an FTDI cable.

This single time aside, I have not been able to get it to work using the same configuration, nor with my Uno R3, or my Pro Mini 3.3v. With the Uno, I tried both as a bypass (uploaded BareMin and used Rx/Tx to communicate directly), or using SerialSoftware in my sketch allowing me to send AT commands via Serial Monitor.

This is as far as I’m able to get:

I AM able to see the bootup output, tho most of the characters are jumbled (see below). This happens both with a direct hookup to PC, or with my Sketch on Uno. Basically, I wire up the module and I disconnect/reconnect CH-PD from 3.3v - and get this output:

sll��|�l�|�l�b|����r�clc��on�lno���bp�lrlslp�o��lco�|l��b��on�l��l`�nol`or���n�lp�o�r�����bn�|�c��on�l`�onl�l`ns���or�``�n��b�ol���nn��lp�n�r������l�cn�|�b��no�l�l`�no�lns���or�`r��or�`sl��n���on����rono�l�brl��l������lll~rl��lllo���l�lll��l��n��n�n���o�ll��n�o���nl�|bl`slrl�B�
Ai-Thinker Technology Co. Ltd.

ready

And here is where it fails; when I send any AT commands, the Serial Monitor simply spits the characters back out to my Serial Monitor (as tho you short Rx/Tx and the characters just come back).

And that’s IT! That’s as far as I get (except the ONE TIME that it worked couple days ago).

I have tried using both Uno’s 3.3v rail as well as an external Power Supply. I’ve tried every BAUD rate, configuration, and tripple-checked my wiring.

I’m really at a loss and frustrated. Sorry to vent; thanks in advance for your guidance.

Below is my Sketch for sending AT commands, just in case.

/F


#include <SoftwareSerial.h>

// Define the Rx and Tx Pins
#define rxPin 10
#define txPin 11

// Define the BAUD Rate for hardware (hUart) and software (sUart) ports
#define hUart 9600
#define sUart 115200

// Define the LED Pin - no longer used!
#define ledPin 13

// Define dDelay 
#define dDelay 100

String xString, yString;

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
byte pinState = 0;



void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);

// Get ready to send data
  Serial.begin(hUart);
    
// set the data rate for the SoftwareSerial port
mySerial.begin(sUart);


// Add to the drama and excitement by delaying 3 seconds
// And then let'em know you're ready!
delay(dDelay);
Serial.println("System Ready to Rock: ");

}

void loop() {


  //  READ FROM SERIAL MONITOR, and
  //  SEND TO SW SERIAL

  yString = Serial.readString();
  if (yString != ""){
    mySerial.print(yString);
  }


  xString = mySerial.readString();
  if (xString != ""){
    Serial.println(xString);
  }

}

In you define

"#define hUart 9600

define sUart 115200

"

why did you use 115200 as baud rate?. I have tried that code and it works for me. But i used a baudrate of 9600 for both. I think the software serial is only capable to the maximum of 19200 baud i guess. try to use 9600 baud for both. BTW, i used Arduino pro mini with a 3.3 volts.

electricalhobbyist:
In you define

"#define hUart 9600
#define sUart 115200
"

why did you use 115200 as baud rate?. I have tried that code and it works for me. But i used a baudrate of 9600 for both. I think the software serial is only capable to the maximum of 19200 baud i guess. try to use 9600 baud for both. BTW, i used Arduino pro mini with a 3.3 volts.

The reason I used 115200 is because the ESP communicates at that BAUD rate - that I’m certain of.

However, you make a good point about SoftwareSerial - does anyone know if there’s a limit to the Software Serial buad rate?

Hello robofred,

I came across your post while I too was struggling yesterday to make ESP8266 work with my Arduino Uno. Good news is that I was able to make it work today (finally) :). I’m writing few points below that may help you debug the problems with your setup (in case you are still struggling)

  1. Make sure that ESP8266 is only powered thru external 3.3v power supply. Do not forget to tie the GND of Arduino to GND of external power supply (being used to power ESP).
  2. connect CH_PD to HIGH using 10K pullup. connect RST to HIGH using 1K pull up. You may connect a button switch to pull the ESP RST pin to GND, thereby RESETing the ESP module (whenever needed). I found this approach more useful.
    3.Per your setup, make sure that you have rx pin 10 connected to Tx on ESP8266. Connect Tx pin 11 to Rx on ESP. I used Logic Shifter to connect software Tx to Rx on ESP. You may alternatively use Voltage divider with 1K and 2K resistors as well. I connected software Rx pin directly to Tx on ESP as I was able to receive only if the last pair was directly connected.
  3. My ESP baud is 115200. I wrote the setup to run at 115200 for Software Serial and Serial to run at 115200. I tried running Serial at 9600 and got the same end result. So can continue with your setup() code.
  4. However, I used different code for loop part. Here is the snippet.

void loop() {
if (module.available()) { //ESP has data to send thru software serial
while(module.available()) {
Serial.write((char)module.read()); //Write data from ESP to Serial port or COM port
}
}

if(Serial.available()) { //USer is entering data into COM port window
delay(1000); //Wait so that buffer fills up before the data is sent to ESP
String command="";
while(Serial.available()) {
command+=(char)Serial.read();
}
module.println(command); // write data to ESP thru software serial
}
}

**module was my reference to SoftwareSerial

  1. With this setup, I would first reset the ESP using the push button and I would receive ready on the Serial Monitor. If I now issue AT commands, the Rx LED on Arduino UNO board would blink, and I would start receiving the output from ESP on my serial monitor window. So, the setup was working and I was able to communicate to ESP using Arduino Uno.

However, I still had a problem at this point. Most of the time (if not always), the output that I would receive would have a few jumbled characters. For example, OK from ESP would come as PK, ready would become reacy and so on. A closer inspection revealed that some of the bits were not being received properly, causing the alphabets to turn into the next adjacent alphabets (O becoming P). That was the point when your post came useful to me and I started suspecting the Software serial. I read thru many other pages that Software serial do create problems when the buffers fall out of sync with bits being received on wire, leading to error on some bits. This was happening with me as well. So I’m pretty sure that running SoftwareSerial on 115200 was the source of the problem. So I decided to do away with softwareserial. But since Arduino UNO has just one H/W serial, which is also used when the UNO communicates to computer, I decided to test the H/W serial first and then use the same in my sketch. To test the H/W serial, I pulled the Arduino RESET pin to GND and then connected Arduino TX to ESP TX and Arduino RX to ESP RX. Make sure that Logic Shifter/Voltage Divider was used between Arduino TX → EXP RX.

Now open the COM Port and start sending command. Effectively, this setup would work as USB to TTL convertor and you would be able to see the ESP working and sending.

Now write a sketch, that makes use of H/W serial. Here is the snippet

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear();
lcd.print(“Started”);
}

void loop() {
if(Serial.available()) { //Serial has incoming data from ESP
String response=""
while(Serial.available()) {
response+=(char)Serial.read();
}
lcd.clear();
lcd.print(response);
}
}

Before this code is uploaded to the board, remove the connections from H/W Tx/RX pins (0 and 1) and upload the code. Now remove the USB cable, connect the ESP TX/RX to Arduino RX/TX. This time, the connections have to be reversed i.e. Arduino TX to ESP Rx and Arduino RX to ESP Tx. This is reverse to what we saw earlier when using Arduino as USB to TTL convertor.

Now power the Arduino from external supply (not USB) and reset the ESP 8266. As you might have noticed above, I used a LCD display to see the progress on the LCD screen. This is because one cannot use the COM port as the COM port too would use the Arduino RX/TX pins and the two would thus interfere.

This time, I was able to see the progress from LCD screen and i could see ESP booting up from reset point. It went to ready and then WIFI CONNECTED and finally WIFI GOT IP state. This was because my Home WIFI credentials were already saved by me to ESP using FTDI board earlier.

You can modify the code above to issue AT command to ESP during setup() phase and to get the things working. Hope this helps.

Hello Ingit,

Thank you so much for the through post. It appears that my specific problem was with my external power supply. I used a 3.7v Li-Ion battery and everything worked fine after that.

I should mention that while I DO NOT recommend this, I did NOT use a TTL Level-Shifter and so far I've not experienced any damage neither to my ESP nor to the Uno.

Thanks again for the post.

Best, /F