looks like the
WIFI.config(thisip)
what works on PICO W / ESP32S3
not work for Arduino Nano ESP32
need like
WIFI.config(thisip, gateway, subnet, primaryDNS, secondaryDNS)
what happen to be the BUILD SWITCH for this board?
looks like the
WIFI.config(thisip)
what works on PICO W / ESP32S3
not work for Arduino Nano ESP32
need like
WIFI.config(thisip, gateway, subnet, primaryDNS, secondaryDNS)
what happen to be the BUILD SWITCH for this board?
the WiFi library in the esp32 Arduino platform version 3 has WIFI.config(thisip), but the Arduino fork of the esp32 platform is older
Hi @kllsamui.
I'm not sure I understand what you mean by this. Are you asking for a way to determine whether the sketch program is being compiled for the Nano ESP32? If so, you can use the ARDUINO_NANO_ESP32 macro. For example:
#if defined(ARDUINO_NANO_ESP32)
// Nano ESP32-specific code here
#endif
However, in this case where the relevant factor is the version of the core, not the board, you might like to instead use the version macros, and helper macro functions, that are defined by the "esp32" boards platform's core (and also by the core of the "Arduino ESP32 Boards" platform, which is a fork of the esp32 platform):
thanks, i will try that what you call
macro
#ifdef ARDUINO_NANO_ESP32
WiFi.config(thisip, gateway, subnet, primaryDNS, secondaryDNS); // test for Arduino NANO ESP32
#else
WiFi.config(thisip);
#endif
so where did you find that ?
ARDUINO_NANO_ESP32
i read at forum i should read boards.txt
c:\Users\user\AppData\Local\Arduino15\packages\arduino\hardware\esp32\2.0.18-arduino.5\boards.txt
but there is only
nano_nora.name=Arduino Nano ESP32
nano_nora.build.board=NANO_ESP32
the use of the other 2 things you linked i not get at the first look
but i will study if needed.
thanks again
got it
.build.board property is used to set a compile-time macro ARDUINO_{build.board}
for Arduino boards only i guess
i am aware of the
#ifdef ESP32
here i use to make combined code for PICO W and ESP32S3
the Arduino Nano ESP32 question came up when
a friend tried that code on a Arduino Nano ESP32 ( thinking it is same like ESP32S3 )
and failed at compile time
there should be something like
Serial.println($build.board); // the selected Arduino IDE / Tools / Board
and for all boards ..
what then could be used in code...
thanks
I'm not sure I understand what you mean by this. If you are guessing that a board identification macro is only defined for the boards manufactured by the Arduino company, then you are wrong. Every one of the board definitions of the "esp32" platform defines one of these macros, including all the 3rd party boards. To pick a random board as an example, the board definition for the 3rd party "Aventen S3 Sync" board defines the build.board property as:
aventen_s3_sync.build.board=AVENTEN_S3_SYNC
The compilation command patterns defined by the platform contain -DARDUINO_{build.board}:
{build.board} is a template placeholder which is expanded to the value of the build.board property when the compilation command is generated by Arduino IDE. So when you compile for the "Aventen S3 Sync" board, the compilation commands will contain the flag -DARDUINO_AVENTEN_S3_SYNC, and thus a global macro named ARDUINO_AVENTEN_S3_SYNC will be defined when a sketch is compiled for this board.
Or maybe you are instead saying that these macros will only be defined when using the Arduino framework? It is true that the macro definition is produced by the Arduino boards platform configuration files. So if you compiled the same program using an alternative development tool that does not use the Arduino boards platform framework, then it is true that the macros would not necessarily be defined. However, I would guess that a 3rd party tool that explicitly supports the Arduino framework (e.g., PlatformIO) would still implement some mechanism for defining these macros, even if it doesn't use the Arduino boards platform framework specifically.
But in the case of a tool that doesn't know or care anything about the Arduino framework (e.g., using GCC manually), then yes there won't be any mechanism for automatically defining these macros (though you could always manually configure the tool to define them).
It is not a common convention, but in addition to the board identification flag macros like ARDUINO_NANO_ESP32 and ARDUINO_AVENTEN_S3_SYNC, the "esp32" platform also defines a macro named ARDUINO_BOARD, which is set to the value of the build.board property. Note the -DARDUINO_BOARD="{build.board}" in the compilation command patterns:
So if you have this code in your sketch:
#ifdef ARDUINO_BOARD
Serial.println(ARDUINO_BOARD);
#endif
Then if the sketch is compiled for the "Aventen S3 Sync" board, the sketch will output "AVENTEN_S3_SYNC" to the serial port. Likewise, if the sketch is compiled for the Arduino Nano ESP32 board, the sketch will output "NANO_ESP32" to the serial port.
thanks again
confusing is that that works for ESP32S3
thinking it is a ARDUINO_BOARD
but not for PICO 2W, there can use #ifdef PICO_BOARD
while the
'ARDUINO_' + build.bord
works fine
here my test sketch
// BOARD type
void setup() {
Serial.begin(115200); // __________________________________________ talk to serial
while (!Serial && (millis() < 10000));
Serial.println("\nHELLO WORLD\ni am ");
#ifdef ARDUINO_BOARD
Serial.print("ARDUINO_BOARD: ");
Serial.println(ARDUINO_BOARD); //ESP32S3_DEV
#endif
#ifdef PICO_BOARD
Serial.print("PICO_BOARD: ");
Serial.println(PICO_BOARD); //solderparty_rp2350_stamp_xl
#endif
#ifdef ARDUINO_ESP32S3_DEV
Serial.println("ARDUINO_ESP32S3_DEV");
#endif
#ifdef ARDUINO_RASPBERRY_PI_PICO_W
Serial.println("ARDUINO_RASPBERRY_PI_PICO_W");
#endif
#ifdef ARDUINO_RASPBERRY_PI_PICO_2W
Serial.println("ARDUINO_RASPBERRY_PI_PICO_2W");
#endif
}
void loop() {}
thanks, i learned a lot
You are welcome. I'm glad if I was able to be of assistance.
Regards, Per
friend did a list of many boards,
and see 2 problems with my above code for
Arduino_nano_RP2040
Arduino_Uno_R4
not react on ARDUINO_BOARD or PICO_BOARD
i am still missing the big picture / like a list of possible board declarations
or like generally
i use the
#ifdef ESP32
often, but from what list of macros that comes from?
sorry
from platform.txt
build.extra_flags
ARDUINO_BOARD or PICO_BOARD is not standard