Showing results for 
Search instead for 
Did you mean: 

AMS5812 I2C Sensor Holding I2C3 Bus on STM32F407G-DISC1

Associate II

I am trying to implement LCD and AMS5812 Sensor on I2C3 Bus,

But AMS5812 I2C sensor is holding the I2C bus and preventing further scanning STM32F407G Discovery board.


  /*-[ I2C Bus Scanning ]-*/
	     HAL_UART_Transmit(&huart2, (uint8_t *)StartMSG, sizeof(StartMSG), 10000);
	     for(i=1; i<128; i++)
	         ret = HAL_I2C_IsDeviceReady(&hi2c3, (uint16_t)(i<<1), 3, 5);
	         if (ret != HAL_OK) /* No ACK Received At That Address */
	             HAL_UART_Transmit(&huart2, (uint8_t *)Space, sizeof(Space), 10000);
	         else if(ret == HAL_OK)
	             sprintf(Buffer, "0x%X", i);
	             HAL_UART_Transmit(&huart2, (uint8_t *)Buffer, sizeof(Buffer), 10000);
	     HAL_UART_Transmit(&huart2, (uint8_t *)EndMSG, sizeof(EndMSG), 10000);
	     /*--[ Scanning Done ]--*/


AMS5812 sensor is working on 5V and i2c LCD is also working on 5V. i am using 5V to 3V level shifter as below.

first time i2c Scanning code detect lcd address as 0x27 and then blank.

Expected 0x27 and 0x78 




I have tried using 3.1K pull up resistors but no benefit on both the sides of level shifter.



Please advise where i could be wrong ?

Senior II

Your converter also needs supply voltage and GND

LV = 3V, HV=5V, GND = GND

Senior III

Hello @asking 

Can you add your code to take a look on it. Also, can you try using just the LCD.

Best regards.


Yes, only LCD works fine. also other I2C Devices like SM Pressure sensors works fine. Only problem is AMS5812 when i put on bus. No further scanning only - - - - .

Core is simple I2C Discovery code. i have enabled I2C3 with 400000HZ Fast Mode.

Yes i have connected LV to 3V, HV to 5V and GND to System GND Common for all systems.

Can you try using another I2C 

Yes, i will try another i2c bus and update.

ST Employee

Hello @asking , 

The silver dot on the AMS 5812 marks the location of Pin 1. The AMS 5812 pinout is:

  • Pin 2: Ground
  • Pin 4: SDA
  • Pin 5: SCL
  • Pin 7: VCC, this should be a 4.75V to 5.25V power source.

4.7 kOhm resistors should be used as pullups on SDA and SCL, these resistors should pullup with a 5V source.




To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Yes i have double checked the connection. now trying with scope on I2C Bus....

Associate II

SCL / SDA on Scope. Below Observations.

With AMS5812 Sensor, Peak is curved.

Yellow is SDA and Violet is SCL


Without AMS5812 Sensor. I2C Scanner works fine.