To read two sensor values with i2c
I'm trying to get the sensor value with stm32
Maybe because I connected the board to one i2c and attached two sensors, the value didn't change
Most people use cereal, but I only use C, so I have to use HAL
The sensor that allows you to read only one is HTU21
I'm doing this and that, but I only got 01 00 00 00 00
I think I didn't code properly, but I don't know where to fix it
I want to get the sensor value and use it as a hex value and float value, so please tell me how
uint8_t hum_addr = 0x40;
uint8_t hum_sec_addr = 0xE5;
uint8_t buf[5] = {0x01, 0x00 };
uint8_t R_buffer1[5] = {0x01, 0x00 };
uint8_t R_buffer2[5] = {0x00, 0x00 };
HAL_StatusTypeDef ret;
//ret = HAL_I2C_Master_Transmit_IT(&hi2c1, (uint16_t)hum_addr, (uint8_t*)R_buffer1, 2);
//ret = HAL_I2C_Master_Receive_IT(&hi2c1, (uint16_t)hum_addr, (uint8_t*)R_buffer2, 2);
ret = HAL_I2C_Mem_Read_IT(&hi2c1, (uint16_t)(hum_addr << 1), hum_sec_addr, 1, R_buffer2, 5);
for(int i = 0; i < 5; i++){
printf("%02X ", R_buffer2[i]);
}
printf("\n\r");Humidity sensor datasheet
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/HTU21D.pdf
Humidity sensors are connected to SD0, SC1 via i2c

