Qwiic Quad Relay Hookup Guide
Arduino Library
We've written a library to make it even easier to get started with the SparkFun Qwiic Quad Relay. The library will give you the full functionality of the Qwiic Quad 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 Single Relay board. If you only need one relay then go check it out!
Library Functions Overview
The list below outlines all of the functions of the Qwiic Relay Arduino Library designed to work with the Qwiic Quad Relay along with short descriptions of what they do. The examples cover nearly all of the functions so take a look at those for demonstrations on how to integrate them into your own code.
bool begin(TwoWire &wirePort = Wire);- Initialize the Qwiic Relay on the I2C busfloat singleRelayVersion();- Returns the version number of the relayvoid turnRelayOn(uint8_t relay);- Turn the given relay on. Valid inputs forrelayare 1 through 4. For example,turnRelayOn(1);will toggle the first relay.void turnRelayOff(uint8_t relay);- Turn the selected relay off. Similar to the above function, select values between 1 and 4 to turn the chosen relay off.void toggleRelay(uint8_relay)- Toggles the selected relay to the opposite state. The function first checks the status of the relay and is toggled to eitheronoroffdepending on what the status check returns.void turnAllRelaysOn();- Turns all relays on the board on.void turnAllRelaysOff();- Turns all relays on the board off.void toggleAllRelays();- Toggles all relays on the board to the opposite state of the relay status check.uint8_t getState(uint8_t relay);- Returns the status of the selected relay. Returns1if on or0if off. Just like with previous functions, valid inputs forrelayare 1 through 4.bool changeAddress(uint8_t newAddress);- Changes the I2C address of the Qwiic Relay. The new address is written to the memory location in EEPROM that determines the address. ValidnewAddressvalues can be between 0x07 and 0x78.