How to Obtain Terminal ID with Raspberry Pi Pico
import machine
import binascii
device_id = binascii.hexlify(machine.unique_id()).decode()
print(device_id)
d66a64xxxxxxxxxx
You can achieve this by using machine.unique_id()
.
The result can be obtained as binary data, which might be difficult to use as it is. Therefore, it is a good idea to convert it to a string using either binascii
or base64
.
binascii
comes standard with MicroPython.
>>> machine.unique_id()
b'\xe6axxxxxxxx'
>>> binascii.hexlify(machine.unique_id())
b'e66164xxxxxxxxxx'
>>> binascii.hexlify(machine.unique_id()).decode()
'e66164xxxxxxxxxx'
Comments