github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/examples/device-id/main.go (about)

     1  package main
     2  
     3  import (
     4  	"encoding/hex"
     5  	"machine"
     6  	"time"
     7  )
     8  
     9  func main() {
    10  	time.Sleep(2 * time.Second)
    11  
    12  	// For efficiency, it's best to get the device ID once and cache it
    13  	// (e.g. on RP2040 XIP flash and interrupts disabled for period of
    14  	// retrieving the hardware ID from ROM chip)
    15  	id := machine.DeviceID()
    16  
    17  	for {
    18  		println("Device ID:", hex.EncodeToString(id))
    19  		time.Sleep(1 * time.Second)
    20  	}
    21  }