OTA Programming arduino mega with esp01

i am trying to compile the wifi101_ota example of arduinoOTA examples and getting this error.

C:\Users\DHRUVI~1\AppData\Local\Temp\arduino_modified_sketch_906113\WiFi101_OTA.ino: In function 'void setup()':

WiFi101_OTA:53:59: error: 'InternalStorage' was not declared in this scope

ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

^

exit status 1
'InternalStorage' was not declared in this scope

please help me with this.

thank you for your support.

Kashyapkoshti:
i am trying to compile the wifi101_ota example of arduinoOTA examples and getting this error.

C:\Users\DHRUVI~1\AppData\Local\Temp\arduino_modified_sketch_906113\WiFi101_OTA.ino: In function 'void setup()':

WiFi101_OTA:53:59: error: 'InternalStorage' was not declared in this scope

ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

^

exit status 1
'InternalStorage' was not declared in this scope

please help me with this.

thank you for your support.

do you still compile for Uno?

Juraj:
do you still compile for Uno?

no i am compiling for mega

ok I see that I should add an example in ArduinoOTA for the WiFiEspAT library

#include <WiFiEspAT.h>
#include <ArduinoOTA.h>

void setup() {
  //Initialize serial:
  Serial.begin(9600);

  Serial1.begin(115200);
  WiFi.init(Serial1);

  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

  // waiting for connection to Wifi network set with the SetupWiFiConnection sketch
  Serial.println("Waiting for connection to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
  }
  Serial.println();
  Serial.println("Connected to WiFi network.");

  // start the WiFi OTA library with internal (flash) based storage
  ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

  // you're connected now, so print out the status:
  printWifiStatus();
}

void loop() {
  // check for WiFi OTA updates
  ArduinoOTA.poll();

  // add your normal loop code below ...
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Juraj:
ok I see that I should add an example in ArduinoOTA for the WiFiEspAT library

#include <WiFiEspAT.h>

#include <ArduinoOTA.h>

void setup() {
  //Initialize serial:
  Serial.begin(9600);

Serial1.begin(115200);
  WiFi.init(Serial1);

if (WiFi.status() == WL_NO_MODULE) {
    Serial.println();
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }

// waiting for connection to Wifi network set with the SetupWiFiConnection sketch
  Serial.println("Waiting for connection to WiFi");
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.print('.');
  }
  Serial.println();
  Serial.println("Connected to WiFi network.");

// start the WiFi OTA library with internal (flash) based storage
  ArduinoOTA.begin(WiFi.localIP(), "Arduino", "password", InternalStorage);

// you're connected now, so print out the status:
  printWifiStatus();
}

void loop() {
  // check for WiFi OTA updates
  ArduinoOTA.poll();

// add your normal loop code below ...
}

