jeroenvermeulen / JeVe_EasyOTA

Making ESP8266 OTA Updates easy to include in your project
GNU General Public License v3.0
24 stars 11 forks source link

JeVe_EasyOTA library for Arduino

Purpose

Library which makes it easy to add support for Over-The-Air (OTA) updates to your project. Works with ESP8266 and ESP32.

Features

How it works

This library tries to connect to configured APs first. Then if those fail ,tries to scan for open networks and connect to those. If it is not possible to connect to neither configured nor open networks - it falls back to AP mode.

Installation

Install as ZIP

Install using Git (OSX / Linux)

Usage

The included examples are the easiest way to learn how to use this library.
You will find them in the Arduino IDE under menu _File > Examples > Examples from Custom Libraries (bottom) > JeVeEasyOTA.

WARNING: Make sure you select the right board in the Arduino IDE because there is less checking when you upload using OTA.

After you put the code in your Arduino, after a few minutes you should see the OTA port in the Arduino IDE under the menu Tools > Port.

If somehow the wifi connection fails, the Arduino will become an access point with the configured hostname as SSID. In the examples the default hostname is ota-flash-demo.

Arduino IDE Menu > Port

To include it in your own project:

Put on top of your Arduino file:

#include <JeVe_EasyOTA.h>
EasyOTA OTA("arduino_hostname");

Put this in your setup() function. This example logs debugging output to Serial:

Serial.begin(9600);
// This callback will be called when EasyOTA has anything to tell you.
OTA.onMessage([](const String& message, int line) {
  Serial.println(message);
});
// Add networks you wish to connect to
OTA.addAP("wifi_ssid", "wifi_password");
// Allow open networks.
// NOTE: gives priority to configured networks
OTA.allowOpen(true);
// Set password for OTA programming
OTA.setPassword("OTApassword");

Put this in you loop function:

OTA.loop();

Or if you need timing:

static unsigned long last_m = millis();
unsigned long now = millis();
OTA.loop(now);

if (now - last_m > 1000) {
    last_m = now;
    // do something every second
}

That's all folks.

Problem Solving

Network port is not showing in IDE

Test Results

Works with:

ESP8266

Wemos® TTGO ESP8266 0.91 Inch OLED For Arduino Nodemcu

Geekcreit® NodeMcu Lua ESP8266 ESP-12E WIFI Development Board

Geekcreit® LoLin V3 NodeMcu Lua WIFI Development Board

Upgraded Version 1M Flash ESP8266 ESP-01 WIFI Transceiver Wireless Module

WeMos® D1 mini V2.2.0 WIFI Internet Development Board Based ESP8266 4MB FLASH ESP-12S Chip

ESP32

Geekcreit® ESP32 Development Board WiFi+Bluetooth Ultra Low Power Consumption Dual Cores ESP-32 ESP-32S Board

WeMos® TTGO ESP32 WiFi + Bluetooth Board 4MB Flash UNO D1 R32

with Geekcreit® IIC / I2C 1602 Blue Backlight LCD Display Module For Arduino