cancel
Showing results for 
Search instead for 
Did you mean: 

First project with Nucleo-F401RE. Trying to interface to a ***-45. Regardless of what I do I get multiple HAL errors.

GLeMu.1
Associate II
 
8 REPLIES 8
Foued_KH
ST Employee

Hello @GLeMu.1​ ,

Could you please share more details about your project?

which type of errors ?

Foued

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.

GLeMu.1
Associate II

for some reason the device I mentioned is not showing up ***-45 (Sam Harris Today-45). In the code snippet below I print the error text (using Putty) if the ret value does not equal the constant. In this case HAL_I2C_ERROR_DMA_PARAM is not valid. I do not get an an error only for HAL_I2C_ERROR_ARLO. Get no errors or warnings when I compile. Does NOT matter if the SDA and SCL are connected.

 /* USER CODE BEGIN WHILE */

 while (1)

 {

// strcpy((char*)buf, "entered while\r\n");

//        HAL_UART_Transmit(&huart2, uint16_t)buf, strlen((char*)buf), HAL_MAX_DELAY);

  // Tell TMP102 that we want to read from the temperature register

  buf[0] = SHT45_SERIAL;

  ret = HAL_I2C_Master_Transmit(&hi2c1, SHT45_ADDR, buf, 1, HAL_MAX_DELAY);

  if ( ret != HAL_I2C_ERROR_DMA_PARAM) {

   strcpy((char*)buf, "Error Tx\r\n");

Foued_KH
ST Employee

If you want to read data from temperature register, you can try :

HAL_I2C_Mem_Read()

DevAddress Target device address: The device 7 bits address value in datasheet must be shifted to the left before calling the interface

MemAddress Internal memory address

MemAddSize Size of internal memory address

pData Pointer to data buffer

Size Amount of data to be sent

Timeout Timeout duration

So, for your case you can try :

  ret = HAL_I2C_Master_Transmit(&hi2c1, SHT45_ADDR, buf, 1, HAL_MAX_DELAY);
  if ( ret !=HAL_OK )
 {
   strcpy((char*)buf, "Error Tx\r\n");
}

Foued

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.

GLeMu.1
Associate II

Before I do the read, I believe the command has to be set. Your _Transmit code is the same as I sent. I have tried to shift and not shift the bit in the SHT45 address.

/* USER CODE BEGIN PV */

static const uint16_t SHT45_ADDR = 0x44 << 1; // Use 8-bit address

static const uint8_t SHT45_SERIAL = 0x89;

/* USER CODE END PV */

GLeMu.1
Associate II

I also ordered a TMP102 and SHT45 eval board. Once I get them, I may reach out to the Person who created a you tube video with the TMP102 device. https://www.digikey.com/en/maker/videos/shawn-hymel/getting-started-with-stm32-and-nucleo-part-2-how-to-use-i2c-to-read-temperature-sensor-tmp102

If you want to read data from register, you only just need to try this function :

HAL_I2C_Mem_Read()

Foued

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.

I recommend you to follow properly the steps as described in this wiki page : Getting started with I2C - stm32mcu

Foued

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.

GLeMu.1
Associate II

Thanks,

I will read the WIKI and try the read only.