cancel
Showing results for 
Search instead for 
Did you mean: 

I²C communication issue between MPU6050 and STM32 (works with ESP32)

MOns1
Associate

Hello,

I am experiencing an I²C communication issue between my MPU6050 sensor and an STM32F429I-DISC1 board. The sensor is properly powered at 3.3 V, and I have already verified its operation with an ESP32 board (communication is successful). However, with the STM32, no communication is established.

Actions performed:

  • Configured I²C1 on the STM32 (tested in fast mode at 400 kHz and standard mode at 100 kHz)
  • Verified the MPU6050 address (default 0x68, AD0 pin connected to GND)
  • External pull-ups: tested with and without 4.7 kΩ resistors on SCL and SDA
  • Checked physical connections (SCL to PB6, SDA to PB7 for I²C1 on the board)
  • Configured the LCD screen

Observed behavior:

  • The I²C scan does not detect any address

Blocking point: The same sensor, using the same basic I²C code, works perfectly on the ESP32. Therefore, the sensor is not the cause. The issue appears to be related to the I²C configuration on the STM32 or a hardware detail.

Question: Has anyone encountered this behavior with an MPU6050 on STM32? Are there specific parameters to configure in the I²C interface (timing, clock stretching, or others)? Could there be an initialization sequence issue?

Thank you in advance for your assistance.

-----------------------------------------------------------------------------------------------------------------

Bonjour à tous,

Je rencontre un problème de communication I2C entre mon capteur MPU6050 et une carte STM32F429I-DISC1. Le capteur est correctement alimenté (3,3V), et j’ai déjà vérifié son bon fonctionnement avec une carte ESP32 (communication OK). Cependant, avec la STM32, aucune communication n’est établie.

Ce que j’ai fait :

  • Configuration de l’I2C1 sur la STM32 (essai en mode Fast Mode (400 kHz) et aussi en Standard Mode (100 kHz))

  • Adresse du MPU6050 vérifiée (0x68 par défaut, broche AD0 à GND)

  • Pull-ups externes ? (j’ai essayé avec et sans résistances de 4,7 kΩ sur SCL et SDA)

  • Vérification des connexions physiques (SCL → PB6, SDA → PB7 pour I2C1 sur ma carte)

  • Il y a aussi la configuration de l'écran LCD

Ce que j’observe :

  • Le scan I2C ne trouve aucune adresse

Ce qui me bloque :
Le même capteur, avec le même code I2C de base, fonctionne parfaitement sur ESP32. Donc le capteur n’est pas en cause. Le problème semble venir de la configuration I2C de la STM32 ou d’un détail matériel .

Question :
Avez-vous déjà rencontré ce genre de comportement avec un MPU6050 sur STM32 ? Y a-t-il des paramètres spécifiques à configurer dans l’I2C (timing, clock stretching, ou autre) ? Peut-être un problème de séquence d’initialisation ?

Merci d’avance pour votre aide !

------

Post Edited by ST moderator to apply source code formatting and translate from Frensh to English to comply with the community rule.

Best regards,

Gyessine

 

2 REPLIES 2
mƎALLEm
ST Employee

Hello,

Hard to tell what the problem is .. 

  • External pull-ups: tested with and without 4.7 kΩ resistors on SCL and SDA

-> you should definitely have 4.7k on SCL/SDA lines

You need to check what is going-on on the I2C lines with an oscilloscope or a logic analyzer otherwise you cannot go further ..

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.
Pavel A.
Super User

Le scan I2C ne trouve aucune adresse

Probably because the STM32 driver and ESP have different format of I2C address. For STM32 the address should be shifted left: the MSB of the address is bit #7, and bit #0 is read/write flag.