Simple test

Ensure your device works with this simple test.

examples/atecc_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import board
 5import busio
 6from adafruit_atecc.adafruit_atecc import ATECC, _WAKE_CLK_FREQ
 7
 8# Initialize the i2c bus
 9i2c = busio.I2C(board.SCL, board.SDA, frequency=_WAKE_CLK_FREQ)
10
11# Initialize a new atecc object
12atecc = ATECC(i2c)
13
14print("ATECC Serial: ", atecc.serial_number)
15
16# Generate a random number with a maximum value of 1024
17print("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.
21print("ATECC Counter #1 Value: ", atecc.counter(1, increment_counter=True))
22
23# Initialize the SHA256 calculation engine
24atecc.sha_start()
25
26# Append bytes to the SHA digest
27print("Appending to the digest...")
28atecc.sha_update(b"Nobody inspects")
29print("Appending to the digest...")
30atecc.sha_update(b" the spammish repetition")
31
32# Return the digest of the data passed to sha_update
33message = atecc.sha_digest()
34print("SHA Digest: ", message)