It's easy to use the 24LC32 with Python or CircuitPython, and the Adafruit_CircuitPython_24LC32 module. This module allows you to easily write Python code that allows you to read and write to the 24LC32 EEPROM. You can use this EEPROM with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library.
CircuitPython Microcontroller Wiring
First, wire up a 24LC32 to your board exactly as shown below. Here's an example of wiring a Feather M4 to the EEPROM with I2C using one of the handy STEMMA QT connectors:
- Board 3V to EEPROM VIN (red wire)
- Board GND to EEPROM GND (black wire)
- Board SCL to EEPROM SCL (yellow wire)
- Board SDA to EEPROM SDA (blue wire)
You can also use standard 0.100" pitch headers to wire it up on a breadboard:
- Board 3V to EEPROM VIN (red wire)
- Board GND to EEPROM GND (black wire)
- Board SCL to EEPROM SCL (yellow wire)
- Board SDA to EEPROM SDA (blue wire)
Python Computer Wiring
Since there's dozens of Linux computers/boards you can use, below shows wiring for Raspberry Pi. For other platforms, please visit the guide for CircuitPython on Linux to see whether your platform is supported.
Here's the Raspberry Pi wired to the EEPROM using I2C and a STEMMA QT connector:
- Pi 3V to EEPROM VIN (red wire)
- Pi GND to EEPROM GND (black wire)
- Pi SCL to EEPROM SCL (yellow wire)
- Pi SDA to EEPROM SDA (blue wire)
Finally here is an example of how to wire up a Raspberry Pi to the EEPROM using a solderless breadboard:
- Pi 3V to EEPROM VIN (red wire)
- Pi GND to EEPROM GND (black wire)
- Pi SCL to EEPROM SCL (yellow wire)
- Pi SDA to EEPROM SDA (blue wire)
Python Installation of 24LC32 Library
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require enabling I2C on your platform and verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready!
Once that's done, from your command line run the following command:
pip3 install adafruit-circuitpython-24lc32
If your default Python is version 3, you may need to run pip
instead. Make sure you aren't trying to use CircuitPython on Python 2.x, it isn't supported!
CircuitPython Usage
To use with CircuitPython, you need to first install the 24LC32 library, and its dependencies, into the lib folder on your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
Your CIRCUITPY/lib folder should contain the following folders and file:
- adafruit_bus_device/
- adafruit_register/
- adafruit_24lc32.mpy

Python Usage
Once you have the library pip3
installed on your computer, copy or download the following example to your computer, and run the following, replacing code.py with whatever you named the file:
python3 code.py
# SPDX-FileCopyrightText: Copyright (c) 2021 Tim Cocks for Adafruit Industries # # SPDX-License-Identifier: Unlicense import board import adafruit_24lc32 i2c = board.I2C() # uses board.SCL and board.SDA # i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller eeprom = adafruit_24lc32.EEPROM_I2C(i2c) print("length: {}".format(len(eeprom))) # eeprom[0] = 4 # print(eeprom[0]) # eeprom[0:4] = [9, 3, 8, 1] # print(eeprom[0:4])
If running CircuitPython: Once everything is saved to the CIRCUITPY drive, connect to the serial console to see the data printed out!
If running Python: The console output will appear wherever you are running Python.
In the example, the EEPROM is instantiated on I2C. Then, the EEPROM's available storage length is printed to the REPL. The EEPROM is internally organized as 4096 words of 8 bits each, or 4 Kbytes total.
In the example, uncomment the following lines:
eeprom[0] = 4 print(eeprom[0]) eeprom[0:4] = [9, 3, 8, 1] print(eeprom[0:4])
Then save and rerun the code. 4
is written to the EEPROM's index 0
. The EEPROM's index 0
is then read and printed to the REPL in bytes. Then, a sequence of integers are written to the EEPROM and then read and printed to the REPL as bytes.
Page last edited January 22, 2025
Text editor powered by tinymce.