Nucleo + SHT45 NACK Issue

Thread Starter

averiksen

Joined Jul 10, 2025
3
I needed a very small humidity sensor, so I made a PCB for the Sensirion SHT45. I interface it with a Nucleo-32 F303K8, and have tried a Nucleo 64 as well. It seems that I'm able to send commands to it, but when I try to read it, I receive only NACKs from the sensor. This behaviour could be because of a busy sensor, but I add enough time in between measurement request and reading that it should not be a problem.

I tried a few chips. The first ones I soldered with an iron, then I tried hot air, most recently hot air from bottom of PCB, to shield the chip and especially its PTFE membrane from the heat of the air. I wonder if solder heat could have broken the sensor in a way where it will respond to I2C, but the sensing element might be broken.

I use CubeIDE, I2C standard default settings.

// Buffer to store RX data
uint8_t buffer[6] = {};

// Request High Precision reading - no error
if(HAL_I2C_Master_Transmit(&hi2c1, (uint16_t)(0x44 << 1),(uint8_t *)0xFD,1, 1) != HAL_OK){
uint8_t dummy = 1;
}

HAL_Delay(200); //have tried delays of 20, 50, 100 and 200 ms

// Reading sensor - always get NACK from sensor, hi2c1 errorcode 4 (NACK error)
HAL_StatusTypeDef ret = HAL_I2C_Master_Receive(&hi2c1, (uint16_t)(0x44 << 1), buffer, 6, 1);

while(ret != HAL_OK) {
ret = HAL_I2C_Master_Receive(&hi2c1, (uint16_t)(0x44 << 1), buffer, 6, 1);
}

HAL_Delay(20);

I use 2.2K pull up resistors, and very short soldered wires in my test setup.

averiksen_1-1754488041718.png
 

MrChips

Joined Oct 2, 2009
34,626
When writing code for I2C for the first time, it helps to test one thing at a time.
Do you have access to an oscilloscope?
 

Thread Starter

averiksen

Joined Jul 10, 2025
3
When writing code for I2C for the first time, it helps to test one thing at a time.
Do you have access to an oscilloscope?
I probed the datalines. When transmitting the command to make the measurement, the waveform looks as one would expect, with device address, command byte and ACKs and so fourth. The command to receive gets a NACK from the sensor though.

I have ordered a cheap SHT45 board form aliexpress, which hopefully is going to answer the question as to whether the code and µController side of things are working.
 

MrChips

Joined Oct 2, 2009
34,626
I think I have Sensirion SHT45 sensors and STM32 boards. I could possibly duplicate your setup, time permitting.
 

Thread Starter

averiksen

Joined Jul 10, 2025
3
I think I had a breakthrough - I increased the timeout to HAL_MAX_DELAY as suggested by @henriquehacl, and I think it did the trick, I get readings now. I had this timeout before, but with different boards. I will look further into it and post an update for others to look at if they run into the same issue. Thank you very much everyone.
 
Top