void printWifiStatus() {
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

// print your WiFi shield's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

// print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Thank you very much for this.

After uploading this the last thing remain is password.

Can you please provide password?

where is its password and how to remove it

arduino says uploading but got this error after that
i also flashed megacode of optiboot and still got this error

processing.app.debug.RunnerException
 at cc.arduino.packages.uploaders.SSHUploader.uploadUsingPreferences(SSHUploader.java:150)
 at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
 at processing.app.SketchController.upload(SketchController.java:732)
 at processing.app.SketchController.exportApplet(SketchController.java:703)
 at processing.app.Editor$UploadHandler.run(Editor.java:2075)
 at java.lang.Thread.run(Thread.java:748)
Caused by: com.jcraft.jsch.JSchException: java.net.ConnectException: Connection timed out: connect
 at com.jcraft.jsch.Util.createSocket(Util.java:389)
 at com.jcraft.jsch.Session.connect(Session.java:215)
 at cc.arduino.packages.uploaders.SSHUploader.uploadUsingPreferences(SSHUploader.java:122)
 ... 5 more

Kashyapkoshti:
Thank you very much for this.

After uploading this the last thing remain is password.

Can you please provide password?

it is the third parameter in begin()
now "password"

if you use my my_boards definitions for Mega with modified Optiboot, then password is not parametrized in platform.txt. there is -password password in tools.avrdude.upload.network_pattern. you can change it to "{network.password}" to use the password entered in IDE

Juraj:
it is the third parameter in begin()
now "password"

if you use my my_boards definitions for Mega with modified Optiboot, then password is not parametrized in platform.txt. there is -password password in tools.avrdude.upload.network_pattern. you can change it to "{network.password}" to use the password entered in IDE

is it mandatory to flash optiboot in mega?

Kashyapkoshti:
is it mandatory to flash optiboot in mega?

modified Optiboot with the copy_flash_pages function
(or SD bootloader if SD card should be used as storage)

and don't forget the platform.txt settings.
it is best to use the my_boards definitions for Mega

Juraj:
modified Optiboot with the copy_flash_pages function
(or SD bootloader if SD card should be used as storage)

and don't forget the platform.txt settings.
it is best to use the my_boards definitions for Mega

Where i add pletform.txt settings?
Please give me related link so i can work with that

tools.avrdude.upload.network_pattern="{network_cmd}" -address {serial.port} -port {upload.network.port} -sketch "{build.path}/{build.project_name}.hex" -upload {upload.network.endpoint_upload} -sync {upload.network.endpoint_sync} -reset {upload.network.endpoint_reset} -sync_exp {upload.network.sync_return}

i found this in platform.txt .where should i add {network.passsword}?

please use my_boards from GitHub - JAndrassy/my_boards: My Arduino boards custom variants. You can use it as starting point for your boards specialities.
as recommended in ArduinoOTA README file

Juraj:
please use my_boards from GitHub - JAndrassy/my_boards: My Arduino boards custom variants. You can use it as starting point for your boards specialities.
as recommended in ArduinoOTA README file

please explain the steps to follow, where i put local.txt file in megacore or esp8266 of \AppData\Local\Arduino15\packages ?

can you provide screen recording of steps so that i can follow this.

Kashyapkoshti:
can you provide screen recording of steps so that i can follow this.

there is a screenshot with the folder structure in README of my my_boards on GitHub

unzip my_boards into hardware subfolder of the sketches folder

and restart the IDE.

then setup Uno for "Arduino as ISP" and use it to burn Optiboot from my_boards with "Burn bootloader" to Mega

Juraj:
there is a screenshot with the folder structure in README of my my_boards on GitHub

unzip my_boards into hardware subfolder of the sketches folder

and restart the IDE.

then setup Uno for "Arduino as ISP" and use it to burn Optiboot from my_boards with "Burn bootloader" to Mega

Can you suggest it for windows 10 because i cannot see hardware folder on documents of arduino. There is only libraries folder.

Do you know about error in comment#45 ?
What should I do after this?

Kashyapkoshti:
Can you suggest it for windows 10 because i cannot see hardware folder on documents of arduino. There is only libraries folder.

Do you know about error in comment#45 ?
What should I do after this?

you can create the hardware folder in Arduino folder

With Arduino IDE (I use Eclipse Sloeber) rename the platform.txt from my_boards to platform.local.txt and copy it next to platform.txt in the official board package to have the right upload command and not ssh

Juraj:
you can create the hardware folder in Arduino folder

With Arduino IDE (I use Eclipse Sloeber) rename the platform.txt from my_boards to platform.local.txt and copy it next to platform.txt in the official board package to have the right upload command and not ssh

I copied platform.local.txt in C:\Program Files (x86)\Arduino\hardware\arduino\avr but after that still got this error and when i first time try to connect to the network port it askes for password, i typed "password" says "unable to connact, wrong password?".

thanks for your support

Kashyapkoshti:
I copied platform.local.txt in C:\Program Files (x86)\Arduino\hardware\arduino\avr but after that still got this error and when i first time try to connect to the network port it askes for password, i typed "password" says "unable to connact, wrong password?".

thanks for your support

did you restart the IDE after placing platform.local.txt?
check %userprofile%\AppData\Local\Arduino15\packages\arduino\hardware\avr\ . The AVR package in use could be there

where should i connect reset pin of arduino mega to esp01?

in my pc at \AppData\Local\Arduino15\packages i cannot find arduino folder. i see esp8266 folder
I installed from official installler and in C: drive of pc
still getting ssh uploader error

i have doubt about passsword