Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h> //https://www.youtube.com/watch?v=wG1I7JeEXE8&t=71s
- /*
- To upload through terminal you can use: curl -u admin:admin -F "image=@firmware.bin" esp8266-webupdate.local/firmware
- */
- #include <ESP8266WiFi.h>
- #include <WiFiClient.h>
- #include <ESP8266WebServer.h>
- #include <ESP8266mDNS.h>
- #include <ESP8266HTTPUpdateServer.h>
- const char* host = "esp8266-sanusb";
- const char* update_path = "/update";
- const char* update_username = "sanusb";
- const char* update_password = "sanusb";
- const char* ssid = "RFID";
- const char* password = "l43s3rf1d";
- //IPAddress mystaticip(192, 168, 1, 195); //Configuração de IP estático
- //IPAddress mygateway(192, 168, 1, 1);
- //IPAddress mysubnet(255, 255, 255, 0);
- ESP8266WebServer httpServer(80);
- ESP8266HTTPUpdateServer httpUpdater;
- void setup(void){
- Serial.begin(115200);
- Serial.println();
- Serial.println("Booting Sketch...");
- WiFi.mode(WIFI_AP_STA);
- WiFi.begin(ssid, password);
- while(WiFi.waitForConnectResult() != WL_CONNECTED){
- delay(500);
- Serial.print(".");
- }
- delay(5000);
- MDNS.begin(host);
- httpUpdater.setup(&httpServer, update_path, update_username, update_password);
- httpServer.begin();
- MDNS.addService("http", "tcp", 80);
- Serial.print("Atualizacao remota (OTA) iniciada com sucesso! Abra http://");
- Serial.print(WiFi.localIP());
- Serial.println("/update no browser");
- //Serial.printf("HTTPUpdateServer ready! Open http://%s.local%s in your browser and login with username '%s' and password '%s'\n", host, update_path, update_username, update_password);
- }
- void loop(void){
- httpServer.handleClient();
- digitalWrite(13, 0); digitalWrite(12, 1);// turn the LED on
- delay(1500); // wait
- digitalWrite(13, 1); digitalWrite(12, 0);// turn the LED off
- delay(1500);
- Serial.printf("SanUSBHERICSON\r\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement