Skip to content

Arduino NANO ESP32 support #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
board:
- fqbn: "esp32:esp32:esp32"
type: esp32
- fqbn: "arduino:esp32:nano_nora"
type: arduino_esp32

include:
- board:
Expand All @@ -46,6 +48,18 @@ jobs:
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
libraries: |
- name: Arduino_DebugUtils
sketch-paths: |
- examples/OTA
- examples/LOLIN_32_Blink
- board:
type: arduino_esp32
platforms: |
- name: arduino:esp32
libraries: |
- name: Arduino_DebugUtils
sketch-paths: |
- examples/OTA
- examples/NANO_ESP32_Blink

steps:
- name: Checkout
Expand All @@ -66,7 +80,7 @@ jobs:
- source-path: ./
${{ matrix.libraries }}
sketch-paths: |
- examples
${{ matrix.sketch-paths }}
enable-deltas-report: true
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}

Expand Down
56 changes: 56 additions & 0 deletions examples/NANO_ESP32_Blink/NANO_ESP32_Blink.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Blink for Arduino NANO ESP32 board
*
* This sketch can be used to generate an example binary that can be uploaded to ESP32 via OTA.
* It needs to be used together with OTA.ino
*
* Steps to test OTA:
* 1) Upload this sketch or any other sketch (this one this one lights up the RGB LED with different colours).
* 2) In the IDE select: Sketch -> Export compiled Binary
* 3) Upload the exported binary to a server
* 4) Open the related OTA.ino sketch and eventually update the OTA_FILE_LOCATION
* 5) Upload the sketch OTA.ino to perform OTA
*/

void setLed(int blue, int gree, int red) {
if (blue == 1) {
digitalWrite(LED_BLUE, LOW);
}
else {
digitalWrite(LED_BLUE, HIGH);
}

if (gree == 1) {
digitalWrite(LED_GREEN, LOW);
}
else {
digitalWrite(LED_GREEN, HIGH);
}

if (red == 1) {
digitalWrite(LED_RED, LOW);
}
else {
digitalWrite(LED_RED, HIGH);
}
}


void setup()
{
pinMode(LED_BLUE, OUTPUT);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
}

void loop()
{ // Blue LED on
setLed(1, 0, 0);
delay(1000);
// Green LED on
setLed(0, 1, 0);
delay(1000);
// Red LED on
setLed(0, 0, 1);
delay(1000);
}
9 changes: 9 additions & 0 deletions examples/OTA/OTA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
static char const SSID[] = SECRET_SSID; /* your network SSID (name) */
static char const PASS[] = SECRET_PASS; /* your network password (use for WPA, or use as key for WEP) */


#if defined(ARDUINO_NANO_ESP32)
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/NANO_ESP32_Blink.ino.ota";
#else
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/LOLIN_32_Blink.ino.ota";
#endif

/******************************************************************************
* SETUP/LOOP
Expand Down Expand Up @@ -95,7 +100,11 @@ void setup()
}

Serial.println("Performing a reset after which the bootloader will start the new firmware.");
#if defined(ARDUINO_NANO_ESP32)
Serial.println("Hint: Arduino NANO ESP32 will blink Red Green and Blue.");
#else
Serial.println("Hint: LOLIN32 will blink Blue.");
#endif
delay(1000); /* Make sure the serial message gets out before the reset. */
ota.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Arduino_ESP32_OTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
return static_cast<int>(Error::OtaHeaderLength);
}

if (_ota_header.header.magic_number != 0x45535033)
if (_ota_header.header.magic_number != ARDUINO_ESP32_OTA_MAGIC)
{
return static_cast<int>(Error::OtaHeaterMagicNumber);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Arduino_ESP32_OTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
#include <WiFiClientSecure.h>
#include "decompress/utility.h"

/******************************************************************************
DEFINES
******************************************************************************/
#if defined (ARDUINO_NANO_ESP32)
#define ARDUINO_ESP32_OTA_MAGIC 0x23410070
#else
#define ARDUINO_ESP32_OTA_MAGIC 0x45535033
#endif
/******************************************************************************
CONSTANTS
******************************************************************************/
Expand Down