Did the following steps just to test if my temperature sensor HTU2X is working or not.
Selected my board (Nucleo-64 STM32F411RE) from STM32CubeIDE then enabled I2C1 which in turn enabled pins PB6 (as the SCL) and PB7 (as the SDA) as in the screenshot below, then saved the project.

Then added code below:
I2C_HandleTypeDef hi2c1;
UART_HandleTypeDef huart2;
void I2C1_Scan()
{
char msg[32];
for (uint8_t addr7 = 0; addr7 <= 127; addr7++)
{
uint16_t addr8 = addr7 << 1; // what HAL expects
if (HAL_I2C_IsDeviceReady(&hi2c1, addr8, 2, 1000) == HAL_OK)
{
// print in both 7-bit and 8-bit forms to avoid confusion
snprintf(msg, sizeof(msg), "Found: 0x%02X (7b), 0x%02X (8b)\r\n", addr7, addr8);
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
}
}
HAL_UART_Transmit(&huart2, (uint8_t*)"No match!\r\n", 12, HAL_MAX_DELAY);
}
// ...
int main() {
// ...
HAL_Delay(100); // give power and peripherals time to settle
I2C1_Scan();
while(1) {
//...
I get "No match!". Any idea where the problem is and how to fix it?


