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 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

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
The print statements will show up in the serial console, but only the first time the code is run. If you connect to the serial console after saving, you may not see anything as there are no prints in the loop.

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.

This guide was first published on Oct 20, 2021. It was last updated on Oct 20, 2021.

This page (EEPROM) was last updated on Sep 30, 2023.

Text editor powered by tinymce.