Updating OTA is amazing

From Command prompt (with and without being Administrator) what do you get with these commands:

ping 192.168.1.103
tracert 192.168.1.103

I am not at my system right now , but when i pinged the IP last night i got 2ms ish per hop.

But this was without specifying Administrator, (but I’m not sure if I have set cmd to always open as Administrator)

Did not tracert it

And what is your subnet? Why would you want to keep wired/wireless seperated anyway in a home situation? I’m using a form of OTA via the webbrowser too and it works fine. The little webserver runs on the ESP and I can upload a compiled bin file to it.

Code is bit like this:

//************** HTTP UPDATE ******************
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>

const char* host = "bla";
const char* ssid = "wifinet";
const char* password = "wifipwd";

ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;
//************** END HTTP UPDATE **************

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

  //************** HTTP UPDATE ******************
  Serial.println();
  Serial.println("Booting Sketch...");
  WiFi.mode(WIFI_STA);
  WiFi.softAPdisconnect(true);
  //WiFi.begin(ssid, password); // If you uncomment this it will also be in AP mode, from security perspective, you don't want that!

  while(WiFi.waitForConnectResult() != WL_CONNECTED){
    WiFi.begin(ssid, password);
    Serial.println("WiFi failed, retrying.");
  }

  MDNS.begin(host);

  httpUpdater.setup(&httpServer);
  httpServer.begin();

  MDNS.addService("http", "tcp", 80);
  Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", host);
  Serial.println("");
  Serial.print ( "IP address: " );
  Serial.println ( WiFi.localIP() );
  //************** END HTTP UPDATE **************
}

void loop()
{
  //************** HTTP UPDATE ******************//
  httpServer.handleClient();
  //************** END HTTP UPDATE **************//
}

Nowyou can go to the IP of the thing and upload the bin file. It works perfectly :slight_smile:

2 Likes

I don’t want to keep it separate, I just plugged and played when i recently got the new AC1900 router and its working.

So are you saying that is why it doesn’t work?

If could be. There is the possibility that one of your components is firewalled and has issues with protocols or weird stuff like that (trust me, I’m a network enigneer! :wink: ). What is the subnet of the wired and wireless components?

The following sketch will allow you to do OTA with a web browser or wireless serial comms (Arduino IDE etc).

Termite should give you something like this (3 available url formats):

Start
End
ets Jan  8 2013,rst cause:2, boot mode:(3,6)
...........   
Booting
Ready - OTA Success!!!
IP address: 192.168.10.171
Now open http://esp8266.local/update in your browser or 
http://192.168.10.171/update or http://cf3908.lan/update if you prefer.

You need to fix your network though @Dave1829 but it might be worth a try via a web browser from your known IP, ChipID or fixed url of http://esp8266.local/update

Arduino IDE (certainly 1.6.9 onwards) now allows you to export the compiled binary for your sketches (same folder as your sketches) from Sketch Menu. So you don’t have to go hunting for it in the tmp directory as indicated by the old Github notes.

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

#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
const char* host = "esp8266"; // will be "8266.local/update" in web browser
ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;

const char* ssid = "xxxxxxxx";
const char* password = "xxxxxxxxxx";

void setup() {
  Serial.begin(115200);
  Serial.println("\nBooting");  
  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 - OTA Success!!!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());  
  MDNS.begin(host);
  httpUpdater.setup(&httpServer);
  httpServer.begin();
  MDNS.addService("http", "tcp", 80);
  String ipaddress = WiFi.localIP().toString();
  String chipID = String(ESP.getChipId(), HEX);
  char charChipID[10]; 
  chipID.toCharArray(charChipID, sizeof(charChipID));
  char charipaddress[16]; 
  ipaddress.toCharArray(charipaddress, sizeof(charipaddress)); 
  Serial.printf("Now open http://%s.local/update in your browser or \n", host); 
  Serial.printf("http://%s/update or http://%s.lan/update if you prefer.\n", charipaddress, charChipID);
}

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

when i try the web browser update:

woohoo!!!

2 Likes

In a “secure” environment like your home you would normally have all devices on the same subnet so they can all “see each other”. Different subnets are used to “hide” different networks from different user types. So in a business the finance department might have a different subnet to the technical department etc.

I noticed you mentioned you have a separate WiFi router and cable broadband router, which is quite rare in a domestic environment these days. Manufacturers mainly use 192.168.10.x and 192.168.1.x for their default IP addresses but obviously they can be changed by the user. When you piggybacked one router to the other it looks like the IP’s worked out ok but that doesn’t mean the network is fully operational.

Looking good Dave. Have you tried a bin file upload with Termite open?

yeah, it is a fcukaround modem from the cable company, complete barstard. google it: Netgear CG3100

when i tried to make it all the same - i lost my NAS and my powerline broadband stuff all fell over, so really just got it to work, then was too scared to touch it!

but would love to fix it all up…

Yes be careful with the IP’s as you could lose all functionality of your network.

Perhaps we will come back to this.

I probably can help you out setting it all up correctly, but we’d better do that in a PM, after all, it’s not a network forum here :slight_smile:

1 Like

i click on export BIN file but it just complies it - which folder does it go to?

Same folder as your sketch.

Booting
Ready - OTA Success!!!
IP address: 192.168.1.103
Now open http://esp8266.local/update in your browser or 
http://192.168.1.103/update or http://dc2054.lan/update if you prefer.

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
@cp:0
ld
ü
Booting
Ready - OTA Success!!!
IP address: 192.168.1.103
Now open http://esp8266.local/update in your browser or 
http://192.168.1.103/update or http://dc2054.lan/update if you prefer.

THANK YOU BOTH SO MUCH!!!

2 Likes

i know you haven’t seen my crawl space or attic, but trust me - this is SO GOOD!

so i use @Costas code in every sketch from now on?

2 Likes

Even better when your ESP is 10,000 miles away :slight_smile:

Yes you must have these OTA elements in all sketches that you flash to the device or it will lose the ability to do further OTA updates. It will now take one upload without OTA elements, even empty setup() and empty loop() but then the device will be unobtainable.

i honestly can’t begin to imagine the amazing stuff that you must be able to do!!!

2 Likes

OK, wonderful, i hope this helps any others who are as techno-illiterate as i am…

sorry to take up so many posts, but i think we set out a fair few ways to approach troubleshooting this OTA thing didn’t we? :blush: )

1 Like