I2C communication between Nano and Duo


#1

Hi there!
I’m trying to make a Nano v2 to communicate with a Duo through I2C. I’ve been able to make two Duo communicate with each other but I’ve no clue about what’s going on when I try to make the Nano write on the I2C bus. You can find the Duo and Nano code below.

Nano:

#include <Wire.h>

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  Wire.begin();
  Serial.println("master write...");
}

byte x = 0;

void loop() {
  int error;
  // put your main code here, to run repeatedly:
  Serial.println("master send begin: ");

  Wire.beginTransmission(0x08);
  Wire.write(x);
  error = Wire.endTransmission();
  Serial.println(error);

  x++;
  delay(1000);
}

Duo:

#include <Wire.h>

/*BLE and WiFi setup*/
#if defined(ARDUINO)
SYSTEM_MODE(MANUAL);
#endif

void setup() {
  Wire.begin();        // join i2c bus (address optional for master)
  Serial1.begin(9600);  // start serial for output
}

void loop() {
  Serial1.println("READ");
  Wire.requestFrom(0x08, 2); 

  while (Wire.available()) { // slave may send less than requested
    char c = Wire.read(); // receive a byte as character
    Serial1.print(c);         // print the character
  }

  delay(500);
}

Thanks in advance!