Go Down

Topic: Getting DEVICE ID (Read 93 times) previous topic - next topic



I have som ATMEGA 328P's and some ATMEGA 2650's . Some are original ARDUINO origin and some are from china.

One ATM328p and one ATM2650 have the same USB-chip (driver ch34X.sys)  These are the chinese types.

I need a smart way to separate between these 2 types ( atm328 and 2650)  in software.   

According to ATMEL (Atmel studio 7.0) there are differences in their DEVICE-ID's.  So I wonder, Is it possible to obtain these built-in device-id's and (eventually) print them in a Serial.print(...); command ?

IF so can anone tell me how to do that ?


Kris  aka snestrup2016


May 22, 2019, 02:22 pm Last Edit: May 22, 2019, 02:23 pm by pert Reason: Add link to list of all processor macros
When you compile for the ATmega328P, the __AVR_ATmega328P__ macro will be defined. When you compile for the ATmega2560, the __AVR_ATmega2560__ macro will be defined. So you can do things like this:
Code: [Select]
#if defined(__AVR_ATmega328P__)
  Serial.print("It's an ATmega328P");
#elif defined(__AVR_ATmega2560__)
  Serial.print("It's an ATmega2560");
  Serial.print("It's some other microcontroller");




THanks at lot.  That did the job.

Kris aka snestrup2016


You're welcome. I'm glad if I was able to be of assistance. Enjoy!

Go Up