Something odd with I2C & Xiao

I’m testing some code for a digital pot. End goal is to add the digital pot to a Xiao project that is using other sensors with I2C successfully.
Current test setup is just the Xiao and the I2C digital pot. Problem is this code will not run with Xiao (or QT Py) but runs fine with a Uno.
By not run I mean, does not control the digital pot and returns an error at Wire.endTransmission() also my I2C ID program does not see the digital pot when connected via Xiao but sees it via Uno

Something is going wrong but don’t know what. You ideas appreciated.

Using library Wire at version 1.0 in folder: C:\Users\User\Documents\ArduinoData\packages\Seeeduino\hardware\samd\1.8.1\libraries\Wire

include <Wire.h>
byte potPos=0x00;

//-----------------------------------------------------------------------
// I2C to digital pot
//-----------------------------------------------------------------------

void sendToPot(byte pos)
{
pos=0x7f-pos;
Wire.beginTransmission(0x2f); // 0x2f is digiPot I2C address
Wire.write(byte(0));
Wire.write(pos); // sends potentiometer value byte

int err = Wire.endTransmission();       // stop transmitting
if(err)  
{
  Serial.print("ERR=");
  Serial.println(err);
}

}

//-----------------------------------------
//
//-----------------------------------------

void loop()
{
Serial.println(potPos);

sendToPot(potPos);

if(potPos<0x7f)
potPos++;
else
potPos=0;
delay(1000);
}

//-----------------------------------------
//
//-----------------------------------------

void setup()
{
Serial.begin(115200);
delay(2000);

Wire.begin();

Serial.println(“Digital pot test”);
}

may take a look at source code for this device ATH20.cpp
a portion is quoted below

// ATH20 ARDUINO LIBRARY
#include “ATH20.H”

void ATH20::begin()
{
Wire.begin();

Wire.beginTransmission(0x38); // transmit to device #8
Wire.write(0xBE);
Wire.endTransmission();    // stop transmitting

}

bool ATH20::startSensor()
{
Wire.beginTransmission(0x38); // transmit to device #8
Wire.write(0xac);
Wire.write(0x33);
Wire.write(0x00);
Wire.endTransmission(); // stop transmitting

unsigned long timer_s = millis();
while(1)
{
    if(millis()-timer_s > 200) return 0;        // time out
    Wire.requestFrom(0x38, 1);

    while(Wire.available())
    {
        unsigned char c = Wire.read();
        if(c&0x80 != 0)return 1;      // busy

    }

    delay(20);
}

}

bool ATH20::getSensor(float *h, float *t)
{
startSensor();
Wire.requestFrom(0x38, 6);

unsigned char str[6];
int index = 0;
while (Wire.available())
{
    str[index++] = Wire.read(); // receive a byte as character
}

if(str[0] & 0x80)return 0;

unsigned long __humi = 0;
unsigned long __temp = 0;

__humi = str[1];
__humi <<= 8;
__humi += str[2];
__humi <<= 4;
__humi += str[3] >> 4;

*h = (float)__humi/1048576.0;

__temp = str[3]&0x0f;
__temp <<=8;
__temp += str[4];
__temp <<=8;
__temp += str[5];

*t = (float)__temp/1048576.0*200.0-50.0;

return 1;

}

Thank you for trying to help.
It’s not a question on how to write the code to communicate via I2C. The code I posted works fine with a Uno microcontroller. The issue is why does the same code not work at all with the Xiao. I seem to have the correct library and the wiring is correct for the Xiao. all in all pretty straightforward but still no joy.

Hi there,
So which board files are you using?
What Verbose compiler output do you get?
HTH
GL:-) PJ

Verbose compiler output is 210K, above the max I can post here. Something specific you’d like to see. The Wire.h used is posted above,
What do you mean by – board files, Seeeduino Xiao is selected as board

Ah’ I see Seeeduino Xiao…

Pullups my friends, pullups.