cancel
Showing results for 
Search instead for 
Did you mean: 

Why HAL_I2C_Mem_Read returns only 0?

ATavo.1
Associate III

Hi,

I am using stm32f1 and HUT21D sensor (Temperature and humidity sensor). The sensor use i2c for communication.

I am using IAR and cubeMX.

For cube: I used default setting for i2c.

For IAR: I shared the main.c below.

Can anyone help on why only get 0.

#I2C​ #[STM32 MCUs]​ 

12 REPLIES 12

I have a question. Sometimes I get HAL_OK and Sometimes I get HAL_Error. Is the problem with wires or not? I can't find why?

It could be the wires but 10cm is still a human distance. Did you measure with an oscilloscope SDA and SCL? Are the waveforms clean?

ATavo.1
Associate III

It seems that one the capacitors was not correctly soldered and it change the ground. it works for now.

Thnx everyone.