API Reference

qwiic_eeprom

Python module for the SparkFun Qwiic EEPROM Breakout - 512Kbit.

This package is a port of the exisiting [SparkFun External EEPROM Arduino Library](https://github.com/sparkfun/SparkFun_External_EEPROM_Arduino_Library).

This package can be used in conjuction with the overall [SparkFun Qwiic Python Package](https://github.com/sparkfun/Qwiic_Py).

New to qwiic? Take a look at the entire [SparkFun Qwiic Ecosystem](https://www.sparkfun.com/qwiic).

class qwiic_eeprom.QwiicEEPROM(address=None, i2c_driver=None)[source]

Qwiic EEPROM

param address

The I2C address to use for the device. If not provided, the default address is used.

param i2c_driver

An existing i2c driver object. If not provided a a driver object is created.

return

The GPIo device object.

rtype

Object

begin()[source]

Initialize the operation of the Qwiic EEPROM. Run is_connected().

Returns

Returns true if the initialization was successful, false otherwise.

Return type

bool

disable_poll_for_write_complete()[source]

Disable polling of when a write has completed

Returns

Nothing

Return type

Void

enable_poll_for_write_complete()[source]

Enable I2C polling of when a write has completed

Returns

Nothing

Return type

Void

erase(to_write=0)[source]

Erase entire EEPROM.

Parameters

to_write – byte to write into each spot of EEPROM

Returns

Nothing

Return type

void

get_I2C_buffer_size()[source]

Return the size of the TX buffer

Returns

I2C_BUFFER_LENGTH_TX

Return type

int

get_memory_size()[source]

Return the size of EEPROM

Returns

memory_size_bytes

Return type

int

get_page_size()[source]

Get the page size

Returns

Current page size off EEPROM in bytes

Return type

int

get_page_write_time()[source]

Get the current time required per page write

Returns

Time required per page write

Return type

int

is_busy(i2c_address=255)[source]

Returns true if the device is not answering (currently writing).

Parameters

i2c_address – I2C address of EEPROM. Larger EEPROMs have two addresses.

Returns

True if the IC is busy, false otherwise

Return type

bool

is_connected(i2c_address=255)[source]

Determine if a Qwiic EEPROM device is connected to the system

Parameters

i2c_address – I2C address of EEPROM. Larger EEPROMs have two addresses.

Returns

True if the device is connected, false otherwise.

Return type

bool

length()[source]

Returns the memory size of the EEPROM

Returns

memory_size_bytes

Return type

int

read(eeprom_location, num_bytes)[source]

Bulk read from EEPROM. Handles breaking up read amt into 32 byte chunks (can be overidden with set_I2C_buffer_size() Handles a read that straddles the 512kbit barrier

Parameters
  • eeprom_location – address of EEPROM to start reading from

  • num_bytes – number of bytes to be read from external EEPROM

Returns

a list of bytes read from EEPROM

Return type

list

read_byte(eeprom_location)[source]

Read exactly one byte from EEPROM at a given address location

Parameters

eeprom_location – location in EEPROM to read byte from

Returns

byte read from EEPROM

Return type

byte

read_float(eeprom_location)[source]

Read a 32-bit float from a given EEPROM location

Parameters

eeprom_location – location in EEPROM to read float from

Returns

float read from EEPROM

Return type

float

read_int(eeprom_location)[source]

Read a 32-bit signed int from a given EEPROM location

Parameters

eeprom_location – location in EEPROM to read int from

Returns

int read from EEPROM

Return type

int

read_string(eeprom_location, string_length)[source]

Read a stromg of given length from any address of EEPROM

Param

eeprom_location: location in EEPROM to read string from

Parameters

string_length – number of chars to read from EEPROM

Returns

string read from EEPROM

Return type

string

set_I2C_buffer_size(buff_size)[source]

Set the size of the TX buffer

Parameters

buff_size – the size of the I2C buffer

Returns

nothing

Return type

Void

set_memory_size(mem_size)[source]

Set the size of memory in bytes

Parameters

mem_size – memory size in bytes

Returns

Nothing

Return type

void

set_page_size(page_size)[source]

Set the size of the page we can write at a time

Parameters

page_size – new page size in bytes

Returns

Nothing

Return type

void

set_page_write_time(write_time_ms)[source]

Set the number of ms required per page write

Parameters

write_time_ms – write time in ms

Returns

Nothing

Return type

Void

write(eeprom_location, data_list)[source]

Write large bulk amounts to EEPROM. Limits write to the I2C buffer size (default is 32 bytes).

Parameters
  • eeprom_location – 2-byte EEPROM address to write to

  • data_list – list of data bytes to be written to EEPROM sequentially, starting at the EEPROM address

Return type

Void

Returns

nothing

write_byte(eeprom_location, byte_to_write)[source]

Write a single byte to given EEPROM location

Parameters
  • eeprom_location – location in EEPROM to byte to

  • byte_to_write – byte to write to EEPROM

Returns

Nothing

Return type

Void

write_float(eeprom_location, float_to_write)[source]

Write a 32-bit float to a given EEPROM location

Parameters
  • eeprom_location – location in EEPROM to write float to

  • float_to_write – float to write to EEPROM

Returns

Nothing

Return type

Void

write_int(eeprom_location, int_to_write)[source]

Write a signed 32-bit int to a given EEPROM location

Parameters
  • eeprom_location – location in EEPROM to write int to

  • int_to_write – int to write to EEPROM

Returns

Nothing

Return type

Void

write_string(eeprom_location, string_to_write)[source]

Write a stirng to a given EEPROM location

Parameters
  • eeprom_location – location in EEPROM to write string to

  • string_to_write – string to write to EEPROM

Returns

Nothing

Return type

Void