-
-
Save aovestdipaperino/4beb68a56180375ca81c2c6b06704d86 to your computer and use it in GitHub Desktop.
ESP Piuma 1.3 stock firmware
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 <WiFi.h> | |
#include <ESPmDNS.h> | |
#include <WiFiUdp.h> | |
#include <ArduinoOTA.h> | |
const char* ssid = "ESP32-DEV-AP"; | |
const char* password = ""; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println("Booting"); | |
WiFi.mode(WIFI_AP); | |
WiFi.softAP(ssid, password); | |
ArduinoOTA | |
.onStart([]() { | |
String type; | |
if (ArduinoOTA.getCommand() == U_FLASH) | |
type = "sketch"; | |
else // U_SPIFFS | |
type = "filesystem"; | |
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end() | |
Serial.println("Start updating " + type); | |
}) | |
.onEnd([]() { | |
Serial.println("\nEnd"); | |
}) | |
.onProgress([](unsigned int progress, unsigned int total) { | |
Serial.printf("Progress: %u%%\r", (progress / (total / 100))); | |
}) | |
.onError([](ota_error_t error) { | |
Serial.printf("Error[%u]: ", error); | |
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed"); | |
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed"); | |
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed"); | |
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed"); | |
else if (error == OTA_END_ERROR) Serial.println("End Failed"); | |
}); | |
ArduinoOTA.begin(); | |
Serial.println("Ready"); | |
// PIN 2 is the green LED. | |
pinMode(2, OUTPUT); | |
// PIN 35 is the one connected to a voltage divider to measure battery voltage. | |
pinMode(35, INPUT); | |
} | |
void loop() { | |
ArduinoOTA.handle(); | |
Serial.printf("Battery pin %d\n", analogRead(35)); | |
digitalWrite(2, HIGH); | |
delay(2000); | |
digitalWrite(2, LOW); | |
delay(2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment