Serial communication Arduino Uno ESP8862-01

Hello,

I'm trying to connect an ESP8862-01 with a Arduino Uno R3 using Serial Communication. I just want to send a single String from the ESP to the Arduino, and let the Arduino print this message into the serial Monitor.

As a beginner, I probably have done something silly/stupid, but I just can't get it where I got it wrong. I found many topics and articles/videos everywhere but nothing worked for me so far...So I'm eventually asking help here.

I attached a screenshot of the schema I made.

I'm using a Bi-directional level converter to level down 5V (from Arduino) to 3.3V as I'm aware the ESP8862-01 only takes 3.3V.

  • I linked ESP-RX to PIN 2 of the Arduino
  • I linked ESP-TX to PIN 3 of the Arduino
  • ESP-CH and VCC are linked to 3.3 V
  • ESP-GND to Arduino GND

The ESP code I uploaded in the ESP is

#include <Arduino.h>

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.write("A");
}

The code I uploaded in the Arduino is:

#include <SoftwareSerial.h>

SoftwareSerial esp(2,3);

void setup() {
  Serial.begin(9600);
  esp.begin(9600);
  Serial.println("<Arduino is ready>");
}

void loop() {
    while(esp.available()) {
      Serial.write(esp.read());
    }
}

When I plug the Arduino to USB and open the Serial Monitor the only result I can see is

<Arduino is ready>

The message from ESP are not displayed as I would expect it...

Is anybody would have any idea of what I'm doing wrong?

I'm actually not even sure the problem comes from the code, or from the electronic part...Or both...

Thank you very much,

Adrien

This could be a fun project. I would suggest you take a look at the softwareserial library and implement that on the arduino. I am assuming it is Async serial and the hardware level are correct. You need to modify your code to implement this. Then you need to read what was sent from the eSP and serial.print it to the console. For some background information you need to do a bit of research on Async serial, baud, bits etc so you can set it up correctly. Use some caution as there is generally inversion in Async serial signals.

Thank you for your advices. Indeed I’m using SoftwareSerial library on the Arduino. I tried to use differrents baud rate (9600 and 115200) with still no success…

I also double checked that given the following code:

SoftwareSerial esp(2,3);

The Tx from the ESP is linked to the PIN 2 of the Arduino
The Rx from the ESP is linked to the PIN 3 of the Arduino

I still have no idea what I’m doing wrong here…

Hello, does anybody have a clue?

I'm still struggling, and I don't know now what I'm doing wrong here...

void loop()
{
  Serial.write("A");
}

On the ESP code, you should put at least some delay on the loop or you risk overrunning the Arduino, considering that it's using SoftwareSerial. Maybe add a 1 second delay just to check

Thank you for your response. Indeed you are right and this is something I already tried with both 1 and 2 sec, but didn't work better unfortunately.

I noticed though that the blue led from the ESP is not blinking every second as I would expect

I've read some article about arduio+esp01 saying that 3.3v from arduino could not stable enough to get this working...So another think I may try is to use an external poser source...but not sure this I'm going toward the good direction...

Hello - don’t give up !! My experience: The 3.3 V power supply from UNO is not sufficient for the ESP-01! I use the 5V pin of the UNO / Nano via a DC-DC converter (AMS1117 3.3) to supply the ESP-01. It works fine.

Thank you, I tried to used a dedicated power supply (hw-131 board like this: Mini Power Supply Module HW-131 Breadboard Power Module 3.3V/5V Power Supply Module for Arduino MB102 Breadboard). I'm still not able to make the ESP-01 to the Arduino...There is something else I'm doing wrong but I still don't understand why...

I attached a hand made schema of my current attempt.

As resumed:

  • I'm using a dedicated 5v/3.3 power source
  • I'm using a 3.3v <-> 5V logical converter for wire between ESP01 and Arduino
  • ESP-01 VCC and CHPD are connected to 3.3V
  • ESP-01 RX is connected to input 3 of Arduino (through logical converter)
  • ESP-01 TX is connected to input 2 of Arduino through logical converter)

