Updating OTA is amazing

I sucesfully uploaded the sketch but when I try to upload new sketches I need to enter the password . When I type 123 , authentication fails and I get an error. I think I have the 8 m variant.

The password stuff is for Yun’s.

Keep Serial Monitor closed and open the com port with Termite.

When trying to upload from OTA in termite I get:

Ready
IP address: 192.168.1.87
Error[1]: Begin Failed

Can you post the code that was uploaded?

I uploaded the ArduinoOTA Basic example using serial and the blink example using ota and I am getting the error.

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "Claxxxxxxxxxxxxxi Wi-Fi";
const char* password = "cxxxxxxxxxxxx3";

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  // ArduinoOTA.setHostname("myesp8266");

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

  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  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());
}

void loop() {
  ArduinoOTA.handle();
}

That is the ArduinoOTA example. Are you including the ArduinoOTA handlers in your blynk sketch? You need to put

#include <ArduinoOTA.h>

on the top

ArduinoOTA.begin();

In setup

and

ArduinoOTA();

In the loop

If you don’t have these in every sketch ota won’t work.

I edited my code and still same error in termite I get Begin Failed and In arduino Ide while uploading I get:
18:13:17 [ERROR]: No response from device
18:13:17 [ERROR]: No response from device

Blynk Code

/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 *   Downloads, docs, tutorials: http://www.blynk.cc
 *   Blynk community:            http://community.blynk.cc
 *   Social networks:            http://www.fb.com/blynkapp
 *                               http://twitter.com/blynk_app
 *
 * Blynk library is licensed under MIT license
 * This example code is in public domain.
 *
 **************************************************************
 * This example runs directly on ESP8266 chip.
 *
 * You need to install this for ESP8266 development:
 *   https://github.com/esp8266/Arduino
 *
 * Please be sure to select the right ESP8266 module
 * in the Tools -> Board menu!
 *
 * Change WiFi ssid, pass, and Blynk auth token to run :)
 *
 **************************************************************/

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define ledpin 2
#include <ArduinoOTA.h>


// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "62cxxxxxxxxxxxxxxxxxxx04a4";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "ClayxxxxxxxxFi";
char pass[] = "cxxxxxxxxxxxxxx13";

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  ArduinoOTA.begin();

  pinMode(ledpin, OUTPUT);
  analogWrite(ledpin, 0);
}

void loop()
{
  Blynk.run();
  ArduinoOTA.handle();
}

Arduino OTA code

#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>

const char* ssid = "Claxxxxxxxxxxxxxxxi";
const char* password = "cxxxxxxxxxx13";

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
  }

  // Port defaults to 8266
  // ArduinoOTA.setPort(8266);

  // Hostname defaults to esp8266-[ChipID]
  ArduinoOTA.setHostname("myesp8266");

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

  ArduinoOTA.onStart([]() {
    Serial.println("Start");
  });
  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());
}

void loop() {
  ArduinoOTA.handle();
}

did you power cycle after the first OTA? That can help.

Yes I did but I still get the same error.

Hmm. I don’t know. Put

ArduinoOTA.setHostname("myesp8266");

before ArduinoOTA.begin(); in the blynk sketch

This names your esp. Then check the network port to make sure you can actually see it under the new name.

Just to confirm the OTA works from the ArduinoOTA example and when you try to upload again it fails. Right?

Maybe add other bits from the Arduino OTA code to the blynk and see if it fixes it. Like WiFi.mode(WIFI_STA); Also

#include <WiFiUdp.h>
#include <ESP8266mDNS.h>

Here is a minimal template with blynk that I use to start all new projects.

#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxxx";
char ssid[] = "xxxxxxxx"; 
char pass[] = "xxxxxxxx"; 
void setup() {
  WiFi.mode(WIFI_STA);
  Blynk.begin(auth, ssid, pass);
  while (Blynk.connect() == false) {}
  //ArduinoOTA.setHostname("xxxxxxx"); // OPTIONAL
  ArduinoOTA.begin();
}
void loop() {
  Blynk.run();
  ArduinoOTA.handle();
}
3 Likes

Hi - I have OTA on Wemos D1 R2 (ESP8266) working nicely but how do I get access to Serial console ? Any help would be very much appreciated.

@mars do you mean when the WeMos is not connected to a computer or when you are doing the OTA (Termite) update and the WeMos is connected to a computer?

yes - I perform the OTA software update to the Wemos all fine - but then I want to see the Serial Console as I have a series Serial.println statements in the code. Normally I would open the serial monitor in Arduino IDE but that does not work any longer.

It wasn’t a yes or no question it was an either or question.

'1. With ESP connected to a computer?

or

'2. With ESP not connected to a computer?

1 or 2?

One easy way for 2 is to do a find and replace in the IDE changing Serial.print() to terminal.print() and add a Terminal widget to your project.

1 Like

I think I follow - but to be sure I will explain my exact setup. I have my WeMos connect via WiFi to my local Wifi. From my computer using Arduino IDE I do a complie & upload and it performs the process OTA. What I’m not sure about is how I view the outputs from my Serial.println remotely ? can I somehow remote Serial into the Wemos ?

Simple answer is you can’t. @tzapulica has done some work with sockets and I tested it some months ago.

From memory it involves hooking up a second ESP to the rx and tx pins.

1 Like

ok - thanks, thats answers it pretty clear.

Yes when uploading new sketches after Arduino OTA