Arduino RP2040 Pico独特ID
我在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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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。下面的代码应该做您需要的事情。
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 orpico_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.
将其添加到未来寻找相同解决方案的人。伯爵已将
rp2040.getchipid()
函数添加到他的pico核心,该功能将提供char *(c String)
结果。代码段为:这是结果:
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 thechar * (c string)
result. A code snippet is:And here is the result:
“ 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