Wifi ESP8266

Hello Forums, I am trying to an app that can communicate from arduino to my phone using an ESP8266 module for a project . I have tried a lot of examples and connections shown from youtube but when I am uploading I always get an error message .

Sketch uses 274924 bytes (26%) of program storage space. Maximum is 1023984 bytes.
Global variables use 27188 bytes (33%) of dynamic memory, leaving 54732 bytes for local variables. Maximum is 81920 bytes.
esptool.py v2.6
2.6
esptool.py v2.6
Serial port COM5
Connecting……_____
Traceback (most recent call last):
File “C:\Users\seahe\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.2/tools/upload.py”, line 25, in
esptool.main(fakeargs)
File “C:/Users/seahe/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py”, line 2653, in main
esp.connect(args.before)
File “C:/Users/seahe/AppData/Local/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/tools/esptool\esptool.py”, line 468, in connect
raise FatalError(‘Failed to connect to %s: %s’ % (self.CHIP_NAME, last_error))
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header
esptool.FatalError: Failed to connect to ESP8266: Timed out waiting for packet header

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

The code and hardware connections are found https://maker.pro/esp8266/tutorial/esp8266-tutorial-how-to-control-anything-from-the-internet I followed the connections shown in the link above . I have also tried others example but when i upload it always show me a error message . I cant figure out what is the problem .

it will sometimes show “the selected serial port does not exist”

I am using a Mega board . The following attachment is a picture of the settings used to upload to my board.

Thank you.

300px-ESP-01.jpg

code?

#include <ESP8266WiFi.h>

const char* ssid = “YOUR_SSID”;//type your ssid
const char* password = “YOUR_PASSWORD”;//type your password

int ledPin = 2; // GPIO2 of ESP8266
WiFiServer server(80);//Service Port

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

pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);

// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(“WiFi connected”);

// Start the server
server.begin();
Serial.println(“Server started”);

// Print the IP address
Serial.print(“Use this URL to connect: “);
Serial.print(“http://”);
Serial.print(WiFi.localIP());
Serial.println(”/”);
}

void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}

// Wait until the client sends some data
Serial.println(“new client”);
while(!client.available()){
delay(1);
}

// Read the first line of the request
String request = client.readStringUntil(’\r’);
Serial.println(request);
client.flush();

// Match the request

int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1){
digitalWrite(ledPin, LOW);
value = LOW;
}

//Set ledPin according to the request
//digitalWrite(ledPin, value);

// Return the response
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(""); // do not forget this one
client.println("");
client.println("");

client.print("Led pin is now: ");

if(value == HIGH) {
client.print(“On”);
} else {
client.print(“Off”);
}
client.println("

“);
client.println(“Click <a href=”/LED=ON”>here turn the LED on pin 2 ON
“);
client.println(“Click <a href=”/LED=OFF”>here turn the LED on pin 2 OFF
“);
client.println(”");

delay(1);
Serial.println(“Client disconnected”);
Serial.println("");
}

MolomitZ:
code?

why? he can't upload?

esptool.py v2.6

Why are you using this to upload the program?

The linked tutorial shows how to use a USB>TTL converter or the Arduino itself to with a simple upload of the code from the IDE.

cattledog:
Why are you using this to upload the program?

The linked tutorial shows how to use a USB>TTL converter or the Arduino itself to with a simple upload of the code from the IDE.

esp8266 arduino core 2.5..+ has the python version of esptool. python is installed with the core

Juraj:
esp8266 arduino core 2.5…+ has the python version of esptool. python is installed with the core

does that mean I have to use python to run the wifi shield ?

ELY1408:
does that mean I have to use python to run the wifi shield ?

you run python to upload to esp8266. the esptool.py is a python script

did you solved it? was programming fine, but after board update, getting the same error... >:(
using

ESP -

and

UART-TTL