0

I would like to identify the target where I'm downloading my Arduino code. Following this example:

How to get board type

I'm able to recognize for example Arduino Mini, etc.. but Arduino Every, quite new board is not in the list and I don't understand where to find the correct "define" name to add in the list. Can someone help me? Thanks Andrea.

4
  • there really isn't much magic behind it. Depending on your selection, ide includes a particular core folder from inside hardware so in theory you could look there also. that specific method is tied to an arduino bootloader- the thing that runs at boot before your program. As it said, search for avr_cpunames.h header and see if _AVR_CPU_NAME_ helps.
    – Abel
    Jul 24 '21 at 20:20
  • Thanks but I wrote here because searching into Arduino IDE installation I did not found nothing related to "Arduino Every" or even "AT mega 4809" etc.. nothing that seems in the list. So, if someone is more expert to me.. also the file avr_cpunames.h contains nothing related. I tried with many names that could make sense but trying by tentatives.. not so good. Arduino IDE version 1.8.13. With IDE installed I can use Arduino Nano Every perfectly.
    – Andrea Guglielmi
    Jul 24 '21 at 21:26
  • default behavior does something evil for downloaded packages - also check %HOMEPATH%\AppData\Local for an Arduino folder. The Arduino.h header it uses is likely there under packages\arduino\hardware\megaavr
    – Abel
    Jul 24 '21 at 22:29
  • Arduino Nano Every is using the ArduinoCore-megaavr, designed for new chips like AT mega4808/09. For Uno/Nano/Pro Mini, it is using the ArduinoCore-avr. If you can't find your board on IDE or your file system, the chance is that you have not install the ArduinoCore-megaavr.
    – hcheung
    Jul 25 '21 at 1:58
2

According to documentation the macro to identify the Arduino board is generated as as ARDUINO_{build.board} where {build.board} is from boards.txt file of the 'platform'.

Nano Every has in boards.txt nona4809.build.board=AVR_NANO_EVERY.

So the macro to identify Nano Every is ARDUINO_AVR_NANO_EVERY.

1
  • 1
    Great! I was not aware of this documentation. It works perfectly, thanks a lot! I also found that if you need to know if the emulator mega 328 is selected, you can use: #elif defined(AVR_NANO_4809_328MODE) #define BOARD F("Every 328 emul") #elif defined(ARDUINO_AVR_NANO_EVERY) #define BOARD F("Every") But your answer solved my problem. Many thanks
    – Andrea Guglielmi
    Jul 25 '21 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy