1- # testing adafruit atecc module
2- import board
3- import adafruit_atecc
4- import busio
5-
6-
7- _WAKE_CLK_FREQ = 100000 # slower clock speed
8- i2c = busio .I2C (board .SCL , board .SDA , frequency = _WAKE_CLK_FREQ )
9-
10- adafruit_atecc .ATECCx08A (i2c )
1+ import board
2+ import busio
3+ import time
4+ import adafruit_ssd1306
5+ from adafruit_atecc .adafruit_atecc import ATECC , _WAKE_CLK_FREQ
6+
7+ # Initialize the i2c bus
8+ i2c = busio .I2C (board .SCL , board .SDA ,
9+ frequency = _WAKE_CLK_FREQ )
10+
11+ # Initialize a new atecc object
12+ atecc = ATECC (i2c )
13+
14+ print ("ATECC Serial: " , atecc .serial_number )
15+
16+ # Generate a random number with a maximum value of 1024
17+ print ("Random Value: " , atecc .random (rnd_max = 1024 ))
18+
19+ # Print out the value from one of the ATECC's counters
20+ # You should see this counter increase on every time the code.py runs.
21+ print ("ATECC Counter #1 Value: " , atecc .counter (1 , increment_counter = True ))
22+
23+ # Initialize the SHA256 calculation engine
24+ atecc .sha_start ()
25+
26+ # Append bytes to the SHA digest
27+ print ("Appending to the digest..." )
28+ atecc .sha_update (b"Nobody inspects" )
29+ print ("Appending to the digest..." )
30+ atecc .sha_update (b" the spammish repetition" )
31+
32+ # Return the digest of the data passed to sha_update
33+ message = atecc .sha_digest ()
34+ print ("SHA Digest: " , message )
0 commit comments