Qwiic_EEPROM_Py¶
Python module for the SparkFun Qwiic EEPROM Breakout - 512Kbit
This python package is a port of the existing SparkFun External EEPROM Arduino Library
This package can be used in conjunction with the overall SparkFun qwiic Python Package
New to qwiic? Take a look at the entire SparkFun qwiic ecosystem.
Supported Platforms¶
The Qwiic EEPROM Python package currently supports the following platforms:
Dependencies¶
This driver package depends on the qwiic I2C driver: Qwiic_I2C_Py
Documentation¶
The SparkFun Qwiic EEPROM module documentation is hosted at ReadTheDocs
Installation¶
PyPi Installation¶
This repository is hosted on PyPi as the sparkfun-qwiic-eeprom package. On systems that support PyPi installation via pip, this library is installed using the following commands
For all users (note: the user must have sudo privileges):
sudo pip install sparkfun-qwiic-eeprom
For the current user:
pip install sparkfun-qwiic-eeprom
To install, make sure the setuptools package is installed on the system.
Direct installation at the command line:
python setup.py install
To build a package for use with pip:
python setup.py sdist
A package file is built and placed in a subdirectory called dist. This package file can be installed using pip.
cd dist
pip install sparkfun-qwiic-eeprom-<version>.tar.gz
Example Use¶
See the examples directory for more detailed use examples.
from __future__ import print_function
import qwiic_eeprom
import time
import sys
def run_example():
print("\nSparkFun Qwiic EEPROM, Example 1\n")
my_eeprom = qwiic_eeprom.QwiicEEPROM()
if my_eeprom.begin() != True:
print("\nThe Qwiic EEPROM isn't connected to the system. Please check your connection", \
file=sys.stderr)
return
print("\nEEPROM ready!")
print("\nMem size in bytes: " + str(my_eeprom.length()))
my_value1 = 200 # 0xC8
my_eeprom.write_byte(300, my_value1) # (location = 0x12C, data byte)
my_read1 = my_eeprom.read_byte(300) # (location = 0x12C)
print("\nI read: " + str(my_read1)) # Should be 0xC8 = 200
my_value2 = -366
my_eeprom.write_int(10, my_value2)
my_read2 = my_eeprom.read_int(10) # (location)
print("\nI read: " + str(my_read2))
my_value3 = -7.35
my_eeprom.write_float(9, my_value3)
my_read3 = my_eeprom.read_float(9) # (location)
# Round to 2-decimal point precision
my_read3 = round(my_read3, 2)
print("\nI read: " + str(my_read3))
if __name__ == '__main__':
try:
run_example()
except (KeyboardInterrupt, SystemExit) as exErr:
print("\nEnding Example 1")
sys.exit(0)