Created
June 11, 2015 15:24
-
-
Save igrr/43d5c52328e955bb6b09 to your computer and use it in GitHub Desktop.
ESP8266 Arduino OTA example v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ESP8266WiFi.h> | |
#include <WiFiUDP.h> | |
const char* ssid = ".........."; | |
const char* password = "..........."; | |
WiFiUDP listener; | |
void setup() { | |
Serial.begin(115200); | |
Serial.setDebugOutput(true); | |
Serial.println(""); | |
Serial.println("OTA test"); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(500); | |
Serial.print("."); | |
} | |
Serial.println(""); | |
Serial.print("Connected to "); | |
Serial.println(ssid); | |
Serial.print("IP address: "); | |
Serial.println(WiFi.localIP()); | |
listener.begin(8266); | |
Serial.print("Sketch size: "); | |
Serial.println(ESP.getSketchSize()); | |
Serial.print("Free size: "); | |
Serial.println(ESP.getFreeSketchSpace()); | |
} | |
void loop() { | |
int cb = listener.parsePacket(); | |
if (cb) { | |
IPAddress remote = listener.remoteIP(); | |
int cmd = listener.parseInt(); | |
int port = listener.parseInt(); | |
int sz = listener.parseInt(); | |
Serial.println("Got packet"); | |
Serial.printf("%d %d %d\r\n", cmd, port, sz); | |
WiFiClient cl; | |
if (!cl.connect(remote, port)) { | |
Serial.println("failed to connect"); | |
return; | |
} | |
listener.stop(); | |
if (!ESP.updateSketch(cl, sz)) { | |
Serial.println("Update failed"); | |
} | |
} | |
delay(100); | |
} |
Where do we need to setup ESP IP in arduino IDE?
Hi I have the same question as bkrajendra.. how to setup adress of esp in IDE.. So far I have modified espota.py directly.. but is annoying to rewrite it for each ESP module.. thx..
@bkrajendra : in arduino IDE -> Tools > port. Your esp should appear in this section under "network ports". But I doesn't upload for me
(sorry if bad englsih, I'm french)
To specify IP instead of serial port (in case it does not appear in the list):
File > Prefrences will show your preferences file
C:\Users\AppData\Roaming\Arduino\preferences.txt
Edit with IP of esp module, for example :
serial.port=192.168.0.50
Restart Arduino and check bottom-right corner to see your IP is displayed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Have you really figured out a way to remotely program your esp8266 using the Arduino IDE? If so, do you have more detailed information to go about this?