Getting DEVICE ID

HI,

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 ?

Thanks

Kris aka snestrup2016

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:

#if defined(__AVR_ATmega328P__)
  Serial.print("It's an ATmega328P");
#elif defined(__AVR_ATmega2560__)
  Serial.print("It's an ATmega2560");
#else
  Serial.print("It's some other microcontroller");
#endif

Reference:
https://www.microchip.com/webdoc/avrlibcreferencemanual/using_tools_1using_avr_gcc_mach_opt.html

hI,

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!
Per