ESP32-WROOM-32 - AZ-delivery dev kitC
Posted: Sun Oct 17, 2021 4:36 pm
Hi,
this is the first time I own such a board. I purchase 1 azdelivery esp32 devKitC esp32-WROOM-32.
I try to programm it with vscode.
To upload a program with the usb cable : is it normla, that I have to press the boot button while uploading ?
2) I try to upload OTA feature. I can upload with usb calbe, but, once it is done, ota doesn't work : it stopp at 8%. I don't know why.
Here is my code :
Here is platformIO.ino (I don't know if it's the right board !)
main.cpp
And the OTA.h file :
Thank you for your help.
this is the first time I own such a board. I purchase 1 azdelivery esp32 devKitC esp32-WROOM-32.
I try to programm it with vscode.
To upload a program with the usb cable : is it normla, that I have to press the boot button while uploading ?
2) I try to upload OTA feature. I can upload with usb calbe, but, once it is done, ota doesn't work : it stopp at 8%. I don't know why.
Here is my code :
Here is platformIO.ino (I don't know if it's the right board !)
- ; PlatformIO Project Configuration File
- ;
- ; Build options: build flags, source filter
- ; Upload options: custom upload port, speed and extra flags
- ; Library options: dependencies, extra library storages
- ; Advanced options: extra scripting
- ;
- ; Please visit documentation for the other options and examples
- ; https://docs.platformio.org/page/projectconf.html
- [env:az-delivery-devkit-v4]
- platform = espressif32
- ;board = az-delivery-devkit-v2
- board = esp32dev
- framework = arduino
- monitor_speed = 115200
- upload_protocol = esptool
- upload_port = 192.168.1.117
- ;lib_deps = https://github.com/tzapu/WiFiManager.git
main.cpp
- #include <OTA.h>
- //const char * ssid = "Routeur24";
- //const char* password = "Da41ma64";
- #define CONNECTION_TIMEOUT 10
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(115200);
- Serial.println("Booting");
- //***********************************
- //************* Connexion au WIFI
- //***********************************
- IPAddress ip(192, 168, 1, 117);
- IPAddress dns(192, 168, 1, 1);
- IPAddress gateway(192, 168, 1, 1);
- IPAddress subnet(255, 255, 255, 0);
- WiFi.config(ip, dns, gateway, subnet);
- WiFi.begin(mySSID,myPASSWORD);
- Serial.print("\nConnexion au WIFI");
- int timeout_counter = 0;
- while(WiFi.status() != WL_CONNECTED){
- Serial.print(".");
- delay(200);
- timeout_counter++;
- if(timeout_counter >= CONNECTION_TIMEOUT*5){
- ESP.restart();
- }
- }
- Serial.println("\nConnected to the WiFi network");
- Serial.print("Local ESP32 IP: ");
- Serial.println(WiFi.localIP());
- //***********************************
- //************* OTA Setup
- //***********************************
- setupOTA("TemplateSketch", mySSID, myPASSWORD);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- //#ifdef defined(ESP32_RTOS) && defined(ESP32)
- //#else // If you do not use FreeRTOS, you have to regulary call the handle method.
- ArduinoOTA.handle();
- //#endif
- Serial.println("Test");
- }
- #ifdef ESP32
- #include <WiFi.h>
- #include <ESPmDNS.h>
- #else
- #include <ESP8266WiFi.h>
- #include <ESP8266mDNS.h>
- #endif
- #include <WiFiUdp.h>
- #include <ArduinoOTA.h>
- #if defined(ESP32_RTOS) && defined(ESP32)
- void ota_handle( void * parameter ) {
- for (;;) {
- ArduinoOTA.handle();
- delay(3500);
- }
- }
- #endif
- void setupOTA(const char* nameprefix, const char* ssid, const char* password) {
- // Configure the hostname
- uint16_t maxlen = strlen(nameprefix) + 7;
- char *fullhostname = new char[maxlen];
- uint8_t mac[6];
- WiFi.macAddress(mac);
- snprintf(fullhostname, maxlen, "%s-%02x%02x%02x", nameprefix, mac[3], mac[4], mac[5]);
- ArduinoOTA.setHostname(fullhostname);
- delete[] fullhostname;
- // Configure and start the WiFi station
- WiFi.mode(WIFI_STA);
- WiFi.begin(ssid, password);
- // Wait for connection
- while (WiFi.waitForConnectResult() != WL_CONNECTED) {
- Serial.println("Connection Failed! Rebooting...");
- delay(5000);
- ESP.restart();
- }
- // Port defaults to 3232
- // ArduinoOTA.setPort(3232); // Use 8266 port if you are working in Sloeber IDE, it is fixed there and not adjustable
- // No authentication by default
- // ArduinoOTA.setPassword("admin");
- // Password can be set with it's md5 value as well
- // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
- // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
- ArduinoOTA.onStart([]() {
- //NOTE: make .detach() here for all functions called by Ticker.h library - not to interrupt transfer process in any way.
- 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);
- });
- ArduinoOTA.onEnd([]() {
- Serial.println("\nEnd");
- });
- ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
- Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
- });
- ArduinoOTA.onError([](ota_error_t error) {
- Serial.printf("Error[%u]: ", error);
- if (error == OTA_AUTH_ERROR) Serial.println("\nAuth Failed");
- else if (error == OTA_BEGIN_ERROR) Serial.println("\nBegin Failed");
- else if (error == OTA_CONNECT_ERROR) Serial.println("\nConnect Failed");
- else if (error == OTA_RECEIVE_ERROR) Serial.println("\nReceive Failed");
- else if (error == OTA_END_ERROR) Serial.println("\nEnd Failed");
- });
- ArduinoOTA.begin();
- Serial.println("OTA Initialized");
- Serial.print("IP address: ");
- Serial.println(WiFi.localIP());
- #if defined(ESP32_RTOS) && defined(ESP32)
- xTaskCreate(
- ota_handle, /* Task function. */
- "OTA_HANDLE", /* String with name of task. */
- 10000, /* Stack size in bytes. */
- NULL, /* Parameter passed as input of the task */
- 1, /* Priority of the task. */
- NULL); /* Task handle. */
- #endif
- }