Not able to detect the I2C based PIR device on the QWIIC connector of Arduino 4 UNO WiFi

I am facing an issue where the Arduino 4 UNO WiFi is not able to detect the I2C based PIR device on the QWIIC connector

I have used the pre existing programs from the Sparkfun Qwiic library present at https://github.com/sparkfun/SparkFun_Qw … r/examples , but these seem to be for the I2C bus on the pins 18 and 19 of the Arduino and hence the Qwiic based I2C device is not detected with these programs.

Can you please tell me what modifications do i need to do with these programs so that i can use the I2C based PIR device connected on the QWIIC connector of Arduino UNO 4 Wifi?

Connection pic:

Use “Wire1” instead of “Wire”, then point it to the correct pin #s and it should be fine; see the i2c & Qwiic sections here https://docs.arduino.cc/tutorials/uno-r … heat-sheet for more in-depth info

Using the Quad Relay (COM-16566) Example 2 Basics program, I2C works fine on the UNO R3 but not on Arduino 4.

Changing to Wire1.begin() had no affect.

Is that program not compatible with the Arduino 4?

Be sure to alter the pin #s as well (to use the R4’s Wire1)

I’m having the same problem with the PIR. The sensor works fine with the RedBoard. I found out that switching to Wire1 with the Qwiic connected RTC was all that was needed. When you say "point it to the correct pin #s " what specifically do you do? There is no statement setting pin numbers in the sketch.

Along with the Wire1.begin() you also need to point your device to use Wire1.

I don’t have a PIR but for other QWIIC sensors like the MCP9600 I used…

#include <SparkFun_MCP9600.h>
MCP9600 tempSensor;

void setup() {
  Wire1.begin();
  tempSensor.begin(96, Wire1);
}

96 is the default address for the MCP9600 in integer format.

Some libraries seem to want the address as an INT and some HEX.

Also, for some libraries you have to use &Wire1 with the ‘&’.

Once you have the sensor initialized on Wire1 it should work the same as on Wire

That’s it! I found the default address in the PIR documentation and added it to the pir.begin argument

 if (pir.begin(0x12,Wire1) == false) {
    Serial.println("Device did not acknowledge! Freezing.");
    while (1);
  }

It works fine now. Thanks

I tried all the combinations to connect the Arduino 4 UNO WIFI to the Quad Relay code SparkFun Example2 following

the recent post for a PIR unit, but none seemed to work for the Quad Relay whether using Wire or Wire1…

As previously noted, code works great with a UNO 3.

It appears the Quad Relay library is hard coded to Wire.

If you manually change the library to Wire1 it will probably work.

SparkFun will need to update the library for the UNO R4 WiFi

Unfortunately it does not work with Wire either by using the external SDA SCL pins either. I will wait for SparkFun to update that library. Let me know when that happens. Thanks

jmp7:
Unfortunately it does not work with Wire either by using the external SDA SCL pins either. I will wait for SparkFun to update that library. Let me know when that happens. Thanks

Is the Quad Relay 5v tolerant on the I2C bus?

The UNO R4 WiFi is 5V on the pins and they have only level shifted the QWIIC connector to 3.3V.

I don’t have one of the Quad Relays to test, but this might work after looking at the example code…

#include <Wire.h>
#include "SparkFun_Qwiic_Relay.h"

#define RELAY_ADDR 0x6D
Qwiic_Relay quadRelay(RELAY_ADDR);

void setup()
{
  Wire1.begin(); 
  quadRelay.begin(Wire1);
}
void loop()
{
}

Or you may have to use…

quadRelay.begin(&Wire1);

…with the “&”

You will also have to adjust the address if you have changed from the default.

May be worth a try?

Thank you for your thoughts. Your suggestion did not work. Tried Wire and Wire1, switching from the pins to the connector. Still nothing. Program executes the code but no output.

Tried “&” but got a compiling error. Relay still works fine using the UNO R3, but not the Arduino 4.

//I got the SparkFun Quad Relay COM-16566 to work on the Arduino 4 WIFI by following the Arduino 4 Cheat Sheet whereas:

#include <Wire.h>

void setup()

{Wire1.begin();}

void loop()

{ Wire1.beginTransmission(109) ; //109 being the device address or 0x6D

Wire1.write(byte(0x01)); //Where 0x01 is the first relay, 0x02 the second relay and so on. Each write statement toggles relay on or off. 0x0A all off. 0x0B all on.

Wire1.endTransmission();}