API Reference

qwiic

The SparkFun qwiic python package aggregates all python qwiic drivers/modules to provide a single entity for qwiic within a python environment. The qwiic package delivers the high-level functionality needed to dynamically discover connected qwiic devices and construct their associated driver object.

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

qwiic.create_device(device=None)[source]

Used to create a device object for a specific qwiic device

Parameters:device – The I2C address (int), Name or Class name (str) of the device to created, or selection from listed connected devices (tuple). The device address should be an integer value, of the hex value. For an example, for an 0x60 (hex) address enter qwiic.create_device(60).
Returns:A qwiic device object for the specified qwiic device, using the I2C address that the device is connected at. If the specified device isn’t found, None is returned.
Return type:Object
Example:
>>> import qwiic
>>> results = qwiic.list_devices()
>>> print(results)
[(16, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'), (16, 'Qwiic Titan GPS', 'QwiicTitanGps'), (41, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'), (60, 'Qwiic Micro OLED (64x48)', 'QwiicMicroOled'), (60, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'), (60, 'SSD1306 Display Driver', 'QwiicSSD1306Driver'), (60, 'Qwiic OLED Display (128x32)', 'QwiicOledDisplay'), (61, 'Qwiic Micro OLED (64x48)', 'QwiicMicroOled'), (61, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'), (61, 'SSD1306 Display Driver', 'QwiicSSD1306Driver'), (61, 'Qwiic OLED Display (128x32)', 'QwiicOledDisplay')]
>>> mydevice1 = qwiic.create_device(results[47])
>>> print(mydevice1)
<qwiic_micro_oled.qwiic_micro_oled.QwiicMicroOled object at 0x743558f0>
>>> mydevice2 = qwiic.create_device(41)
>>> print(mydevice2)
<qwiic_vl53l1x.QwiicVL53L1X object at 0x743e7bb0>
>>> mydevice3 = qwiic.create_device("QwiicTitanGps")
============================================================================
Message about Titan GPS package...
============================================================================
>>> print(mydevice3)
<qwiic_titan_gps.QwiicTitanGps object at 0x739c4430>
qwiic.get_devices()[source]

Used to create device objects for all qwiic devices attached to the computer.

Returns:A list of qwiic device objects. If no qwiic devices are an empty list is returned.
Return type:list
Example:
>>> import qwiic
>>> qwiic.get_devices()
[<qwiic_micro_oled.qwiic_micro_oled.QwiicMicroOled at 0x76081ef0>,
<qwiic_ccs811.QwiicCcs811 at 0x752b78b0>,
<qwiic_proximity.QwiicProximity at 0x752b0e10>,
<qwiic_bme280.QwiicBme280 at 0x752b0a30>]
qwiic.list_available_drivers(device_address=None)[source]

Returns a list of known drivers/packages for qwiic devices.

Parameters:device_address – A list with an I2C address or addresses. If no value was given, the I2C bus will be scanned and the address(es) of the connected qwiic devices will be used.
Returns:A list of qwiic drivers/packages associated with the address(es) in the list. Each element of the list a tuple that contains the following values (Device I2C Address, Device Name, Device Driver Class Name)
Return type:list
Example:
>>> import qwiic
>>> qwiic.list_available_drivers([32])
[(32, 'Qwiic GPIO', 'QwiicGPIO'),
(32, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(32, 'SparkFun Qwiic Joystick', 'QwiicJoystick')]
>>> qwiic.list_available_drivers([61,91])
[(61, 'Qwiic Micro OLED', 'QwiicMicroOled'),
(61, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(91, 'Qwiic PCA9685', 'QwiicPCA9685'),
(91, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(91, 'Qwiic CCS811', 'QwiicCcs811')]
qwiic.list_devices()[source]

Returns a list of known qwiic driver/packages for I2c address(es) of device(s) connected to the I2C bus.

Returns:A list of the qwiic devices associated with the I2C address(es) scanned from the I2C bus. Each element of the list a tuple that contains the following values (Device I2C Address, Device Name, Device Driver Class Name) If no devices are attached, an empty list is returned.
Return type:list
Example:
>>> import qwiic
>>> qwiic.list_devices()
[(61, 'Qwiic Micro OLED', 'QwiicMicroOled'),
(61, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(91, 'Qwiic PCA9685', 'QwiicPCA9685'),
(91, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(91, 'Qwiic CCS811', 'QwiicCcs811'),
(96, 'Qwiic PCA9685', 'QwiicPCA9685'),
(96, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(96, 'Qwiic Proximity Sensor', 'QwiicProximity'),
(119, 'Qwiic PCA9685', 'QwiicPCA9685'),
(119, 'Qwiic 4m Distance Sensor (ToF)', 'QwiicVL53L1X'),
(119, 'Qwiic Mux', 'QwiicTCA9548A'),
(119, 'Qwiic BME280', 'QwiicBme280')]
qwiic.scan()[source]

Used to scan the I2C bus, returning a list of I2C address attached to the computer.

Returns:A list of I2C addresses. If no devices are attached, an empty list is returned.
Return type:list
Example:
>>> import qwiic
>>> [2]: qwiic.scan()
[61, 91, 96, 119]