SparkFun Qwiic Quad Solid State Relay Kit Hookup Guide
Qwiic Relay Arduino Library
The SparkFun Qwiic Relay Arduino Library works with all SparkFun Qwiic Relay boards to help you use your Qwiic Relay to its full functionality. 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 library's GitHub repo and download it from there.
Library Functions Overview
The list below outlines all of the functions of the Qwiic Relay library along with short descriptions of what they do. The examples cover nearly all of the functions so take a look at those for help integrating them into your own code.
These functions will work with all SparkFun Qwiic Relay boards.
bool begin(TwoWire &wirePort = Wire);
- Initialize the Qwiic Relay on the I2C bus.float singleRelayVersion();
- Returns the version number of the relay.void turnRelayOn(uint8_t relay);
- Turn the given relay on. For example,turnRelayOn(1);
will toggle the first relay. If using the single Qwiic Single Relay leave the unsigned integer blank.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. Leave the integer blank if using the Qwiic Single Relay.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 eitheron
oroff
depending 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();
- Checks the state of each relay and toggles all relays on the board to the opposite state.uint8_t getState(uint8_t relay);
- Returns the status of the selected relay. Returns1
if on or0
if off.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.
The below function is intended for the Qwiic Solid State Relay boards only. It will not work on either of the Qwiic Mechanical Relay boards.
bool setSlowPWM(uint8_t relay, uint8_t pwmValue);
- Starts a slow PWM (1Hz) with a range from 0-120 for the selected relay. The PWM range is limited to 0-120 as this is the maximum PWM resolution for Zero-crossing SSR's at 60Hz. SettingpwmValue
to 120 will give you 100% duty cycle and the selected relay will be always on.