If this schema is correct, then could the issue come from the code I upload from to the ESP01? Or the Arduino?

If anybody would have any idea/clue about the obvious mistake I made here I would be so happy. After weeks miserably trying to get this working...

Do you have GND from Arduino connected to GND everywhere else?

Thank you for your response.

I indeed connected GND of the arduino to GND everywhere else but I forgot it on my hand made schema.

Here attached a corrected version...

Try switching the wires (labelled RX and TX) at the ESP-01.

If you upload a sketch to the ESP-01 such that it only transmits a data stream - where is the activity seen ('RX' or 'TX')?

void loop ()
{
  Serial.print("MMMM");
  delay(100);
}

Thank you for your response.

I tried already to switch those wires, as I’m aware there is often a confusion between the Rx /Tx serial communications.

Unfortunately this didn’t work too.

So to at least be sure I’m correct here, I have this:

ESP Tx is wired to Pin 2 Arduino
ESP Rx is wired to Pin3 Arduino

From the Arduino I read data from ESP using SoftwareSerial configured as this:

#include <SoftwareSerial.h>

SoftwareSerial esp(2,3);
// 2 because ESP Rx is wired to Ardunio Pin 2
// 3 because ESP Tx is wired to Pin 3

void setup() {
  Serial.begin(9600);
  esp.begin(9600);
  Serial.println("<Arduino is ready>");
}
void loop() {
    while(esp.available()) {
      Serial.write(esp.read());
    }
}

Here the code I upload to the ESP 01:

#include <Arduino.h>

void setup()
  Serial.begin(9600);
}

void loop()
{
  Serial.write("A");
  delay(1000);
}

Is there something wrong on this code maybe?

Should I use SoftwareSelrial library from ESP code too ? (I tried that already, but could not get it work too)

My ESP-8266 experience is NodeMCU (and similar).
Please read over this Martyn Currey article.
http://www.martyncurrey.com/arduino-to-esp8266-serial-commincation/
He shows CH_PD pulled up to 3V3.
This is his set-up --

I’d want to be convinced that the ESP is outputting and you can prove this out with an LED+resistor between GPIO1 and GND and then between 3V3 and GPIO1.
Using my previous sketch, with the delay, it should be easy to see it mostly On one way and mostly Off the other way.

This way, the LED lights when data is sent:

+3V3-----A K----470Ω----GPIO1(TX)

Thank you for your help.

When wiring +3V3-----A K----470Ω----GPIO1(TX) following your recommandation, the LED lights.

This works with my NodeMCU.
Serial Monitor knocks out data sent by the NodeMCU.
The NodeMCU has this sketch –

void setup()
{
  Serial.begin(9600);
}

void loop() 
{
  Serial.print("MMMM\r\n");
  delay(1000);
}

My Uno has this sketch –

#include <SoftwareSerial.h>

const byte rxPin = 2;
const byte txPin = 3;

SoftwareSerial ExtESP(rxPin,txPin); // (rx,tx)

void setup() 
{
  ExtESP.begin(9600);
  Serial.begin(9600);
}

void loop() 
{
  if (ExtESP.available())   
  {  
    Serial.write(ExtESP.read());  
  }
}

GND to GND; NodeMCU GPIO1(TX) to Uno D2.
The Uno is connected to PC’s USB and the NodeMCU is running from the Uno’s 5V.
The Uno takes 3V as an acceptable HIGH, no level translation required.

Thank you for trying.

I removed the level converter following your recommandations, and I also used the exact same code you provided.

Still no luck.

I actually have a NodeMCU board that I still have not used already. I may try to replace the ESP8862-01 that is currently wired with the NodeMCU and see if it works better...

Unless it's the Uno.
Did you try other pins for SoftwareSerial(2,3)?
SoftwareSerial(3,2)? SoftwareSerial(8,9)?