Skip to content

Commit 3ef89d6

Browse files
committed
add: ci for Arduino Nano ESP32
1 parent 8c0e7a5 commit 3ef89d6

File tree

8 files changed

+52
-60
lines changed

8 files changed

+52
-60
lines changed

.github/workflows/compile-examples.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ jobs:
3232
- name: WiFiNINA
3333
- name: INA2xx
3434
- name: Arduino_BMI270_BMM150
35-
- name: BSEC Software Library
35+
- name: bsec2
3636
- name: Arduino_GroveI2C_Ultrasonic
3737
- name: OneWireNg
38+
- name: Arduino_APDS9999
39+
3840
3941
strategy:
4042
fail-fast: false
@@ -45,6 +47,10 @@ jobs:
4547
platforms: |
4648
- name: arduino:mbed_nano
4749
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
50+
- fqbn: arduino:esp32:nano_nora
51+
platforms: |
52+
- name: arduino:esp32
53+
artifact-name-suffix: arduino-nano-esp32
4854

4955
steps:
5056
- name: Checkout repository

.vscode/settings.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/ScienceJournal/ScienceJournal.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ScienceKitCarrier science_kit;
2828
rtos::Thread thread_update_sensors;
2929
#endif
3030

31-
#ifdef ESP32
31+
#ifdef ARDUINO_NANO_ESP32
3232
TaskHandle_t update_base;
3333
TaskHandle_t update_ble;
3434
#endif
@@ -52,7 +52,7 @@ void setup(){
5252
#ifdef ARDUINO_NANO_RP2040_CONNECT
5353
name = "ScienceKit R3 - ";
5454
#endif
55-
#ifdef ESP32
55+
#ifdef ARDUINO_NANO_ESP32
5656
name = "ScienceKit - ";
5757
#endif
5858
name += address[address.length() - 5];
@@ -126,7 +126,7 @@ void setup(){
126126
#ifdef ARDUINO_NANO_RP2040_CONNECT
127127
thread_update_sensors.start(update); // this thread updates sensors
128128
#endif
129-
#ifdef ESP32
129+
#ifdef ARDUINO_NANO_ESP32
130130
xTaskCreatePinnedToCore(&freeRTOSUpdate, "update_base", 10000, NULL, 1, &update_base, 1); // starts the update sensors thread on core 1 (user)
131131
xTaskCreatePinnedToCore(&freeRTOSble, "update_ble", 10000, NULL, 1, &update_ble, 0); // starts the ble thread on core 0 (internal)
132132
#endif
@@ -140,7 +140,7 @@ void update(void){
140140
}
141141
}
142142

143-
#ifdef ESP32
143+
#ifdef ARDUINO_NANO_ESP32
144144
static void freeRTOSUpdate(void * pvParameters){
145145
update();
146146
}
@@ -157,15 +157,15 @@ void updateBle(){
157157
BLEDevice central = BLE.central();
158158
if (central) {
159159
ble_is_connected = true;
160-
#ifdef ESP32
160+
#ifdef ARDUINO_NANO_ESP32
161161
science_kit.setStatusLed(STATUS_LED_BLE);
162162
#endif
163163
lastNotify=millis();
164164
while (central.connected()) {
165165
if (millis()-lastNotify>10){
166166
updateSubscribedCharacteristics();
167167
lastNotify=millis();
168-
#ifdef ESP32
168+
#ifdef ARDUINO_NANO_ESP32
169169
delay(1);
170170
#endif
171171
}
@@ -174,7 +174,7 @@ void updateBle(){
174174
else {
175175
delay(100);
176176
ble_is_connected = false;
177-
#ifdef ESP32
177+
#ifdef ARDUINO_NANO_ESP32
178178
science_kit.setStatusLed(STATUS_LED_PAIRING);
179179
#endif
180180
}

examples/ScienceJournal/ble_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const int VERSION = 0x00000002;
5656
#ifdef ARDUINO_NANO_RP2040_CONNECT
5757
#define SCIENCE_KIT_UUID(val) ("555a0003-" val "-467a-9538-01f0652c74e8")
5858
#endif
59-
#ifdef ESP32
59+
#ifdef ARDUINO_NANO_ESP32
6060
#define SCIENCE_KIT_UUID(val) ("555a0004-" val "-467a-9538-01f0652c74e8")
6161
#endif
6262

examples/SerialDebug/SerialDebug.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void loop() {
9595
Serial.print(science_kit.getTravelTime());
9696
Serial.print("\t|| ");
9797

98-
// Microphone is only availble on Arduino Nano RP2040 Connect edition
98+
// Microphone is only available on Arduino Nano RP2040 Connect edition
9999
#ifdef ARDUINO_NANO_RP2040_CONNECT
100100
Serial.print(science_kit.getMicrophoneRMS());
101101
Serial.print("\t|| ");

src/Arduino_ScienceKitCarrier.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ScienceKitCarrier::ScienceKitCarrier(){
9898
thread_ultrasonic = new rtos::Thread();
9999
#endif
100100

101-
#ifdef ESP32
101+
#ifdef ARDUINO_NANO_ESP32
102102
wire_semaphore = xSemaphoreCreateMutex();
103103
#endif
104104

@@ -124,7 +124,7 @@ ScienceKitCarrier::ScienceKitCarrier(){
124124

125125
int ScienceKitCarrier::begin(const uint8_t auxiliary_threads){
126126

127-
#ifdef ESP32
127+
#ifdef ARDUINO_NANO_ESP32
128128
pinMode(LED_RED,OUTPUT);
129129
pinMode(LED_GREEN,OUTPUT);
130130
pinMode(LED_BLUE,OUTPUT);
@@ -249,7 +249,7 @@ void ScienceKitCarrier::updateAnalogInput(const uint8_t input_to_update){
249249

250250
if (!getExternalTemperatureIsConnected()){
251251
inputA=analogRead(inputA_pin)>>board_resolution;
252-
#ifdef ESP32
252+
#ifdef ARDUINO_NANO_ESP32
253253
beginExternalTemperature();
254254
#endif
255255
}
@@ -291,12 +291,12 @@ int ScienceKitCarrier::beginAPDS(){
291291
else{
292292
apds9999->enableColorSensor();
293293
apds9999->enableProximitySensor();
294-
apds9999->setGain(APDS9999_GAIN_3X);
294+
apds9999->setGain(APDS9999_GAIN_18X);
295295
apds9999->setLSResolution(APDS9999_LS_RES_16B);
296296
apds9999->setLSRate(APDS9999_LS_RATE_25MS);
297297
color_sensor_used = APDS9999_VERSION;
298298
}
299-
#ifdef ESP32
299+
#ifdef ARDUINO_NANO_ESP32
300300
for(int i=0; i<=color_sensor_used; i++){
301301
digitalWrite(LED_GREEN, LOW);
302302
delay(100);
@@ -319,10 +319,10 @@ void ScienceKitCarrier::updateAPDS(){
319319
}
320320
}
321321
if (color_sensor_used==APDS9999_VERSION){
322-
r = apds9999->getRed()*4097/65535.0;
323-
g = apds9999->getGreen()*4097/262144.0;
324-
b = apds9999->getBlue()*4097/131072.0;
325-
c = apds9999->getIR()*4097/4096.0;
322+
r = apds9999->getRed()*5.0*4097/65535.0;
323+
g = apds9999->getGreen()*5.0*4097/262144.0;
324+
b = apds9999->getBlue()*5.0*4097/131072.0;
325+
c = apds9999->getIR()*5.0*4097/4096.0;
326326
proximity = 255 - apds9999->getProximity();
327327
if (proximity>255){
328328
proximity = 0;
@@ -436,7 +436,7 @@ float ScienceKitCarrier::getResistanceMeasureVolts(){
436436
#ifdef ARDUINO_NANO_RP2040_CONNECT
437437
value = REF_VOLTAGE*analogRead(resistance_pin)/ADC_RESOLUTION;
438438
#endif
439-
#ifdef ESP32
439+
#ifdef ARDUINO_NANO_ESP32
440440
value = analogReadMilliVolts(resistance_pin)/1000.0;
441441
#endif
442442
return value;
@@ -519,7 +519,7 @@ void ScienceKitCarrier::threadBME688(){
519519
}
520520
}
521521

522-
#ifdef ESP32
522+
#ifdef ARDUINO_NANO_ESP32
523523
void ScienceKitCarrier::freeRTOSInternalTemperature(void * pvParameters){
524524
((ScienceKitCarrier*) pvParameters)->threadBME688();
525525
}
@@ -650,7 +650,7 @@ void ScienceKitCarrier::errorTrap(const int error_code){
650650
}
651651
}
652652

653-
#ifdef ESP32
653+
#ifdef ARDUINO_NANO_ESP32
654654
void ScienceKitCarrier::setStatusLed(const int led_state){
655655
switch (led_state){
656656
case STATUS_LED_OFF:
@@ -768,7 +768,7 @@ void ScienceKitCarrier::updateUltrasonic(){
768768
if (ultrasonic_data==4294967295){
769769
ultrasonic_measure = -1.0;
770770
ultrasonic_is_connected = false;
771-
#ifdef ESP32
771+
#ifdef ARDUINO_NANO_ESP32
772772
setStatusLed(STATUS_LED_RM_ULTRASONIC);
773773
#endif
774774
}
@@ -778,7 +778,7 @@ void ScienceKitCarrier::updateUltrasonic(){
778778
ultrasonic_measure = 4500.0;
779779
}
780780
ultrasonic_is_connected = true;
781-
#ifdef ESP32
781+
#ifdef ARDUINO_NANO_ESP32
782782
setStatusLed(STATUS_LED_ADD_ULTRASONIC);
783783
#endif
784784
}
@@ -831,7 +831,7 @@ void ScienceKitCarrier::threadUltrasonic(){
831831
}
832832
}
833833

834-
#ifdef ESP32
834+
#ifdef ARDUINO_NANO_ESP32
835835
void ScienceKitCarrier::freeRTOSUltrasonic(void * pvParameters){
836836
((ScienceKitCarrier*) pvParameters)->threadUltrasonic();
837837
}
@@ -857,7 +857,7 @@ void ScienceKitCarrier::updateExternalTemperature(){
857857
#ifdef ARDUINO_NANO_RP2040_CONNECT
858858
pinMode(OW_PIN,INPUT);
859859
#endif
860-
#ifdef ESP32
860+
#ifdef ARDUINO_NANO_ESP32
861861
pinMode(INPUTA_PIN,INPUT);
862862
#endif
863863

@@ -870,14 +870,14 @@ void ScienceKitCarrier::updateExternalTemperature(){
870870
if (ec == OneWireNg::EC_SUCCESS) {
871871
if (scrpd->getAddr()!=15){
872872
external_temperature_is_connected=false;
873-
#ifdef ESP32
873+
#ifdef ARDUINO_NANO_ESP32
874874
setStatusLed(STATUS_LED_RM_EXT_TEMP);
875875
#endif
876876
external_temperature = EXTERNAL_TEMPERATURE_DISABLED;
877877
}
878878
else{
879879
external_temperature_is_connected=true;
880-
#ifdef ESP32
880+
#ifdef ARDUINO_NANO_ESP32
881881
setStatusLed(STATUS_LED_ADD_EXT_TEMP);
882882
#endif
883883
long temp = scrpd->getTemp();
@@ -910,7 +910,7 @@ void ScienceKitCarrier::threadExternalTemperature(){
910910
}
911911
}
912912

913-
#ifdef ESP32
913+
#ifdef ARDUINO_NANO_ESP32
914914
void ScienceKitCarrier::freeRTOSExternalTemperature(void * pvParameters){
915915
((ScienceKitCarrier*) pvParameters)->threadExternalTemperature();
916916
}
@@ -973,7 +973,7 @@ void ScienceKitCarrier::startAuxiliaryThreads(const uint8_t auxiliary_threads){
973973
#ifdef ARDUINO_NANO_RP2040_CONNECT
974974
thread_update_bme->start(mbed::callback(this, &ScienceKitCarrier::threadBME688));
975975
#endif
976-
#ifdef ESP32
976+
#ifdef ARDUINO_NANO_ESP32
977977
xTaskCreatePinnedToCore(this->freeRTOSInternalTemperature, "update_internal_temperature", 10000, this, 1, &thread_internal_temperature, INTERNAL_TEMPERATURE_CORE);
978978
#endif
979979
}
@@ -986,7 +986,7 @@ void ScienceKitCarrier::startAuxiliaryThreads(const uint8_t auxiliary_threads){
986986
#ifdef ARDUINO_NANO_RP2040_CONNECT
987987
thread_external_temperature->start(mbed::callback(this, &ScienceKitCarrier::threadExternalTemperature));
988988
#endif
989-
#ifdef ESP32
989+
#ifdef ARDUINO_NANO_ESP32
990990
xTaskCreatePinnedToCore(this->freeRTOSExternalTemperature, "update_external_temperature", 10000, this, 1, &thread_external_temperature, EXTERNAL_TEMPERATURE_CORE);
991991
#endif
992992
}
@@ -999,15 +999,15 @@ void ScienceKitCarrier::startAuxiliaryThreads(const uint8_t auxiliary_threads){
999999
#ifdef ARDUINO_NANO_RP2040_CONNECT
10001000
thread_ultrasonic->start(mbed::callback(this, &ScienceKitCarrier::threadUltrasonic));
10011001
#endif
1002-
#ifdef ESP32
1002+
#ifdef ARDUINO_NANO_ESP32
10031003
xTaskCreatePinnedToCore(this->freeRTOSUltrasonic, "update_ultrasonic", 10000, this, 1, &thread_ultrasonic, ULTRASONIC_CORE);
10041004
#endif
10051005
}
10061006
thread_ultrasonic_is_running = true;
10071007
}
10081008

10091009
// start status led
1010-
#ifdef ESP32
1010+
#ifdef ARDUINO_NANO_ESP32
10111011
if ((auxiliary_threads==START_AUXILIARY_THREADS)||(auxiliary_threads==START_STATUS_LED)){
10121012
if (!thread_led_is_running){
10131013
xTaskCreatePinnedToCore(this->freeRTOSStatusLed, "update_led", 10000, this, 1, &thread_led, LED_CORE);

src/Arduino_ScienceKitCarrier.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include <Arduino.h>
2424

25-
#if !defined(ARDUINO_NANO_RP2040_CONNECT) && !defined(ESP32)
25+
#if !defined(ARDUINO_NANO_RP2040_CONNECT) && !defined(ARDUINO_NANO_ESP32)
2626
#error "This product is compatible only with Arduino® Nano RP2040 Connect and Arduino® Nano ESP32
2727
#endif
2828

@@ -46,7 +46,7 @@
4646
#include "../../OneWireNg/src/platform/OneWireNg_PicoRP2040.h" // forces to use gpio instead PIO hw
4747
#define OneWireNg_CurrentPlatform OneWireNg_PicoRP2040
4848
#endif
49-
#ifdef ESP32
49+
#ifdef ARDUINO_NANO_ESP32
5050
#include "OneWireNg_CurrentPlatform.h"
5151
#endif
5252
#include "drivers/DSTherm.h"
@@ -64,7 +64,7 @@ static Placeholder<OneWireNg_CurrentPlatform> ow;
6464
#define wire_unlock wire_mutex.unlock()
6565
#endif
6666

67-
#ifdef ESP32
67+
#ifdef ARDUINO_NANO_ESP32
6868
#define wire_lock while(!xSemaphoreTake(wire_semaphore, 5)){}
6969
#define wire_unlock xSemaphoreGive(wire_semaphore)
7070
#endif
@@ -122,7 +122,7 @@ class ScienceKitCarrier{
122122
rtos::Mutex wire_mutex;
123123
#endif
124124

125-
#ifdef ESP32
125+
#ifdef ARDUINO_NANO_ESP32
126126
TaskHandle_t thread_internal_temperature;
127127
TaskHandle_t thread_external_temperature;
128128
TaskHandle_t thread_ultrasonic;
@@ -155,7 +155,7 @@ class ScienceKitCarrier{
155155
void errorTrap(const int error_code=0);
156156

157157
/* Status led */
158-
#ifdef ESP32
158+
#ifdef ARDUINO_NANO_ESP32
159159
void setStatusLed(const int led_state=STATUS_LED_OFF);
160160
void threadStatusLed();
161161
static void freeRTOSStatusLed(void * pvParameters);
@@ -206,7 +206,7 @@ class ScienceKitCarrier{
206206
float getHumidity(); // Percentage
207207
float getAirQuality(); // index, if good it is 25.0
208208
void threadBME688(); // thread used to update BME688 automatically in multithread mode
209-
#ifdef ESP32
209+
#ifdef ARDUINO_NANO_ESP32
210210
static void freeRTOSInternalTemperature(void * pvParameters);
211211
#endif
212212

@@ -250,7 +250,7 @@ class ScienceKitCarrier{
250250
float getTravelTime(); // microseconds
251251
bool getUltrasonicIsConnected();
252252
void threadUltrasonic();
253-
#ifdef ESP32
253+
#ifdef ARDUINO_NANO_ESP32
254254
static void freeRTOSUltrasonic(void * pvParameters);
255255
#endif
256256

@@ -262,7 +262,7 @@ class ScienceKitCarrier{
262262
float getExternalTemperature(); // celsius
263263
bool getExternalTemperatureIsConnected();
264264
void threadExternalTemperature();
265-
#ifdef ESP32
265+
#ifdef ARDUINO_NANO_ESP32
266266
static void freeRTOSExternalTemperature(void * pvParameters);
267267
#endif
268268

0 commit comments

Comments
 (0)