how to code for multiple qwiic relays ?

I have several qwiic single relays I assigned addresses to, 0x18, 0x19, 0x20 but I can’t figure out how to code them. I was trying this:

#include “SparkFun_Qwiic_Relay.h”

#define RELAY_ADDR 0x18

#define RELAY_ADDR19 0x19

Qwiic_Relay relay(RELAY_ADDR);

Qwiic_Relay relay19(RELAY_ADDR19);

and in setup I define it as:

if(!relay.begin())

Serial.println(“Check connections to Qwiic Relay.”);

else

Serial.println(“Ready to flip some switches.”);

float version = relay.singleRelayVersion();

Serial.print("Firmware Version: ");

Serial.println(version);

if(!relay19.begin())

Serial.println(“Check connections to Qwiic Relay.”);

else

Serial.println(“Ready to flip some switches.”);

float version19 = relay19.singleRelayVersion();

Serial.print("19 Firmware Version: ");

Serial.println(version19);

but when the code runs and I try and query the relay status

int state19 = relay19.getState();

Serial.print("19 ");Serial.println(state19);

it seems to crash the ESP32 board and forces a restart

Try getting just one to work first, then try adding in the others https://learn.sparkfun.com/tutorials/qw … ample-code - if you are daisy-chaining the relays together also be sure to disable all but one set of i2c pull-up resistors (cut the traces on the back, leave 1 set active per i2c bus)

I was able to get one to work but cannot figure how to code a second one, etc. Do i need a separate instance as in my example above ? When I tried to run the code it caused my esp32 to reboot. Do you have any example code of using two single relays (each has their own unique i2c address) ? thanks