API Reference

qwiic_relay

Python module for the SparkFun Qwiic Single Relay, SparkFun Qwiic Quad Relay, SparkFun Qwiic Dual Solid State Relay, SparkFun Qwiic Quad Solid State Relay

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.

class qwiic_relay.QwiicRelay(address=None, i2c_driver=None)[source]
Parameters:
  • address – The I2C address to use for the device. If not provided, the default address is used.
  • i2c_driver – An existing i2c driver object. If not provided a driver object is created.
Returns:

The Qwiic Relay device object.

Return type:

Object

begin()[source]

Initialize the operation of the relay

Returns:Returns true of the initialization was successful, otherwise False.
Return type:bool
connected

Determine if the Qwiic Relay is connected to the system.

Returns:True if the device is connected, otherwise False.
Return type:bool
get_relay_state(relayNum=None)[source]

Returns true if the relay is currently on, and false if it is off.

Returns:Status of the relay
Return type:bool
get_slow_pwm(relayNum)[source]

Gets the value for the slow PWM signal. Can be anywhere from 0 (off) to 120 (on).

Param:The relay to get the PWM signal of
Returns:The value of the PWM signal, a value between 0 and 120
Return type:bool
get_version()[source]

Returns the firmware version for the Single Relay

Returns:The firmware version
Return type:string
is_connected()[source]

Determine if the Qwiic Relay is connected to the system.

Returns:True if the device is connected, otherwise False.
Return type:bool
set_all_relays_off()[source]

Turn’s off all relays. This command does nothing for the single relay

Param:The relay to turn off
Returns:successful I2C transaction
Return type:bool
set_all_relays_on()[source]

Turn’s on all relays. This command does nothing for the single relay

Param:The relay to turn on
Returns:successful I2C transaction
Return type:bool
set_relay_off(relayNum=None)[source]

Turn’s off a relay,if we’re using a single relay, do not pass in a relay number

Param:The relay to turn off
Returns:successful I2C transaction
Return type:bool
set_relay_on(relayNum=None)[source]

Turn’s on a relay,if we’re using a single relay, do not pass in a relay number

Param:The relay to turn on
Returns:successful I2C transaction
Return type:bool
set_slow_pwm(relayNum, pwmValue)[source]

Sets the value for the slow PWM signal. Can be anywhere from 0 (off) to 120 (on). A full cycle takes 1 second.

Param:The relay to set the PWM signal of
Param:The value of the PWM signal, a value between 0 and 120
Returns:successful I2C transaction
Return type:bool
version

Returns the firmware version for the Single Relay

Returns:The firmware version
Return type:string