Hi
Im struggling to get a second Qwiic GPIO DEV-17047 board working.
I’ve addressed the 2nd board as 0x26. could someone please help how I setup the boards together
do the boards and the addresses need defining?
if so what is the correct way to achieve this?
thanks in advance
nick
do the two boards need defining?
Yes you’d need to define both, so that your code can tell them apart.
can you throw a bone then? how is done?
I’m afraid we can’t help with code but if any other forum users would like to chip in they are free to do so.
jfbauer
February 4, 2021, 12:53pm
7
I believe what you want to do is something like the following:
TCA9534 myGPIO1;
TCA9534 myGPIO2;
void setup() {
...
if (myGPIO1.begin() == false) { // default address 0x27
Serial.println("Check Connections. No Qwiic GPIO #1 detected.");
while (1);
}
if (myGPIO2.begin(Wire, 0x26) == false) {
Serial.println("Check Connections. No Qwiic GPIO #2 detected.");
while (1);
}
...
}
And then to use, do something like
myGPIO1.digitalWrite(0, HIGH); // GPIO 0 on 1st DEV-17047
myGPIO1.digitalWrite(1, HIGH); // GPIO 1 on 1st DEV-17047
...
myGPIO2.digitalWrite(0, HIGH); // GPIO 0 on 2nd DEV-17047
Hi
Would there still need a #define ‘address’? like below with ‘sgp30’ & ‘Qwiic relay’. there isn’t one in the sparkfun library
#define SGP30_ADDR 0x58
#define RELAY_ADDR 0x6D, 0x6C
TCA9534 myGPIOA, myGPIOB;
SGP30 mySensor;
Qwiic_Relay quadRelayA(0x6D), quadRelayB(0x6C);
regards
Nick
In your code fragment, neither of your defines are being used (and RELAY_ADDR as you have it is probably not what you intended). But you could do so like this.
#define RELAY_ADDR_A 0x6D
#define RELAY_ADDR_B 0x6C
...
Qwiic_Relay quadRelayA(RELAY_ADDR_A), quadRelayB(RELAY_ADDR_B);
For the code I posed the other day, you could replace the 0x26 in the one myGPIO2.begin() with a define. That is up to you. It is generally considered good practice to do so. You could also add a define for the myGPIO1.begin() as well and also add it as (well as the Wire argument) in the call. i.e.
#define GPIO1_ADDR 0x27 // I think that was the default
#define GPIO1_ADDR 0x26
...
if (myGPIO1.begin(Wire, GPIO1_ADDR) == false) {
...
if (myGPIO2.begin(Wire, GPIO2_ADDR) == false) {
...
Gpio’s working great. Could you please check to see if i have the relays right?
#define RELAY_ADDR 0x6D
#define RELAY_ADDR_B 0x6C
Qwiic_Relay quadRelay(RELAY_ADDR), quadRelayB(RELAY_ADDR_B);
void setup() {
// Let’s make sure the hardware is set up correctly.
if(!quadRelay.begin() == false) { //if(!quadRelayA.begin())
Serial.println(“Check connections to Qwiic Relay A.”);}
else{
Serial.println(“Relay A Detected”);
}
if(!quadRelayB.begin() == false) { //if(!quadRelayB.begin())
Serial.println(“Check connections to Qwiic Relay B.”);}
else{
Serial.println(“Relay B Detected”);
}
}
jfbauer
February 26, 2021, 9:15pm
11
Looks like your conditionals are wrong. Either remove the ‘!’ or the ’ == false’. i.e. do something like
if (quadRelay.begin() == false) {
// error handling
}
or
if (!quadRelay.begin()) {
// error handling
}