MattFryer / Board_Identify

An Arduino library which allows identification of the board/controller
GNU General Public License v3.0
25 stars 3 forks source link
arduino arduino-boards arduino-ide arduino-library

Arduino IDE GitHub version GitHub Release Date GitHub stars GitHub issues Codacy grade GitHub license

Board Identify

An Arduino library which allows identification of the make, model and MCU of board/controller which the code was compiled for. Currently supports identification of over 100 different boards including all Arduino/Genuino, Teensy, ESP8266, ESP32, BBC micro:bit and Digispark boards.

Please note, some boards share the same identifiers and so can't be distinguished between. When this is the case, both boards will be returned.

How to Install

For details on how to install libraries in the Arduino IDE, please see the Arduino website.

How to Use

A full example is provided with the library and can be found in the Arduino IDE under "File->Examples->Board_Identify".

Firstly, you must include the library in your sketch:

#include <Board_Identify.h>

Board Identify uses the namespace "BoardIdentify" to prevent conflicts with other libraries. You can therefor access the board information as follows:

Serial.print(F("Board Type: "));
Serial.println(BoardIdentify::type); 
Serial.print(F("Board Make: "));
Serial.println(BoardIdentify::make); 
Serial.print(F("Board Model: "));
Serial.println(BoardIdentify::model); 
Serial.print(F("Board MCU: "));
Serial.println(BoardIdentify::mcu); 

It is advised to use BoardIdentify::type for any logic as it will never be changed and so should maintain future compatibility.

Adding this line before the library is included will cause a warning in the compile output window containing the identified board:

#define BOARD_IDENTIFY_WARNING

If warnings still don't display, ensure "File->Preferences->compiler warnings" is set to "Default".

Even doing this, some boards still won't display the warning in the compile window but the constants will still be created.

Currently Supported Boards

Over 100 boards/controllers are currently supported including:

Planned Improvements/Changes

For planned changes, improvements and known bugs please visit the Github issues tracker.