Skip to content

Commit 4962dbf

Browse files
authored
Merge pull request #12 from arduino-libraries/nano_esp32
Arduino NANO ESP32 support
2 parents a75fa26 + abe1e64 commit 4962dbf

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

.github/workflows/compile-examples.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ jobs:
3737
board:
3838
- fqbn: "esp32:esp32:esp32"
3939
type: esp32
40+
- fqbn: "arduino:esp32:nano_nora"
41+
type: arduino_esp32
4042

4143
include:
4244
- board:
@@ -46,6 +48,18 @@ jobs:
4648
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
4749
libraries: |
4850
- name: Arduino_DebugUtils
51+
sketch-paths: |
52+
- examples/OTA
53+
- examples/LOLIN_32_Blink
54+
- board:
55+
type: arduino_esp32
56+
platforms: |
57+
- name: arduino:esp32
58+
libraries: |
59+
- name: Arduino_DebugUtils
60+
sketch-paths: |
61+
- examples/OTA
62+
- examples/NANO_ESP32_Blink
4963
5064
steps:
5165
- name: Checkout
@@ -66,7 +80,7 @@ jobs:
6680
- source-path: ./
6781
${{ matrix.libraries }}
6882
sketch-paths: |
69-
- examples
83+
${{ matrix.sketch-paths }}
7084
enable-deltas-report: true
7185
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
7286

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Blink for Arduino NANO ESP32 board
3+
*
4+
* This sketch can be used to generate an example binary that can be uploaded to ESP32 via OTA.
5+
* It needs to be used together with OTA.ino
6+
*
7+
* Steps to test OTA:
8+
* 1) Upload this sketch or any other sketch (this one this one lights up the RGB LED with different colours).
9+
* 2) In the IDE select: Sketch -> Export compiled Binary
10+
* 3) Upload the exported binary to a server
11+
* 4) Open the related OTA.ino sketch and eventually update the OTA_FILE_LOCATION
12+
* 5) Upload the sketch OTA.ino to perform OTA
13+
*/
14+
15+
void setLed(int blue, int gree, int red) {
16+
if (blue == 1) {
17+
digitalWrite(LED_BLUE, LOW);
18+
}
19+
else {
20+
digitalWrite(LED_BLUE, HIGH);
21+
}
22+
23+
if (gree == 1) {
24+
digitalWrite(LED_GREEN, LOW);
25+
}
26+
else {
27+
digitalWrite(LED_GREEN, HIGH);
28+
}
29+
30+
if (red == 1) {
31+
digitalWrite(LED_RED, LOW);
32+
}
33+
else {
34+
digitalWrite(LED_RED, HIGH);
35+
}
36+
}
37+
38+
39+
void setup()
40+
{
41+
pinMode(LED_BLUE, OUTPUT);
42+
pinMode(LED_GREEN, OUTPUT);
43+
pinMode(LED_RED, OUTPUT);
44+
}
45+
46+
void loop()
47+
{ // Blue LED on
48+
setLed(1, 0, 0);
49+
delay(1000);
50+
// Green LED on
51+
setLed(0, 1, 0);
52+
delay(1000);
53+
// Red LED on
54+
setLed(0, 0, 1);
55+
delay(1000);
56+
}

examples/OTA/OTA.ino

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@
3636
static char const SSID[] = SECRET_SSID; /* your network SSID (name) */
3737
static char const PASS[] = SECRET_PASS; /* your network password (use for WPA, or use as key for WEP) */
3838

39+
40+
#if defined(ARDUINO_NANO_ESP32)
41+
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/NANO_ESP32_Blink.ino.ota";
42+
#else
3943
static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/LOLIN_32_Blink.ino.ota";
44+
#endif
4045

4146
/******************************************************************************
4247
* SETUP/LOOP
@@ -95,7 +100,11 @@ void setup()
95100
}
96101

97102
Serial.println("Performing a reset after which the bootloader will start the new firmware.");
103+
#if defined(ARDUINO_NANO_ESP32)
104+
Serial.println("Hint: Arduino NANO ESP32 will blink Red Green and Blue.");
105+
#else
98106
Serial.println("Hint: LOLIN32 will blink Blue.");
107+
#endif
99108
delay(1000); /* Make sure the serial message gets out before the reset. */
100109
ota.reset();
101110
}

src/Arduino_ESP32_OTA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ int Arduino_ESP32_OTA::download(const char * ota_url)
189189
return static_cast<int>(Error::OtaHeaderLength);
190190
}
191191

192-
if (_ota_header.header.magic_number != 0x45535033)
192+
if (_ota_header.header.magic_number != ARDUINO_ESP32_OTA_MAGIC)
193193
{
194194
return static_cast<int>(Error::OtaHeaterMagicNumber);
195195
}

src/Arduino_ESP32_OTA.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
#include <WiFiClientSecure.h>
2727
#include "decompress/utility.h"
2828

29+
/******************************************************************************
30+
DEFINES
31+
******************************************************************************/
32+
#if defined (ARDUINO_NANO_ESP32)
33+
#define ARDUINO_ESP32_OTA_MAGIC 0x23410070
34+
#else
35+
#define ARDUINO_ESP32_OTA_MAGIC 0x45535033
36+
#endif
2937
/******************************************************************************
3038
CONSTANTS
3139
******************************************************************************/

0 commit comments

Comments
 (0)