Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to updates ESP8266 via OTA / OTA Uploading #20

Open
ctripodi opened this issue Jun 17, 2017 · 3 comments
Open

Add the ability to updates ESP8266 via OTA / OTA Uploading #20

ctripodi opened this issue Jun 17, 2017 · 3 comments
Assignees

Comments

@ctripodi
Copy link

A features that could be great to have in this excellent project, is the ability to updates ESP8266/NODEMCU via OTA / OTA Uploading
http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html
Thanks.

@corbanmailloux
Copy link
Owner

I did the work for this on the add-ota-upload branch, but I could never get the OTA upload reliably working. When the work on the unified version of the code is complete (see #31), I'll take a look back at this and see if I can finally get it working.

@Philje123
Copy link

Philje123 commented Dec 14, 2017

I've successfully added OTA code to your code and it works perfectly.

I use it on a Magic Home RGB wifi controller. Other firmwares were too complicated for my needs so I've used this and changed the data pins accordingly and now added OTA.

Added this to config:

/**************************** FOR OTA **************************************************/
#define SENSORNAME "kitchenislandleds" //change this to whatever you want to call your device
#define OTApassword "supersecretpassword" //the password you will need to enter to upload remotely via the ArduinoIDE
int OTAport = 8266;

Then just added this between setup_wifi and void setup_wifi:

 //OTA SETUP
  ArduinoOTA.setPort(OTAport);
  // Hostname defaults to esp8266-[ChipID]
  ArduinoOTA.setHostname(SENSORNAME);

  // No authentication by default
  ArduinoOTA.setPassword((const char *)OTApassword);

  ArduinoOTA.onStart([]() {
    Serial.println("Starting");
  });
  ArduinoOTA.onEnd([]() {
    Serial.println("\nEnd");
  });
  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
    Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
  });
  ArduinoOTA.onError([](ota_error_t error) {
    Serial.printf("Error[%u]: ", error);
    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
    else if (error == OTA_END_ERROR) Serial.println("End Failed");
  });
  ArduinoOTA.begin();

  Serial.println("Ready");
  Serial.print("IP Address: ");
  Serial.println(WiFi.localIP());
}

@corbanmailloux
Copy link
Owner

@Philje123 Thanks for sharing. I've been planning to come back to the OTA work soon, and that example might help. I'm not sure if it's much different that what I had before, but I'll review and get it working.

(Note: I edited your comment just to add code formatting. When adding a multiline code block, surround the code with ``` on the lines above and below the code.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants