2025-01-24 12:15 PM - last edited on 2025-01-24 02:56 PM by Tesla DeLorean
What does this error mean for the I2C interface? I have it on the connection between the LORA E5 Mini and the SI7021 sensor.
The debugger stops here:
Exactly at his method call:
/* Wait until TXIS flag is set */
if (I2C_WaitOnTXISFlagUntilTimeout(hi2c, Timeout, Tickstart) != HAL_OK)
{
return HAL_ERROR;
}
As you can see, the I2C is in the HAL_I2C_STATE_READY.
I have four items of the same sensor tested with this LORA device, and all behave the same, so I think a hardware error should be excluded.
Solved! Go to Solution.
2025-01-24 01:02 PM
ErrorCode=32 indicates HAL_I2C_ERROR_TIMEOUT.
Devaddress=0 suggests an invalid slave address.
Ensure HAL_I2C_IsDeviceReady returns HAL_OK before using any other HAL_I2C_* command.
2025-01-24 01:02 PM
ErrorCode=32 indicates HAL_I2C_ERROR_TIMEOUT.
Devaddress=0 suggests an invalid slave address.
Ensure HAL_I2C_IsDeviceReady returns HAL_OK before using any other HAL_I2C_* command.
2025-01-24 01:46 PM
I2C doesn't see device:
According to the MX configuration, I2C3 has the following GPIO:
According to the WIO Lora E5 Mini wiki, I see that these pins are
PCO => RX1
PB14 => MISO
The Green LED on the SI7021 fires.
I checked the connections between LORA and this sensor many times, and all look good.
The ST-LINK V2 is attached to the LORA device too.
2025-01-24 01:52 PM
Do you have external pullups on the SDA/SCL lines?
2025-01-24 02:11 PM
That board is clearly labeled with SCL and SDA which is I2C2. So it's PA15 and PB15 that needs to be used.
By default when enabling I2C2, it chooses PA12 for SCL. So you override it and choose PB15 for SCL.
2025-01-24 02:46 PM - edited 2025-01-24 02:55 PM
There are 7-bits in the I2C address used, the high order bits. You should be cycling 0..127 with counter<<1 passed as the address. Address of SI7021 should be 0x80 from ST perspective (0x40 << 1)
https://www.adafruit.com/product/3251
The AdaFruit board has 10K pull-up, and a level shifter. Looks to be built on the assumption of a 5V supply/signalling. Not sure of what the regulator's going to do with 3.3V and both VCC and 3V3 need to be present. The SparkFun board is less encumbered, can find on eBay, Amazon, Mouser, DigiKey.
Enumerating what you've wired to what. Pictures help, but have to decipher colours, and placement
Would expect to need VCC,3V3,SCL,SDA,GND minimum. If providing VCC, check the voltage at 3V3 pin for drop-out
https://www.sparkfun.com/sparkfun-humidity-and-temperature-sensor-breakout-si7021.html
2025-01-24 02:47 PM - edited 2025-01-24 02:49 PM
Board has regulator, pull-ups and level shifter.
https://learn.adafruit.com/adafruit-si7021-temperature-plus-humidity-sensor/downloads
2025-01-24 03:28 PM - edited 2025-01-24 03:32 PM
@Karl Yamashita I choose I2C3, so PC0 and PB14 will the pins to connect.
But I think my LORA was destroyed, and it caused my problem. I got another LORA, and SI7021 worked with this device.
Thanks to all of you who tried to help me.
2025-01-24 03:32 PM
@TDK According to the MX documentation for this chip under the STMCubeIDE, these GPIOs (for I2C) don't need any pullups or pulldowns.
I have several sensors attached to the LORA devices without those pulls.
2025-01-24 03:36 PM
@TDKThis helped me to discover the real cause of my problem. I debugged the code and found that LORA couldn't find the sensor attached to it.