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
 6
 7from adafruit_atecc.adafruit_atecc import ATECC
 8
 9# Use 100kHz frequency for wake condition
10WAKE_CLK_FREQ = 100000
11
12# Initialize the i2c bus
13i2c = busio.I2C(board.SCL, board.SDA, frequency=WAKE_CLK_FREQ)
14
15# Initialize a new atecc object
16atecc = ATECC(i2c)
17
18print("ATECC Serial: ", atecc.serial_number)
19
20# Generate a random number with a maximum value of 1024
21print("Random Value: ", atecc.random(rnd_max=1024))
22
23# Print out the value from one of the ATECC's counters
24# You should see this counter increase on every time the code.py runs.
25print("ATECC Counter #1 Value: ", atecc.counter(1, increment_counter=True))
26
27# Initialize the SHA256 calculation engine
28atecc.sha_start()
29
30# Append bytes to the SHA digest
31print("Appending to the digest...")
32atecc.sha_update(b"Nobody inspects")
33print("Appending to the digest...")
34atecc.sha_update(b" the spammish repetition")
35
36# Return the digest of the data passed to sha_update
37message = atecc.sha_digest()
38print("SHA Digest: ", message)