MKR IoT Carrier and Wire.h are compatible?

Strange behaviour of following same sketch:

// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this
// Created 29 March 2006

//Modified June2022 by Andrea Pagliari
//To use LCD Screen on Arduino Iot MKR and MKR Wifi1010


//**Wire
#include <Wire.h>
//EndOfWire**

//**MKRIotCarrier
int ScreenSwitch = 1;
//#include <Arduino_MKRIoTCarrier.h>
/* Create a carrier object */
//MKRIoTCarrier carrier;
//EndOf **MKRIotCarrier


void setup()
{
  //**Wire
  Wire.begin(0x40);  // join i2c bus with address 0x40 which is the address the master send data to
  digitalWrite(SDA, 0);//added to disable internal pull up resistors
  digitalWrite(SCL, 0);//added to disable internal pull up resistors
  Wire.onReceive(receiveEvent); // register event
  //EndOfWire**

  //Initialize the MKR IoT Carrier
  /*carrier.begin();
    carrier.display.setRotation(0);
    carrier.display.enableDisplay(1);*/

  //**SerialDebug
  Serial.begin(9600);           // start serial for debug output
  //EndOfSerialDebug**

}

void loop()
{
  delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  Serial.print("EventRECEIVED");// debug
  int x = Wire.read();    // receive byte as an integer
  /* carrier.display.fillScreen(ST77XX_RED); //red background
    carrier.display.setTextColor(ST77XX_WHITE); //white text
    carrier.display.setTextSize(6); //medium sized text
    carrier.display.setCursor(80, 100); //sets position for printing (x and y)
    carrier.display.print(x); // print the integer*/
  Serial.print("Speed=");
  Serial.println(x);         // print the integer

}

This way it perfectly works as i2c slave receiver.
As soon as I uncomment the MKR IoT part as following:

// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this
// Created 29 March 2006

//Modified June2022 by Andrea Pagliari
//To use LCD Screen on Arduino Iot MKR and MKR Wifi1010


//**Wire
#include <Wire.h>
//EndOfWire**

//**MKRIotCarrier
int ScreenSwitch = 1;
#include <Arduino_MKRIoTCarrier.h>
/* Create a carrier object */
MKRIoTCarrier carrier;
//EndOf **MKRIotCarrier


void setup()
{
  //**Wire
  Wire.begin(0x40);  // join i2c bus with address 0x40 which is the address the master send data to
  digitalWrite(SDA, 0);//added to disable internal pull up resistors
  digitalWrite(SCL, 0);//added to disable internal pull up resistors
  Wire.onReceive(receiveEvent); // register event
  //EndOfWire**

  //Initialize the MKR IoT Carrier
  carrier.begin();
  carrier.display.setRotation(0);
  carrier.display.enableDisplay(1);

  //**SerialDebug
  Serial.begin(9600);           // start serial for debug output
  //EndOfSerialDebug**

}

void loop()
{
  delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
  Serial.print("EventRECEIVED");// debug
  int x = Wire.read();    // receive byte as an integer
  carrier.display.fillScreen(ST77XX_RED); //red background
  carrier.display.setTextColor(ST77XX_WHITE); //white text
  carrier.display.setTextSize(6); //medium sized text
  carrier.display.setCursor(80, 100); //sets position for printing (x and y)
  carrier.display.print(x); // print the integer
  Serial.print("Speed=");
  Serial.println(x);         // print the integer

}

..it stops working as I2c slave receiver and didn't get any data.

Has someone already faced this strange behaviour of I2c in combination with MKR Iot Carrier with MKR WiFi1010?
Thanks a lot for your support.

BR
Andrea

Is this the question as: I2c between two arduino mkr wifi1010 not working ?

Hi Koepel, as you can read this question is more specific and related to 2 specific Arduino products:
a)MKR Iot Carrier and the second
b) MKR Wifi 1010.

Do you have an actionable answer here?

Do you precisely know the MKR Iot Carrier architecture, its relationship with the <Arduino_MKRIoTCarrier.h> library and the impacts on the Wire.h library? If yes, really interested in your specific guidance.

Everything is online.
The MKR IoT Carrier board: https://store.arduino.cc/products/arduino-mkr-iot-carrier
Also a schematic is provided.

Take a step back.
Run a I2C Scanner sketch to find all the sensors on the Carrier board.
Then you also know if 0x40 is already taken.
Then try to include the *.h file, then call begin, then read the sources of the Carrier library.

Some boards do not work if the power was not turned on for the I2C bus. I forgot for which board is was, sorry.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.