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, Name or Class name of the device to created.
Returns:A qwiic device object for the specified qwiic device. If the specified device isn’t found, None is returned.
Return type:Object
Example:
>>> import qwiic
>>> results = qwiic.list_devices()
>>> print(results)
[(61, 'Qwiic Micro OLED', 'QwiicMicroOled'), (91, 'Qwiic CCS811', 'QwiicCcs811'),
(96, 'Qwiic Proximity Sensor', 'QwiicProximity'), (119, 'Qwiic BME280', 'QwiicBme280')]
>>> mydevice = qwiic.create_device(results[0][0])
>>> print(mydevice)
<qwiic_micro_oled.qwiic_micro_oled.QwiicMicroOled object at 0x751fdab0>
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_devices()[source]

Returns a list of known qwiic devices connected to the I2C bus.

Returns:A list of known attached qwiic devices. If no devices are attached, an empty list is returned. 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_devices()
[(61, 'Qwiic Micro OLED', 'QwiicMicroOled'),
(91, 'Qwiic CCS811', 'QwiicCcs811'),
(96, 'Qwiic Proximity Sensor', 'QwiicProximity'),
(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]