I2C not working on STM32L476RG Nucleo

I am trying to use three I2C sensors, namely BMX160, HTS221 and MS5837-30BA with an STM32L476RG Nucleo.

I tried working with the last two sensors using the following libraries:

  1. HTS221 - Capacitive digital sensor for relative humidity a… | Mbed
  2. AUV_MS5837_30BA_WRCE_TSD - Updated MS5837 Library to add support for the MS5… | Mbed

I connected the SCL and SDA lines to D15 and D14 (also tried with A5 and A4).

For both sensors, I get erroneous readings on the serial monitor, even when no sensor is connected for both I2C configurations. I checked for sensor errors with an Arduino but the sensors work fine with an Arduino. Note that the first library is from the sensor manufacturer itself. Here are some code snippets:
Temperature Sensor:

#include "mbed.h"
#include "platform/mbed_thread.h"
#include "HTS221Sensor.h"

static DevI2C devI2c(PB_9,PB_8); //declare devi2c object
static HTS221Sensor hum_temp(&devI2c); //declare hts221 object
Serial pc(USBTX, USBRX);

int main()
{
    pc.baud(9600);
    uint8_t id;
    float temp, hum;
    hum_temp.init(NULL); //initialize the sensor
    hum_temp.enable(); //enable the sensor
    hum_temp.read_id(&id);
    pc.printf("HTS221  humidity & temperature    = 0x%X\r\n", id);

    while (true) {
        hum_temp.get_temperature(&temp);
        hum_temp.get_humidity(&hum);
        pc.printf("HTS221:  [temp] %.2f C, [hum]   %.2f%%\r\n", temp, hum);
        thread_sleep_for(500);
    }
}

Pressure Sensor:

    #include "mbed.h"
    #include "platform/mbed_thread.h"
    #include "MS5837.h"
    using namespace std;

    Serial pc(USBTX, USBRX);

    int main()
    {
        pc.baud(9600);
        MS5837 small_sensor = MS5837(PC_1, PC_0, ms5837_addr_no_CS);
        small_sensor.MS5837Init();
        float pressure_small;
        float temp_small;

        while (true) {
            small_sensor.Barometer_MS5837();
            pressure_small = small_sensor.MS5837_Pressure();
            temp_small = small_sensor.MS5837_Temperature();
            pc.printf("Small Sensor Pressure: %f\n", pressure_small);
            pc.printf("Small Sensor Temperature: %f\n\n", temp_small);
        }
    }

I am quite sure something fishy is going on with the I2C ports. I ran a small I2C scanner sketch compiled for the Nucleo board using Arduino IDE and it can’t find any I2C device at all on both the I2C ports.

Any idea what’s happening?

Have you added pull up resistors to the SCL and SDA (4k7 ohm)?
I use the L476, but did notice some issues connecting more that one device on the same i2c bus since OS5 where it was working fine on OS2.

Ya I noticed yesterday that was the problem. Then used 2.2k resistors on the SCL and SDA lines. It serves as a warning for those of us used to Arduino, which has internal pullups.