cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L053 I2C problems with LIS3DH sensor

JJavi
Associate II

Hi,

I'm trying to recover the data from the LIS3DH sensor and I found this tutorial " https://www.youtube.com/watch?v=A1CIOUZdeR4". In the tutorial the person uses function " if(HAL_I2C_IsDeviceReady(&hi2c1,SLAVEI2C_ADD,10,100)==HAL_OK) " to see if the sensor is ready for use. However when I make the connections and run the program, I don'tsee anything, I do not know if you can give me some advice. 

I connected the sensor as follows:

Sensor STM32

SDA -> SDA/D14

SCL -> SCL/D15

SDO -> 3.3v

GND -> GND

Vcc -> 3.3v

#include "main.h"
 
I2C_HandleTypeDef hi2c1;
 
#define SLAVEI2C_ADD 0x19
 
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
 
int main(void)
{
 
  HAL_Init();
 
  SystemClock_Config();
 
  MX_GPIO_Init();
  MX_I2C1_Init();
 
	
HAL_Delay(1000);
		if(HAL_I2C_IsDeviceReady(&hi2c1,SLAVEI2C_ADD,10,100)==HAL_OK)
{
	HAL_GPIO_TogglePin(GPIOA,GPIO_PIN_5);
}
 
  while (1)
  {
 
  }
 
}

0690X000006DavhQAC.png

I want to recover the aceleration but i can't do a simple step..... Someone could help me???

11 REPLIES 11
SDong.3
Associate

I am new to STM32 programming as well. But I believe you need to shift your device address to the left by one bit for the function to add RW bit.

Hi JJavi, 

Im working on a project involving a stm32l433cct6 microchip with a lis3dh over i2c. I believe i have similar problem as you. Could you please post your solution on this page if thats ok, that would help me alot. 

 

Thanks!