so impatient
Hi there! I don´t know if I can paste code direct here⌠if not, sorry community! Here´s the code:
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <CayenneMQTTESP8266.h>
`ESP8266WiFiMulti WiFiMulti;`
char mSSID[] = ""; // to set as required
char mPASS[] = ""; // to set as required
char username[] = ""; // to set as required
char mqtt_password[] = ""; // to set as required
char client_id[] = ""; // to set as required
//// WHERE TO FIND NEW SKETCH
String Cliente = "client_name";
String NewVersion = "0.0.4"; // NEW VERSION OF THE CODE â if the current version is, for example, 0.0.3 and in the remote server there´s a version 0.0.4, it will update
String url_server = "http://www.gpstech.com.br/codigos/"+Cliente; // FOLDER NAME â if use a folder with the client name
String url_sketch = url_server+"/"+Cliente+"_"+NewVersion+".bin"; // new URL â it's builds the URL to get the compiled code file (.bin) - I used a file with the client's name plus new version number
bool Continue = true;
int blink_led = 2;
void setup() {
Serial.begin(115200);
Cayenne.begin(username, mqtt_password, client_id, mSSID, mPASS);
}
//// UPDATING SKETCH ROUTINE
void OTA_Updates(){
Serial.println(Cliente);
Serial.println(NewVersion);
Serial.println(url_server);
Serial.println(url_sketch);
if((WiFiMulti.run() == WL_CONNECTED)) {
t_httpUpdate_return ret = ESPhttpUpdate.update(url_sketch);
switch(ret) {
case HTTP_UPDATE_FAILED:
Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n",
ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("HTTP_UPDATE_NO_UPDATES");
break;
case HTTP_UPDATE_OK:
Serial.println("HTTP_UPDATE_OK");
break;
}
Continue = false;
}
}
void loop() {
if (Continue){
Serial.println("Updating system, hold on");
OTA_Updates();
}
ApplicationCayenne();
}
void ApplicationCayenne() {
digitalWrite(2, HIGH);
delay(1000);
digitalWrite(2, LOW);
delay(1000);
}
you could use the â</>â button to paste your code
This code sounds good ! Thanks a lot !
i test your code and I notice my www.000webhost.com is https: instead of http: is it a problem ?
I don´t know⌠try it and let me know!
Thank you for this.
I will try your code as soon as friend gives me subdomain to test on his server.
You´re welcome⌠it´s a hard work⌠don´t forget EEPROM works âbyte per byteâ⌠it won´t be easy to split those credentialsâŚ
Let me know if you need help!
Hi, i must have more details if i not made errors .
This is my part of code :
//// WHERE TO FIND NEW SKETCH
String Cliente = "wemos_OTAserver"; //"client_name";
String NewVersion = "0.0.2"; // NEW VERSION OF THE CODE â if the current version is, for example, 0.0.3 and in the remote server there´s a version 0.0.4, it will update
String url_server = "https://myName.000webhostapp.com/ESP8266OTA"; //+ Cliente; // FOLDER NAME â if use a folder with the client name
String url_sketch = url_server + "/" + Cliente + "_" + NewVersion + ".bin"; // new URL â itâs builds the URL to get the compiled code file (.bin) - I used a file with the clientâs name plus new version number
bool Continue = true;
i put this in a folder named âESP8266OTAâ in my 000webhostapp ,with Filezilla:
i got this in serial monitor :
Updating system, hold on
wemos_OTAserver
0.0.1
https://myName.000webhostapp.com/ESP8266OTA
https://myName.000webhostapp.com/ESP8266OTA/wemos_OTAserver_0.0.1.bin
HTTP_UPDATE_FAILD Error ( -1): HTTP error: connection refused
Did you see something wrong ? ⌠or itâs https fault ? (myName is not the realy name )
Hello! First, you have to save the file in .bin format, not .ino format, as you can see here: String url_sketch = url_server + "/" + Cliente + "_" + NewVersion + ".bin";
Try again! Let me know!
âclient_nameâ : is the name of the sketch ? right ?
does i keep the .ino or just .bin like this : wemos_OTAserver_0.0.2.bin ?
An example would be appreciated
Hi guys!
Guilherme and I are working with OTA atualization on ESP8266.
Ninja, your question is very important. I will try explain it for you:
We were using Arduino 1.8.5 IDE and select the board âWeMos D1 R2 & miniâ (itâs works with other ESP boards too).
On the âSketchâ menu we select âExport compiled Binaryâ.
A â.binâ file is saved at sketch folder.
We rename this file with required name (Cliente+â_â+NewVersion+â.binâ) and put it on the web server.
Before the atualization the showed code by Guilherme prints on Serial Monitor:
a) name to file (without version and without .bin)
b) version
c) url of file folder
d) complete url to file (used to download of .bin file)
I hope Iâve helped.
You can to ask-me if you need help!
(Sorry the very poor english knowledge.)
@poetini your English is perfect
Thatâs what i do :
In the folder ESP8266OTA i create a Folder wemosOTAserver : this is âClienteâ and i put the wemosOTAserver_0.0.2.bin into (after âExport compiled Binaryâ and rename) .
I got this :
Updating system, hold on
wemosOTAserver
0.0.1
https://myName.000webhostapp.com/ESP8266OTA/wemosOTAserver
https://myName.000webhostapp.com/ESP8266OTA/wemosOTAserver/wemosOTAserver_0.0.2.bin
HTTP_UPDATE_FAILD Error ( -1): HTTP error: connection refused
Do you know where is the problem ? because https ?
I think that understood whatâs happen.
You are using
String url_server = "https://myName.000webhostapp.com/ESP8266OTA";
but the first part of the URL is your site name.
By exemple:
String url_server = "https://SuperNinja.000webhostapp.com/ESP8266OTA";
Can you do a test:
Put the name that you defined during the 000webhostapp register in the position of SuperNinja and check again.
Other test is put a .html file with/beside the .bin file (in the same folder) and access it by browser. Only to confirm the url that you are using.
Yes, Humberto. I think that´s the point:
String url_server = "https://SuperNinja.000webhostapp.com/ESP8266OTA";
Ninja, you must use the name of your âsiteâ⌠in our case is http://gpstech.com.br/OTA_something.
So, understand that our server name is http://gpstech.com.br. You have to do the same!
Regards,
âmyNameâ is a hidden name . This is the realy name :
Connection refused !
If you want i send you my login and password to test on my host , by private message ?
I think https host is the issue : i change for a http host and the error is different :
I progress âŚ
@Agroelektronik , did you test the OTA on server ?
We had large snow fall during the weekend and all the trouble that comes with it, so i did not had a chance to do any coding, will report in a few days.
Damn, no mather how exhausted i am i had to try
Had a NodeMCU board near me, and hooked it up fast used code from @guilherme and modified it to match my data.
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266httpUpdate.h>
#include <CayenneMQTTESP8266.h>
ESP8266WiFiMulti WiFiMulti;
char mSSID = âxxxâ; // to set as required
char mPASS = âxxxâ; // to set as required
char username = âxxxâ; // to set as required
char mqtt_password = âxxxâ; // to set as required
char client_id = âxxxâ; // to set as required
//// WHERE TO FIND NEW SKETCH
String Cliente = âtestâ;
String NewVersion = â0.2â; // NEW VERSION OF THE CODE â if the current version is, for example, 0.0.3 and in the remote server there´s a version 0.0.4, it will update
String url_server = âhttp://xxxxx.rs/â+Cliente; // FOLDER NAME â if use a folder with the client name
String url_sketch = url_server+â/â+Cliente+â_â+NewVersion+â.binâ; // new URL â itâs builds the URL to get the compiled code file (.bin) - I used a file with the clientâs name plus new version number
bool Continue = true;
int blink_led = 2;
void setup() {
Serial.begin(115200);
Cayenne.begin(username, mqtt_password, client_id, mSSID, mPASS);
}
//// UPDATING SKETCH ROUTINE
void OTA_Updates(){
Serial.println(Cliente);
Serial.println(NewVersion);
Serial.println(url_server);
Serial.println(url_sketch);
if((WiFiMulti.run() == WL_CONNECTED)) {
t_httpUpdate_return ret = ESPhttpUpdate.update(url_sketch);
switch(ret) {
case HTTP_UPDATE_FAILED:
Serial.printf(âHTTP_UPDATE_FAILD Error (%d): %s\nâ,
ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println(âHTTP_UPDATE_NO_UPDATESâ);
break;
case HTTP_UPDATE_OK:
Serial.println(âHTTP_UPDATE_OKâ);
break;
}
Continue = false;
}
}
void loop() {
if (Continue){
Serial.println(âUpdating system, hold onâ);
OTA_Updates();
}
ApplicationCayenne();
}
void ApplicationCayenne() {
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
}
After uploading the code i got this
My guess is that its the power supply thats causing the wdt reset, since its hooked only on usb port and no external power supply.
@SuperNinja Only difference my and your code is that i use subfolder in domain, and not subdomain like you.
I will post update tomorrow when i get to my work shop, this curent setup is on my dinning table
I will reply to my self to keep text short
First WDT reset is normal, since the code DID update and resets NodemMCU, but the fact that i did not notice any change is that i did not change any code so no change on dashboard
Important part is
String NewVersion = â0.0.1â
In this code goes number of future version
Explanation
Your original code is 0.0.0 (You dont write this anywhere)
In your basic code your String NewVersion = â0.0.1â is setup like this
Upload it to ESP via usb
Set device up for usage.
When time comes you make a change on the code and want to make it available to your boards
In your String NewVersion = â0.0.2â (for future updated version so ESP can know what to look next time)
Compile your .bin file and rename it to 0.0.1
Upload that new .bin file to your public server and restart esp board.
Board will update to 0.0.1 code version
Next time you restart board it will look for 0.0.2 version of code
And so it goes unlimited times, basicly your file name version needs to -1 to String NewVersion = ââ code number.
I successfully update my dashboard 3 times in a row so i can confirm that this method works without error.
Second screenshoot shows that file is not present because it has not been uploaded to server yet so when i make a change to sketch and upload 0.0.3 version on ESP reset it will find it update, and next time it resets it will look for 0.0.4
Tryed to exlain it best i can good luck and thanks to @guilherme
@Agroelektronik YHEAAAAAA !!! itâs ok for me !!!
You put me on the right way . I made the error of put the new number of version on server !
As you said , we must put the N-1 !!!
Itâs working for me , so happy i waiting for this for long time !!
Thanks to @guilherme & @poetini good work guys !
Itâs a detail , but how to make âFile not found(404)â desapear ?
On the code there is :
case HTTP_UPDATE_OK:
Serial.println("HTTP_UPDATE_OK");
break;
Why it didnât display this ?