So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By SuperNinja
#70831
villTech wrote:do you know how to set up a server on the internet and save files on it?

i just made a ftp server with use Filezilla to upload data like .bin
The ARduino example use http server , not ftp !

NickLD wrote:
ftheirs wrote:Could you share the tutorial or link that you've used?[/quote="ftheirs"]

Have you taken a look at the ESP8266 Arduino examples?

in the examples shows how to remotely update the running sketch from an HTTP server.

https://github.com/esp8266/Arduino/blob ... Update.ino

Also recommend reading the docs page on the "HTTP Server" update section https://github.com/esp8266/Arduino/blob ... ttp-server


Is it possible to update ESP8266 over internet with use of a ftp server instead of http(s) ?
User avatar
By PeteKnight
#70837 The easiest way to do HTTP updates is to use a free web hosting account. I use hostinger.co.uk

If you’re not familiar with how web hosting servers work, you may struggle, so here’s a quick guide..

Create a free hosting account - in this example we’ll assume that the URL is updater.hostinger.com

Set Arduino IDE to verbose output.

Update your code to use the http update URL of http//:updater.hostinger.com/updater.ino.bin and put some code in there that gets your device to check for updates every 24 Hours at a specific time of day (2am maybe).

Compile the code and find the path for your ino.bin file you see this in verbose mode) pick-up the file and rename it to updater.ino.bin

Log in to your free hosting account and navigate to /public_html and drop the updater.ino.bin file in there.

That’s basically it. At 2am the ESP will check to see if there’s a file in your specified URL location and if there is it will install it and reboot.
The only drawback is that if you leave the updater file where it is, the ESP will keep reinstalling it every day at 2am. Not really a problem, but probably not what you really want.
The easy solution is to delete the updater file once it’s been installed. The more complex solution is to run a script on the server that deletes the file automatically, but that’s really beyond the scope of what I use HTTP updater for, so I’ve never bothered.

I’ve refined the process described above a little to make it work better for me. I have separate sub folders for each device and the names of these folders are based on the MAC address of the ESP device.
I also include the system compile date/time in my code (__DATE__ and __TIME__) and get the device to send a Pushover message to me when it reboots. The message includes the compile date/time info.

This way, I know that the new firmware has successfully installed and it acts as a reminder for me to go and manually delete the updater file. It also lets me know when the device has restarted unexpectedly, and it’s good to be able to see which version of the firmware you’re running.

Hope this helps.

Pete.
User avatar
By SuperNinja
#70919 Hi Pete
PeteKnight wrote:The easiest way to do HTTP updates is to use a free web hosting account. I use hostinger.co.uk


i login a free hosting account, i use http://www.000webhost.com by Hostinger and i create ????????.000webhostapp.com "web server".
i update my code :
Code: Select all#include <Arduino.h>

#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>

#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>

#define USE_SERIAL Serial

ESP8266WiFiMulti WiFiMulti;
//===================================
//=              SETUP              =
//===================================
void setup() {

  USE_SERIAL.begin(9600);
  // USE_SERIAL.setDebugOutput(true);

  USE_SERIAL.println();
  USE_SERIAL.println();
  USE_SERIAL.println();

  for (uint8_t t = 4; t > 0; t--) {
    USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
    USE_SERIAL.flush();
    delay(1000);
  }
  // WiFi network info.
  WiFiMulti.addAP("?????????", "????????");

} // FIN de setup
//===================================
//=              LOOP               =
//===================================
void loop() {
  // wait for WiFi connection
  if ((WiFiMulti.run() == WL_CONNECTED)) {

    t_httpUpdate_return  ret = ESPhttpUpdate.update("https://????????.000webhost.com/updater.ino.bin"); //("https://server/file.bin");

    switch (ret) {
      case HTTP_UPDATE_FAILED:
        USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
        break;

      case HTTP_UPDATE_NO_UPDATES:
        USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
        break;

      case HTTP_UPDATE_OK:
        USE_SERIAL.println("HTTP_UPDATE_OK");
        break;
    }
  }
} //FIN de loop


PeteKnight wrote: pick-up the file and rename it to updater.ino.bin

i did it : after compile in BIN, and rename , i put "updater.ino.bin" in my "/public_html" with fillezilla.

this is what it diplay on Serial monitor :
Code: Select all[SETUP] WAIT 4...
[SETUP] WAIT 3...
[SETUP] WAIT 2...
[SETUP] WAIT 1...
HTTP_UPDATE_FAILD Error (-1): HTTP error: connection refused


did you find something wrong ? Thanks
User avatar
By martinayotte
#70924 HTTPS vs HTTP !!!
You need either to allow plain HTTP in your Web Hosting instead of HTTPS, or doing some change to ESP8266HTTPClient/ESP8266httpUpdate classes to allow HTTPS connections. The former is probably the easiest way ...