ESP 01 and Arduino UNO Can't Communicate

Good afternoon,

I am doing an IoT project using Arduino UNO and ESP 01.

Here is a sample of my code.

#include <WiFi.h>


const char* ssid = "*******";
const char* password = "**********";
void setup() {
  
  Serial.begin(115200);
  Serial.println(ssid);
  Serial.println(password);

  WiFi.begin(ssid,password);
  Serial.print("Connecting:");
  Serial.println(WiFi.status()); 
  
}

void loop() {}

and when I upload my code, here is the error:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x41
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x73
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x61
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x77
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x61
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x6e
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x69
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x54
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x69
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x6e

What is the cause of this error?
Attached is my wiring diagram.

The connection of the ESP-01 to the native serial port which is used for uploading (to the Arduino).

I changed it TX-TX and RX-RX.

It uploads but when I upload this code it displays "WiFi shield not present".

#include <WiFi.h>
#include <SPI.h>

const char* ssid = "*******";
const char* password = "*******";
void setup() {
  
  Serial.begin(115200);
  Serial.println(ssid);
//  Serial.println(password);

  WiFi.begin(ssid,password);
 if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present"); 
 } 
}

void loop() {
  

}

You are uploading to the Arduino, not the ESP.

You have to remove the Arduino processor (or keep it in reset) to mistreat it as an USB to TTL interface.

Then you could upload a sketch compiled for ESP8266 with its uploader (which is not avrdude IIRC).

I didn't get a thing. I'm sorry. I'm just new in this stuff about ESP 01.

Can you explain it a little lightly?

I could, but I wont, because you are lacking the most basic understanding of what you are trying to do.

I don't have a link to a ESP and Arduino beginners tutorial, maybe someone else can provide that,
or you could try to find one yourself.

https://tttapa.github.io/ESP8266/Chap01%20-%20ESP8266.html

I fail to understand why you think WiFi.h library should work with esp8266.

It works with Arduino WiFi Shield

As far as I know ESP 01 is not Arduino WiFi shield, maybe I am wrong?

Edit: That is not your biggest problem though.

agrp87132:
I fail to understand why you think WiFi.h library should work with esp8266.

It works with Arduino WiFi Shield

WiFi - Arduino Reference

As far as I know ESP 01 is not Arduino WiFi shield, maybe I am wrong?

Edit: That is not your biggest problem though.

The OP is confused.

That schematic looks like he is trying to communicate via AT commands.
So the sketch is all wrong.

I suggest the OP read Martyn Currey's excellent tutorial: Arduino to ESP8266 By Serial Communication – Martyn Currey

.

ieee488:
I suggest the OP read Martyn Currey's excellent tutorial: Arduino to ESP8266 By Serial Communication – Martyn Currey

or A Beginner's Guide to the ESP8266

Thank you for the advice and links you gave me. Now I can connect my ESP 01 to my cellphone's hotspot.

Connection established!
IP address: 192.168.43.27

with this config:

esp Arduino
TX --- TX
RX --- RX
RST --- VCC
GPIO0 - GND
VCC --- VCC
GND --- GND

and my Arduino UNO's RST is on GND.

I used this code in my ESP 01.

#include <ESP8266WiFi.h>        // Include the Wi-Fi library

const char* ssid     = "SSID";
const char* password = "password";     // The password of the Wi-Fi network

void setup() {
  Serial.begin(115200);         // Start the Serial communication to send messages to the computer
  delay(10);
  Serial.println('\n');
  
  WiFi.begin(ssid, password);             // Connect to the network
  Serial.print("Connecting to ");
  Serial.print(ssid); 
  Serial.println(" ...");

  int i = 0;
  while (WiFi.status() != WL_CONNECTED) { // Wait for the Wi-Fi to connect
    delay(1000);
    Serial.print(++i); Serial.print(' ');
  }

  Serial.println('\n');
  Serial.println("Connection established!");  
  Serial.print("IP address:\t");
  Serial.println(WiFi.localIP());         // Send the IP address of the ESP8266 to the computer
}

void loop() { }

Did I do something wrong about it? Am I on the right path now?

Well if you can ping 192.168.43.27 from a computer connected to your network (i.e. has ip address 192.168.xxx.xxx) you have successfully programmed ESP-01 to connect.

I am not sure what you are asking??

agrp87132:
Well if you can ping 192.168.43.27 from a computer connected to your network (i.e. has ip address 192.168.xxx.xxx) you have successfully programmed ESP-01 to connect.

I am not sure what you are asking??

Actually, I just want to know if I am on the right path. Since I used Arduino UNO as a USB-TTL converter, I want for my Arduino UNO to communicate with my ESP 01 module. How will I do it? I saw several tutorials about using SoftwareSerial library but how could I know that the ESP 01 received the data?

Please give code or link to help me.

ESP-01's default firmware will respond to AT queries. That is how you know you are communicating to it!

ieee488:
ESP-01's default firmware will respond to AT queries. That is how you know you are communicating to it!

Given the above code and configuration, do you think I can still use AT commands? I tried sending AT commands but there is no response from the ESP 01

I enter programming mode in ESP 01. Did I burn the default firmware?

OninVR:
Given the above code and configuration, do you think I can still use AT commands? I tried sending AT commands but there is no response from the ESP 01

Sorry I did not see that you have overwritten the AT firmware.

You have to understand that you don't need the Arduino anymore since you have flashed the ESP-01 with the ESP8266 Arduino core firmware. That firmware is not a good idea for the ESP-01.

If you want to use the Arduino with the ESP-01 and with the ESP-01 strictly only for wifi, you need a different library. GitHub - ekstrand/ESP8266wifi: ESP8266 Arduino library with built in reconnect functionality

ieee488:
Sorry I did not see that you have overwritten the AT firmware.

So what I did is that I already have overwritten the AT firmware? Geez man. Thank you. So what am I gonna use now to make my ESP 01 and Arduino UNO communicate? Any suggestion?

Yeah that firmware is good for ESP8266 modules like the ESP-12 which have a lot of IO pins but not helpful for the ESP-01.

You have to re-flash your ESP-01 with AT firmware. https://www.allaboutcircuits.com/projects/flashing-the-ESP-01-firmware-to-SDK-v2.0.0-is-easier-now/ or buy another one. They're cheap.

Also, here's another library ( GitHub - bportaluri/WiFiEsp: Arduino WiFi library for ESP8266 modules ) after you do that. It is recommended by pert who is very knowledgeable about the Arduino.