RAK3172LP-SiP I2C Timing

Hi,

I’ve been trying to connect to an external I2C eeprom memory using the Wire library in Arduino.

This is my hardware configuration:
SCL → PA12
SDA → PA11
I2C pull up → 2K2

This is my code:

RUI version 4.2.0

#include <Arduino.h>
#include <Wire.h>


#define I2C_ADDR                0x55


bool halI2c_Read (uint8_t addr, uint8_t regAddr, uint8_t *data, size_t size)
{
    Wire.beginTransmission(addr);
    Wire.write(regAddr);
    Wire.endTransmission(false);

    size_t bytesToRead = Wire.requestFrom (addr, size);

    if ( 0 == bytesToRead || bytesToRead != size )
    {
        Serial.printf("Error reading... expected: %d and available %d\r\n", size, bytesToRead);
        return false;
    }

    size_t bytesRead = Wire.readBytes(data, bytesToRead);

    if ( bytesRead != bytesToRead )
    {
        Serial.printf("Error! Read %d and requested %d", bytesRead, bytesToRead);
    }

    return ( bytesRead == bytesToRead ) ? true : false;
}

bool halEeprom_Id (void)
{
    uint8_t id;

    bool rc = halI2c_Read(I2C_ADDR, 0, &id, 1);

    if ( true == rc && 0x04 == id )
    {
        Serial.println("Eeprom detected!");

        rc = true;
    }
    else
    {
        Serial.println("Eeprom not detected !!!!!!!");

        rc = false;
    }

    return rc;
}

void setup() 
{
    Serial.begin(115200);
    Wire.begin();
    Wire.setClock(100000);
}

void loop() 
{
    delay(1000);

    bool detected = halEeprom_Id();

    if ( true == detected )
    {
        Serial.println("NFC detected!");
    }
    else
    {
        Serial.println("NFC not detected");
    }
}

The code doesn’t detect the external eeprom. I’ve checked it with an ESP32, using the same code, and it’s working, so I checked with the scope the SCL signal

This is the SCL signal with the RAK3172LP-SiP

This is the SCL signal with the ESP32

The clock is not generated correctly in the RAK3172.
I’m sure I’m doing something wrong, but I cannot see what.
Anyone could help me.
Thank you

Regards,
David

Hi @dbagan ,

I am not sure what I2C eeprom you use but some ideas I have.

  1. Can you double check if you selected RAK3172LP-SiP on the board selection in your Arduino IDE when you compile/upload?
  2. Can you try to test basic on-off even using simple delays on the SCL pin? Also SDA pin if it behaves strange as well.
  3. Can you try to remove setting up the speed? Wire.setClock(100000);