Showing results for 
Search instead for 
Did you mean: 

Why can't get adress of 2x16 LCD in Cube IDE?

Associate III

Hi every one. I am using STM32-F401RE, 2x16 LCD with I2C integrate, i connect SCL-SDA-Vcc and GND each other (board and LCD), i tried to make scann program to know adress of LCD in this way:

#include "main.h"

#include "stdio.h"

I2C_HandleTypeDef hi2c1;

UART_HandleTypeDef huart1;

uint8_t Buffer[25] = {0};

uint8_t Space[] = " - ";

uint8_t StartMSG[] = "Starting I2C Scanning: \r\n";

uint8_t EndMSG[] = "Done! \r\n\r\n";

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_I2C1_Init(void);

static void MX_USART1_UART_Init(void);

int main(void)


  uint8_t i = 0, ret;







  /*-[ I2C Bus Scanning ]-*/

  HAL_UART_Transmit(&huart1, StartMSG, sizeof(StartMSG), 10000);

  for(i=1; i<128; i++)


    ret = HAL_I2C_IsDeviceReady(&hi2c1, (uint16_t)(i<<1), 3, 5);

    if (ret != HAL_OK) /* No ACK Received At That Address */


      HAL_UART_Transmit(&huart1, Space, sizeof(Space), 10000);


    else if(ret == HAL_OK)


      sprintf(Buffer, "0x%X", i);

      HAL_UART_Transmit(&huart1, Buffer, sizeof(Buffer), 10000);



  HAL_UART_Transmit(&huart1, EndMSG, sizeof(EndMSG), 10000);

  /*--[ Scanning Done ]--*/

  while (1)




but no adress i saw. If i use LCD with Arduino Mega board i am able to see the 0x27 adress of LCD. I used also all the pins avaiable on F401RE board for SCL and SDA comunication but never i see the adress of LCD.

Have some one idea how i can get it(adress of LCD)?


the lcd working , i use it with arduino better than Nucleo board