The seesaw firmware that ships with the ATtinyxxx breakouts provides access to the 128 byte EEPROM. This example reads from and writes to the EEPROM.
Follow the instructions on the Python & CircuitPython page to get set up.
Example Code
Update your code.py to the following.
Before saving the file, connect to the serial console. The print statements are only sent the first time the code runs, so if you connect after you save the file, you may not see them printed to the serial console.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT # Simple seesaw test reading and writing the internal EEPROM # The ATtiny8xx series has a true 128 byte EEPROM, the SAMD09 mimics it in flash with 64 bytes # THE LAST BYTE IS USED FOR I2C ADDRESS CHANGE! import time import board from adafruit_seesaw import seesaw i2c_bus = board.I2C() # uses board.SCL and board.SDA # i2c_bus = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller ss = seesaw.Seesaw(i2c_bus) value = ss.eeprom_read8(0x02) # Read from address 2 print("Read 0x%02x from EEPROM address 0x02" % value) print("Incrementing value") ss.eeprom_write8(0x02, (value + 1) % 0xFF) value = ss.eeprom_read8(0x02) # Read from address 2 print("Second read 0x%02x from EEPROM address 0x02" % value) while True: # Do not write EEPROM in a loop, it has 100k cycle life time.sleep(1)
First, you import all the necessary modules and libraries, and you instantiate the seesaw on I2C.
Next, you read the value from address 2.
Then, you increment that value by +1.
Finally, you read the new value from address 2.
Inside the loop, is a 1 second delay. Do not write EEPROM in a loop, because it has a 100k cycle life.