Giter Club home page Giter Club logo

arduinouniqueid's Introduction

ArduinoUniqueID

This Library gets the Unique ID / Manufacture Serial Number from the Atmel AVR, SAM, SAMD, STM32, and ESP Microcontroller.

Compile Sketch

Microcontrollers

ArduinoUniqueID supports the Microcontrollers.

  • Atmel AVR - Not Unique Disclaimer
  • Atmel SAM ARM
  • Atmel SAMD ARM
  • STM32
  • Espressif ESP
  • Teensy
  • Raspberry Pi Pico - RP2040

Installation

Examples

The library comes with examples. After installing the library you need to restart the Arduino IDE before they can be found under File > Examples > ArduinoUniqueID.


Reference

Include Library

#include <ArduinoUniqueID.h>

Variable: UniqueID & UniqueIDsize

UniqueID has UniqueIDsize bytes array of the Unique Serial ID.

for(size_t i = 0; i < UniqueIDsize; i++)
  Serial.println(UniqueID[i], HEX);

Method: UniqueIDdump

Print the hexadecimal bytes of the Unique Serial ID on the Stream.

void UniqueIDdump(Stream);

Variable: UniqueID8

UniqueID8 has the last 8 bytes array of the Unique Serial ID.

for(size_t i = 0; i < 8; i++)
  Serial.println(UniqueID8[i], HEX);

Method: UniqueID8dump

Print the last eight hexadecimal bytes of the Unique Serial ID on the Stream.

void UniqueID8dump(Stream);

Do you like this library? Please star this project on GitHub!

arduinouniqueid's People

Contributors

khoih-prog avatar ricaun avatar timgremalm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduinouniqueid's Issues

Seem a little mistake with ESP32 C3

Hi,

This lib works like a Charm with ESP32 C3 except that all my device's low MAC are minus 1
original MAC is 84:F7:03:3B:49:ED
given Mac by the library is 84:F7:03:3B:49:EC

This is always the same with all my chip

SAMD51 not supported (and will crash the CPU if used)

Thanks for making this library available.

On the SAMD51 platform, the addresses to use are as follows:

#define SERIAL_NUMBER_WORD_0	*(volatile uint32_t*)(0x008061FC)
#define SERIAL_NUMBER_WORD_1	*(volatile uint32_t*)(0x00806010)
#define SERIAL_NUMBER_WORD_2	*(volatile uint32_t*)(0x00806014)
#define SERIAL_NUMBER_WORD_3	*(volatile uint32_t*)(0x00806018)

My board is a Feather M4; it can be detected by having ARDUINO_FEATHER_M4 defined, but there may be better/other ways of doing this (not sure if there is a SAMD21 vs SAMD51 definition).

Read and compare ID

Hello
I have arduino Nano.
How can I make the ID read when the chip is powered and compare it with the ID written in the code.
Thank you.

you can keep memory

extern ArduinoUniqueID _UniqueID; wastes RAM.
Usually, you need to check ID just once. And no need to have it globally.
Please, fix it.

How to address Arduino board through the unique ID

Thank you for your library, i have tested it and got unique addresses for Arduino Mega. I have attached the unique address generated by your library, it is about 9 byte. I want to know how i can use the unique ID to address the Arduino. I'm doing a project that has many arduino and they are all controlled by another arduino which acts as a central control. How do i use the unique ID to send message or request data from a particular arduino board?.
Thank you

ID

Incorrect endianness during copy since the chip is little endian

id[i * 4 + 0] = (uint8_t)(pdwUniqueID[i] >> 24);
id[i * 4 + 1] = (uint8_t)(pdwUniqueID[i] >> 16);
id[i * 4 + 2] = (uint8_t)(pdwUniqueID[i] >> 8);
id[i * 4 + 3] = (uint8_t)(pdwUniqueID[i] >> 0);

This should be copied in reverse since the architecture is little endian

	id[i * 4 + 0] = (uint8_t)(pdwUniqueID[i] >> 0);
	id[i * 4 + 1] = (uint8_t)(pdwUniqueID[i] >> 8);
	id[i * 4 + 2] = (uint8_t)(pdwUniqueID[i] >> 16);
	id[i * 4 + 3] = (uint8_t)(pdwUniqueID[i] >> 24);

Change for Core RP2040 Arduino

Arduino has changed the definition of the Mbed core for RP2040 of ARDUINO_ARCH_MBED_RP2040 to ARDUINO_ARCH_RP2040

Thanks

Writable Unique ID

Hi all,

I understand that this library is helping to read the unique ID of the MCU but I wanted to ask theoretically that we can write to the unique ID as well like to change it? Is it possible?

Please let me know.

Thanks,
AKshay

UNO R4 not supported

Loading this lib and selecting the new UNO R4 Minima lists the examples as incompatible.
Is there any way to get a unique ID from the UNO R4?
Using ethernet-shields it's very important to have a unique MAC adress. I did this on AVR in code using the unique ID from the board. That makes it easy not to forget generating a "unique" MAC when using more than one ethernet shield.

I read something that native USB support requires unique IDs. The UNO R4 has native USB like many other non-AVR-devices. So maybe there is a "native" arduino command for that?

Any ideas?
Thanks

Add processor type information to ID

Nice useful library.
Had a quick look at the code and noticed that you can have the same deviceID for different device types.
By adding type information - could be an enum of supported types - the uniqueness can be multi processor.

reserving 2 bytes for the type would allow you to add a new device type every day for 160-180 years

ArduinoUniqueID example tries to send data before serial comms established

Tested on an Arduino Micro the ArduinoUniqueID example tries to send serial data before comms are established and ends up sending nothing! Adding <while (!SerialUSB);> just after serial.begin fixed this issue for me :)
This issue also occurred for the ArduinoUniqueID8 example but the ArduinoUniqueIDSerialUSB example already had it and works all good!

Unable to be used in Platform IO

If PlatformIO is used as the compiler for an Arduino sketch the 2nd time the include file is used it causes a compilation issue.
expected ')' before '.' token Line 51

This is not seen under Arduino IDE as it creates a single source code file before it compiles.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.