can i flash esp8266-01 with mega/uno

guys,i have google a lot with method to flash esp8266-01 module,but much of it is using ttl usb,but i didnt buy it,can i flash it with my mega?

what i want is to reset ssid in it.it keep connected old hotspot.TQ

yes you can - as long as you know how it's currently setup so that you can establish an AT command session with it.

Then it's just a matter of sending the right AT commands

COMPUTER <--- USB ---> ARDUINO MEGA <-- WIRES ON SERIAL2 --> ESP01

I used an adapter to ensure I can play with 5V safely (ESP is 3.3V)

ESP-adapter.png

and you stick your ESP on top of it

ESP-Breadboard.png

// ESP connected to Serial2 Rx & Tx and powered appropriately
// ------------
// WARNING
// ------------
// ==> Ensure proper voltage conversation your module does not support 5V on Rx
// ------------


void setup() {
  Serial.begin(115200);
  Serial2.begin(115200); // depending on your config try 9600 19200 38400 57600 74880 115200
  delay(2000);  // wait a bit for ESP to possibly boot
}

void loop()
{
  int r;

  // read what the user types in the Serial Console and send it to the ESP
  while (Serial.available()) {
    r = Serial.read();
    if (r != -1) Serial2.write((char) r);
  }

  // read what the ESP spits out and print it to the Serial Console
  while (Serial2.available()) {
    r = Serial2.read();
    if (r != -1) Serial.write((char) r);
  }

}

ensure the Serial console in the IDE is setup at 115200, sending CR and LF (probably)

to see if it works, type AT and you should see OK.
if it does not try changing the baud rate on Serial2.

please note this comment in the code

// ------------
// WARNING
// ------------
// ==> Ensure proper voltage conversation your module does not support 5V on Rx
// ------------

I've a tutorial in french on playing with a MEGA and ESP01 if you can read french

oh man,it works.i use seriel port 2 17/16 and it work...how can it dont work on serial 1

It should work find on Serial1 if you change the code and wiring accordingly. In fact, the wiring in the picture shows it connected to Serial1.

Yep the picture is just an indication and might not match the code - comment in the code states to use Serial2.

I have actually had some issues in some fake Arduino with Serial1 whereas Serial2 was working fine.... may be an hardware challenge