Qwiic Single Relay Hookup Guide
Arduino Library
We've written a library to make it even easier to get started with the SparkFun Qwiic Single Relay. The library will give you the full functionality of the Qwiic Single Relay without the hub bub of the I²C data transactions. You can click the link below to download the file or navigate through the Arduino Library Manager by searching SparkFun Qwiic Relay. You can also go the Github page and get it directly.
This library also works with our Qwiic Quad Relay board. If you need more relays on one PCB, then go check it out!
Library Functions Overview
The list below outlines the functions of the Qwiic Relay Arduino Library designed to work with the Qwiic Single Relay along with short descriptions of what they do. The examples cover nearly all of these functions so take a look at them for help integrating them into your own code.
bool begin(TwoWire &wirePort = Wire);
- Initialize the Qwiic Single Relay on the I2C busfloat singleRelayVersion();
- Returns the firmware version present on the Qwiic Single Relay.void turnRelayOn();
- Turn the relay on.void turnRelayOff();
- Turn the relay off.void toggleRelay()
- Toggles the relay to the opposite state. The function first checks the status of the relay and is toggled to eitheron
oroff
depending on what the status check returns.uint8_t getState();
- Returns the status of the relay. Returns1
if on or0
if off.bool changeAddress(uint8_t newAddress);
- Changes the I2C address of the Qwiic Relay to the value set fornewAddress
. ValidnewAddress
values can be between 0x07 and 0x78. The new address is written to the memory location in EEPROM that determines the address.