Two Argons Communicating over I2C

I’m using the following sets of code for two Argons connected via I2C:

device 1 code:

void setup() {
  Serial.begin(115200);
  Wire.begin();
}
void loop() {
  Wire.requestFrom(4, 4);
  while(Wire.available()> 0){
    char c = Wire.read();
    Serial.println(c);
  }
  delay(100);
}

Device 2 with code:

void test(){
  Wire.write("test");
}

void setup() {
  Wire.begin(4);
  Wire.onRequest(test); 
}

I had hooked up a pair of photons in this way and had results. But now that I’m using Argons, nothing appears to be getting printed to the SerialPort. Is there some change to I2C between Gen2 and Gen3?

I set up a pair of photons on a breadboard with this code and it worked fine. So it must have been an issue with the setup I had the argons in, likely a poor choice of pullup resistors. I’ll mark this concluded.

We have found out that the Gen3 Devices have 13k pullups on the I2C lines already.

This causes issues with devices when this is not known and you add your own pull up resistors or mutiple devices with their own pullups.

So I was able to get everything working as expected using Wire1 and pullup resistors. But the buffer size was 32 bytes and I’ll need more. I had previously used the following code to increase buffer size per the documentation but this didn’t seem to work on Wire1 on the Argons:

constexpr size_t I2C_BUFFER_SIZE = 1024;

HAL_I2C_Config acquireWireBuffer() {
    HAL_I2C_Config config = {
        .size = sizeof(HAL_I2C_Config),
        .version = HAL_I2C_CONFIG_VERSION_1,
        .rx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_SIZE],
        .rx_buffer_size = I2C_BUFFER_SIZE,
        .tx_buffer = new (std::nothrow) uint8_t[I2C_BUFFER_SIZE],
        .tx_buffer_size = I2C_BUFFER_SIZE
    };
    return config;
}

I also tried switching back to Wire instead of Wire1 and with/without pull up resistors, and get no output.

For Wire1, you need to use acquireWire1Buffer instead of acquireWireBuffer.

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