Skip to main content
Associate III
March 24, 2025
Question

Trialstand: External Accelerometer with STM32F411CEU

  • March 24, 2025
  • 11 replies
  • 1702 views

F. U. I.:

 

I would like to read sensor data from my accelerometer (MPU 6050) with the I²C-protocol.

My aim is to present the sensor data on my laptop via /dev/ttyUSB0, but no data reached my USB TO TTL-Adapter.

Attached you will find the code snippet and a photo.

 

(1)

I get no sensor data via I²C to my STM32F411.

What is wrong there?

The init-functions seems to be right, but the I2C_byteRead() gives no data back.

(2)

I would like to send my sensor data to PA2 (USART2, TX).

How can I realize this per code?

 

Thank's a lot.

 

Greetings

TIMBO

#

 

This topic has been closed for replies.

11 replies

Andrew Neil
Super User
March 24, 2025

@timbo2023 wrote:

(1) I get no sensor data via I²C to my STM32F411.

What is wrong there?


What debugging have you done to find what's wrong?

Have you looked at the I2C lines with an oscilloscope and/or logic analyser to see what's happening?

 

How to write your question to maximize your chances to find a solution

 

PS:

what is "Trialstand" ?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
timbo2023Author
Associate III
March 24, 2025

Hi there,

 

(1) OpenOCD

(2) No possibility - I only check if the data is empty with the glim of my onboard LED (PC13).

 

Could you check the I2C Code?

Do I forgot the right memory addresses?
How I reach the data @ (PA2) USB to TTL?

 

Greetings

TIMBO

 

Andrew Neil
Super User
March 24, 2025

@timbo2023 wrote:

(1) OpenOCD


That's just a tool - what have you actually done with it?

This is not a pure software problem - the hardware is an essential part of the system!

That's why you need to be able to see what's happening in the hardware.

And you also need to show your schematic.

Cheap logic analysers are available on the likes ebay, amazon, et al ...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
timbo2023Author
Associate III
March 24, 2025

OPINION CHECK WISHED...

LA1010 USB Logic Analyzer?!?

Andrew Neil
Super User
March 24, 2025

You'll also want something that can show you what's happening in the analogue domain.
In particular, that will show if your pullups are correct:

AndrewNeil_3-1742814541358.png

See: https://electronics.stackexchange.com/a/473799 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
timbo2023Author
Associate III
March 24, 2025

I do not understand...

Andrew Neil
Super User
March 24, 2025

A logic analyser will only show you 0/1 logic levels - so it assumes that your signal is clean & correct in the analogue domain.

If you've got "analogue" problems (such as missing/incorrect pullups on I2C), a logic analyser isn't going to help.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
timbo2023Author
Associate III
March 24, 2025

 

The problem lies code-snippet side....

Andrew Neil
Super User
March 24, 2025

How do you know that?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
timbo2023Author
Associate III
March 24, 2025

In my opinion it is a failure with the while()-loops in the function I2C1_byteRead.

Do you know an alternative?

It should start with

while(I2C1->SR2 & 2);

// wait until bus is not busy....