Arduino RP2040 Pico独特ID

发布于 2025-02-07 04:43:55 字数 1431 浏览 2 评论 0 原文

我在Arduino IDE上使用Raspberry pi pico。我正在使用此库 githublink> githublink 。此链接中有3个示例, “ https://github.com/ricaun/arduinouniqueid/tree/master/examples/ArduiniqueD8” rel =“ nofollow noreferrer”> arduinouniqued8 什么都不打印。 iDE说

WARNING: library ArduinoUniqueID claims to run on avr, esp8266, esp32, sam, samd, stm32 architecture(s) and may be incompatible with your current board which runs on mbed_rp2040 architecture(s).

(但GitHub说我们添加了RP2040)

当我尝试使用最后一个示例,它打印了某些内容,但它们不是正确的值。它在此处打印以下内容:

UniqueID: 30 00 33 00 39 00 31 00 36 00 30 00 45 00 36 00 32 00 41 00 38 00 32 00 34 00 38 00 43 00 33 00 
UniqueID: 34 00 38 00 43 00 33 00 

此处正确的唯一ID值:(我用Micropython打印了这些值)

hex value of s = e660a4931754432c
type s = <class 'bytes'>
s =  b'\xe6`\xa4\x93\x17TC,'

我什至不知道哪种类型 34 00 38 00 43 00 33 00 33 00 是,我尝试转换十六进制打印同一件事。

如何使用Arduino代码找到Pico的独特ID?

I am using Raspberry pi pico on Arduino IDE. I am using this library githublink for it. There is 3 examples in this link, ArduinoUniqueID and ArduinoUniqueID8
doesn't print anything. Ide says

WARNING: library ArduinoUniqueID claims to run on avr, esp8266, esp32, sam, samd, stm32 architecture(s) and may be incompatible with your current board which runs on mbed_rp2040 architecture(s).

(but GitHub says we add RP2040)

When I try to use last example ArduinoUniqueIDSerialUSB , It prints something but they are not correct values. It prints these :

UniqueID: 30 00 33 00 39 00 31 00 36 00 30 00 45 00 36 00 32 00 41 00 38 00 32 00 34 00 38 00 43 00 33 00 
UniqueID: 34 00 38 00 43 00 33 00 

The correct unique ID values here : (I printed these with micropython)

hex value of s = e660a4931754432c
type s = <class 'bytes'>
s =  b'\xe6`\xa4\x93\x17TC,'

I don't even know what type 34 00 38 00 43 00 33 00 are, I try to convert hex but it prints same thing.

How can I find pico's Unique ID with Arduino Code ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

失与倦" 2025-02-14 04:43:55

PICO的唯一ID(和大多数RP2040板)由闪光灯的序列号确定。 PICO SDK具有获取该ID的功能。您可以使用 flash_get_unique_id(uint8_t* id_out)直接从闪存中检索它。该文档的文档为

另外,您可以从MCU获得唯一的ID。检索ID的两个函数是 pico_get_unique_board_id(pico_unique_board_id_id_t* id_out)它将ID返回为十六进制阵列或 pico_get_get_unique_unique_board_id_id_id_id_id_id_id_id_id_id_id_id_d_ id_ id_ id_out,uint len len len 在这里。

这些值是十六进制的,并且来自其唯一的_id缓冲区,看起来似乎不正确地填充了唯一的ID。下面的代码应该做您需要的事情。

   uint8_t UniqueID[8];
   void UniqueIDdump(stream)                      
    {
        flash_get_unique_id(UniqueID);                                             
        stream.print("UniqueID: ");       
        for (size_t i = 0; i < 8; i++) 
        {                                         
            if (UniqueID[i] < 0x10)               
                stream.print("0");                
            stream.print(UniqueID[i], HEX);      
            stream.print(" ");                          }                                         
        stream.println();                         
    }

A unique ID for the Pico (and most RP2040 boards) is determined by the serial number of the flash. The Pico SDK has functions to get that ID. Either you can retrieve it directly from the flash by using flash_get_unique_id(uint8_t* id_out) which is what the library linked above did. The documentation for that is here.

Alternatively, you can get the unique ID from the MCU. The two functions for retrieving the ID are pico_get_unique_board_id(pico_unique_board_id_t* id_out) which returns the ID as a hex array or pico_get_unique_board_id_string(char* id_out, uint len) which returns it as a string. The documentation for that is here.

Those values are hex and are coming from their Unique_ID buffer which it looks like is being improperly filled with the Unique id. The code below should instead do what you need.

   uint8_t UniqueID[8];
   void UniqueIDdump(stream)                      
    {
        flash_get_unique_id(UniqueID);                                             
        stream.print("UniqueID: ");       
        for (size_t i = 0; i < 8; i++) 
        {                                         
            if (UniqueID[i] < 0x10)               
                stream.print("0");                
            stream.print(UniqueID[i], HEX);      
            stream.print(" ");                          }                                         
        stream.println();                         
    }
寂寞花火° 2025-02-14 04:43:55

将其添加到未来寻找相同解决方案的人。伯爵已将 rp2040.getchipid()函数添加到他的pico核心,该功能将提供 char *(c String)结果。代码段为:

  // Print out my unique Id
  Serial.print("Unique Id: "); Serial.println(rp2040.getChipID());

这是结果:

Unique Id: E66138528361BB32

Adding this for those looking for the same solution in the future. Earl has added a rp2040.getChipID() function to his pico core which will provide the char * (c string) result. A code snippet is:

  // Print out my unique Id
  Serial.print("Unique Id: "); Serial.println(rp2040.getChipID());

And here is the result:

Unique Id: E66138528361BB32
夏尔 2025-02-14 04:43:55

“ uniqueID:30 00 33”等是一个Unicode字符串“ 039160E62A8248C348C3”而不是HEX。

另外,对于伯爵(Earls pico)核心,只需添加 extern“ c” void flash_get_unique_id(uint8_t *p); 即可访问上述唯一diDump示例所需的功能

"UniqueID: 30 00 33 " etc is a unicode string "039160E62A8248C348C3" not hex.

also for Earls pico core just add extern "C" void flash_get_unique_id(uint8_t *p); to your sketch and you can access the function required by the above UniqueIDdump example

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文