Interface MPU6050/GY-521 with STM32 || LCD 20x4 || CubeMx || HAL || SW4STM

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024
  • Purchase the Products shown in this video from :: controllerstec...
    ________________________________________________________________________________________
    type -u _printf_float in the linker flag.
    To download the code and for more explanation, goto
    controllerstec...
    Check out more VIDEOS on MODULES/SENSORS with STM32 • STM32 and SENSORS/MODULES
    ________________________________________________________________________________________
    ****** SUPPORT US BY DONATING*****
    paypal.me/cont...
    ******Join the Membership******
    / @controllerstech
    Join the Discord Server / discord
    Join the Telegram Group t.me/controlle...
    Follow me on Instagram / controllerstech
    For more info, visit www.controller...
  • НаукаНаука

Комментарии • 100

  • @egar1956
    @egar1956 3 года назад +4

    I could see the acceleration values in Live View tab. For testing purposes, it worked fine. Thanks for sharing

  • @arslankhan1058
    @arslankhan1058 13 дней назад

    In my case, one of them works at a time, either Display or MPU. What could be issue?

  • @woldecosgrove
    @woldecosgrove 4 месяца назад

    Hello, i try this on H723 Nucleo its not working at all... LCD is working but X, Y Z values are not changing...Why?

  • @tuannguyenhoanganh6982
    @tuannguyenhoanganh6982 2 года назад

    Thank you very much, you makes me clearly know how does it work.

  • @amadinsix7359
    @amadinsix7359 2 года назад +1

    Thank you very much. You just helped me alot with this video. But I have a littke problem because the values that I get are a little bit high and if I want to calculate the momentary angle, it just keep counting up. Could someone help me?

  • @ruifazhou7300
    @ruifazhou7300 4 года назад +3

    很棒!非常感谢!

  • @Mustafa-cp8wc
    @Mustafa-cp8wc 10 месяцев назад

    No value of check is being returned. Please help!

  • @ashotklekchyan
    @ashotklekchyan 5 месяцев назад

    After HAL_Init(); in main , stm32 out off order, i have test next block again chip out of order.. i am block ///HAL_Init(); every thing work correct..Thank

  • @lonny_breaux
    @lonny_breaux Год назад

    hi
    why data array Rec_Data has type uint8_t, while sum of two first numbers of this array (Rec_Data[0]

  • @Lucialunivers
    @Lucialunivers 2 года назад

    In fact you have configured the MPU6050 in one of your videos I would like to know how to get a curve from it. If you could make a small video to show how to get a curve of the gyro and acceleration parameters. Thanks

  • @anghao7050
    @anghao7050 4 года назад

    I have a problem. When I turn on USB FS and set clock 48MHz, I can't communication with I2C. please tell me why. thank you so much!

  • @jiansun6341
    @jiansun6341 4 года назад

    pay more attention to the address of mpu6050 is 0xD0 not 0x68 in HAL, otherwise it will return HAL_ERROR

  • @suleymanerdogan6271
    @suleymanerdogan6271 2 года назад

    The linker flags part does not appear at 15.38 minutes, can you help me?

    • @ControllersTech
      @ControllersTech  2 года назад +1

      In cubeIDE, you can enable it in Properties-> C/C++ Build -> Settings -> MCUSetting. You will see the checkbox there to enable it.

  • @muhammadhelmihanif9764
    @muhammadhelmihanif9764 9 месяцев назад

    hello , its very helpfull video , but do u have any suggestion if i want to get the data exactly 1K data per second ( 1 Khz ) or 500 Hz

  • @maulanawahyudi7127
    @maulanawahyudi7127 3 года назад

    Please correct me if I am wrong in a statement or otherwise, #define MPU6050_ADDR 0xD0 where the value 0xD0 is obtained from 7 bits + RW . From 7 bits (MSB) depending on pin level AD0, in this case let's say 0x68(AD0 at low level). and RW means do we want to write or read, my question is when we use "HAL_I2C_Mem_Write" do we keep using 0xD0 and not using 0xD1? Thank you sir I'm a beginner to learn STM and MPU sensors

    • @ControllersTech
      @ControllersTech  3 года назад

      The R/W bit should be 0 for write and 1 for read.
      But we don't need to worry about the read address. The HAL adds that 1 during the read operation.

    • @maulanawahyudi7127
      @maulanawahyudi7127 3 года назад

      @@ControllersTech ok sir, what if now i change the address with 0xD1 will HAL also add automatically too or will it be a problem?

    • @ControllersTech
      @ControllersTech  3 года назад

      Nope. It only takes care of receive address.

  • @ed223-p5g
    @ed223-p5g 4 года назад

    i don't know how to calculate pitch, roll and yaw please help me

  • @syahputra1770
    @syahputra1770 2 года назад

    Hi sir, may I ask for code because the link you gave you can not be accessed

  • @anbuscientist4635
    @anbuscientist4635 2 года назад

    Thank you for a very informative tutorial, I tried the same way to communicate with my accelerometer, but i can't able to get output from my port. While at compiling it shows o errors and 0 warnings and successfully deployed, but i can't able to get any output form the module. And the LD4 in ST link continues to blink from green to red, even during debugging. Can you help me to sort out the issue. And at I did step into debug, which shows variables have a value both raw and float, but if I try to print those values via putty, its not showing anything. And it seems to be like constant.

  • @jorgejacome4269
    @jorgejacome4269 4 года назад

    absolutely brilliant, thanks for all

    • @ControllersTech
      @ControllersTech  4 года назад

      Thanks for the contribution man. Really appreciate it... 👍

    • @jorgejacome4269
      @jorgejacome4269 4 года назад +2

      @@ControllersTech I always say: Left hand help right hand and both wash my face

  • @SA-ys8eg
    @SA-ys8eg 3 года назад

    can you build a reaction wheel following this code?

  • @LSUDTechTelugu
    @LSUDTechTelugu 4 года назад

    Can this be used for MPU6500(with stm32) as well or are there any register changes? has any one tried that?

  • @gopalagrawal2270
    @gopalagrawal2270 3 года назад

    I am getting the wrong values while interfacing MPU6050 Accelerometer with STM32F446RE.
    For Example for value of X, Y, Z axis as 0 , 0, 1 i am getting 0, 3.16, 1 for 0 ,1, 0 i am getting 3.16, 3.16, 0 and so on i am continuously getting this unexpected 3.16.
    i have chosen accelerometer range as +/-2g, I2C1 peripheral with Standard mode and 50% duty cycle and APB1 clock as 16MHz
    help me in getting my values correctly

    • @ControllersTech
      @ControllersTech  3 года назад

      If you are continuously getting same value, that means your configuration is not right.
      Check the calculation part for for the range you have chosen

  • @kenancanko443
    @kenancanko443 2 года назад

    Hello mate did you made second video?

  • @anghao7050
    @anghao7050 4 года назад

    thank you! I was successful.

  • @electronicsguy8609
    @electronicsguy8609 3 года назад

    Hello, thank you for the video, how can i find the part 2?, isit still in the making?

  • @tarkucar8040
    @tarkucar8040 3 года назад

    hi, I try a little to get euler angles from dmp(digital motion processor) but I couldn't do that. do you know how I can get that from easy way? any source or whatever? I will use complementary filter or mahony filter if dmp is so exhausting. thanks in advance

    • @ControllersTech
      @ControllersTech  3 года назад +1

      I didn't tried it. I tried some algorithms to stabilize the gyro, but that didn't worked. I will try it again after few days ( I am out of my workstation right now)

  • @user-ee6js5oh4n
    @user-ee6js5oh4n 2 года назад

    Excuse me, where do I go to find the header file "i2c-lcd.h" and the source file "i2c-lcd.c"?

    • @ControllersTech
      @ControllersTech  2 года назад

      Link is in the description and files are in the src and inc folders..

  • @triumph6328
    @triumph6328 2 года назад

    thank you!

  • @andrews5630
    @andrews5630 4 года назад

    Hi, how to convert angular velocity to regular angle?

    • @ControllersTech
      @ControllersTech  4 года назад

      I have to start working on the angle part. I forgot as it was due for a while. The problem is that the error get developed in the gyro as the time passes. There are some algorithms to solve the issue. I'll take a look.
      If you want to use angular velocity to do so, you can use the formula (w = ∆theta/∆t)

  • @franciscotoapanta3926
    @franciscotoapanta3926 4 года назад

    if i using cubeide, and i couldn't found the part that said linker flags where i can put the -u _printf_float

    • @ControllersTech
      @ControllersTech  4 года назад

      It's in project setting -> c/c++ build -> setting -> tool setting -> mcu setting and enable u printf float

    •  4 года назад

      Window not?

  • @SANDJONG123
    @SANDJONG123 2 года назад

    Hello
    Controllers Tech! First of all I'd like to thank you for your video.
    I have encountered some problems with the displaying part of the accel value.
    1. After I builded the programm, I received an error. "buf" is undeclared. I cant recalled you declared a char volatile buf variable to use it in the sprintf function, or?
    2. I dont get any value on the display.
    What could be the problem? Does anyone else encountered this?

    • @ControllersTech
      @ControllersTech  2 года назад +1

      You should work on them separately first and then combine the codes. Better focus on LCD alone and when you understand it, then check the MPU6050.

    • @SANDJONG123
      @SANDJONG123 2 года назад

      @@ControllersTech Understood. Thx for replying.

  • @mohamedhassane6347
    @mohamedhassane6347 11 месяцев назад

    Thank you sir

  • @EmbeddedEnigma
    @EmbeddedEnigma 2 года назад

    Hi, I created my own I2c library in stm32f I am doing bare metal, the only confusion I have is that my stm32 only detects mpu6050 when I give it address (0x68

    • @ControllersTech
      @ControllersTech  2 года назад

      Because that's the address of the slave (mpu6050)

    • @EmbeddedEnigma
      @EmbeddedEnigma 2 года назад

      @@ControllersTech yes I know that but I mean while check slave address on arduino we give 0x68 but on stm32 we have to shift 1 bit why is that?

    • @ControllersTech
      @ControllersTech  2 года назад

      Because Arduino takes 7 bit address. STM needs 8 bits (7 bits + read/write)

    • @EmbeddedEnigma
      @EmbeddedEnigma 2 года назад

      @@ControllersTech thank you

  • @startobytes
    @startobytes 3 года назад

    can you make a Video about the 16x2 i2c LCD without this library?!

  • @Lucialunivers
    @Lucialunivers 2 года назад

    Hi, is it possible to plot the acceleration and gyroscope curve?

    • @ControllersTech
      @ControllersTech  2 года назад

      yes but you need some application which can do the plotting for you.
      Then use uart to send the data to the app and it will plot the curve

    • @Lucialunivers
      @Lucialunivers 2 года назад

      @@ControllersTech Okay, thanks! I'll give it a try.

    • @Lucialunivers
      @Lucialunivers 2 года назад

      @@ControllersTech In fact you have configured the MPU6050 in one of your videos I would like to know how to get a curve from it. If you could make a small video to show how to get a curve of the gyro and acceleration parameters. Thanks

  • @pawel12313
    @pawel12313 3 года назад

    does not work check stays as 0

  • @animalinwildlife
    @animalinwildlife 4 года назад

    How can i download these libraries ??
    Pls help me, thank you !!!

    • @ControllersTech
      @ControllersTech  4 года назад

      Goto the link in the description.. at the end of the post, there is a download button

  • @babotvoj
    @babotvoj 4 года назад

    Hello, I want to process the signal from the accelerometer. Because the read function is in the main loop which goes at a much faster rate than the 1kHz defined for the accelerometer, will the samples be red multiple times? Should interrupts or DMA be used to get samples at the exact sampling rate I want?

    • @ControllersTech
      @ControllersTech  4 года назад

      It doesn't go faster than 1KHz. If you read every 1 ms, that would be 1KHz.

    • @babotvoj
      @babotvoj 4 года назад

      @@ControllersTech hello, but to restrict it to read every 1ms you would need a delay or a timer interrupt. Otherwise it would sample as fast as the while loop goes. That's how I understood it.

    • @ControllersTech
      @ControllersTech  4 года назад +1

      Yeah you put a delay of 1 ms in the while loop

    • @babotvoj
      @babotvoj 4 года назад

      @@ControllersTech thanks for the reply, I have 1 just one more question, does it make sense to work with timer interrupts or DMA to get the sampling timing more accurate.

  • @abutaymiyyahlectures
    @abutaymiyyahlectures 3 года назад

    hey can i know where did we innitialize Accel_X_RAW ,Accel_Y_RAW & Accel_Z_RAW?

    • @ControllersTech
      @ControllersTech  3 года назад

      Right click on it and goto declaration

    • @abutaymiyyahlectures
      @abutaymiyyahlectures 3 года назад

      @@ControllersTech ooo okay, can i know where i can find your sample code?, because on your website i cant seem to find it(the one you put on your discription), anyways, thanks for your awesome tutorial, it helped me a lot !!

    • @ControllersTech
      @ControllersTech  3 года назад

      it's there... at the bottom of the page

    • @abutaymiyyahlectures
      @abutaymiyyahlectures 3 года назад

      @@ControllersTech yup i found it just a second ago, there is a downlaod button. Thank you

  • @cristianmelian4655
    @cristianmelian4655 Год назад

    Great video! Maybe just a small clarification if it's possible, I'm not so good at coding. Maybe someone could explain.
    For example for acceleration: How do we get the reading for all the axes both for H and L part, given the fact that there is only one command where only the ACCEL_XOUT_H_REG is read?
    How does this command "HAL_I2C_Mem_Read (&hi2c1, MPU6050_ADDR, ACCEL_XOUT_H_REG, 1, Received_Data, 6, 1000);" knows that I also want to read ACCEL_XOUT_L_REG, ACCEL_YOUT_H_REG, ACCEL_YOUT_L_REG and so on...? Thanks!

    • @ControllersTech
      @ControllersTech  Год назад

      In that function we are reading 6 registers starting from the ACCEL_H_REG. If you check the datasheet of the device, you will find out the next 5 registers.

    • @cristianmelian4655
      @cristianmelian4655 Год назад

      @@ControllersTech Thanks! And one more thing regarding the values of the gyro. I have managed to build the setup but from what I see the generated values doesn't take into consideration the previous value. If for example I move the gyro at a certain angle I can see an instant change in the value but if I keep the senzor in the same position then the next values will start from zero instead of taking into consideration the angle. Did you manage to solve this issue? I know from Arduino implementation that the read values took into account the position of the sensor instead of creating a reference to zero at each new reading.
      Thanks!

    • @ControllersTech
      @ControllersTech  Год назад

      You can define the variable as static..
      For eg- Static float angle;

  • @cristiansandor4435
    @cristiansandor4435 4 года назад +2

    Hi, It's a good tutorial, thanks
    Anyway, I'm trying to make this working together with a LCD display and a PCF8574 module. Both working except GY521.
    I tried to debug and I found I get HAL_Status error in the call of I2C_WaitOnFlagUntilTimeout in stmf1xx_hal_i2c.c . This is insider of first call of HAL_I2C_Mem_Read
    I will buy another GY521,... only thing I can think of is the module is faulty.

    • @achoangnguyen8796
      @achoangnguyen8796 4 года назад

      Hi sir , i read your comment and i think i get the same error ..
      Did you buy another GY521 ? and Did it work after that ?
      Thanks.

    • @cristiansandor4435
      @cristiansandor4435 4 года назад

      @@achoangnguyen8796 Hi, no I did not continue this project. Sorry

    • @ControllersTech
      @ControllersTech  4 года назад

      Check tha address. Also check the connections. Use 4K7 pull up resistors on the sck and sda lines

  • @lexxyar
    @lexxyar 5 лет назад

    Hi friend. First of all thx for this video.
    Could you show, how to measure current angle? I measure ticks at start loop and end loop. Get difference between ticks. Then I get gyro dps and multiply on tick difference. The result I add to float vareable. Unfortunately, I didn't get axpected result. Could you help me?

    • @ControllersTech
      @ControllersTech  5 лет назад

      There are lot of errors and other things to be taken into consideration while measuring angle. Like I mentioned in the video I'll make another one involving all those things soon. Or you can refer any arduino based code and port it. It should work

    • @lexxyar
      @lexxyar 5 лет назад

      @@ControllersTech Thx for answer. I'll try it... again :)

    • @yusufaksel-2737
      @yusufaksel-2737 5 лет назад

      @@ControllersTech you did not do it yet right?

  • @user-oo5pq7xb7f
    @user-oo5pq7xb7f 4 года назад

    what Os?

  • @betulguncaldi4676
    @betulguncaldi4676 3 года назад

    how will the sensor be filtered?

    • @ControllersTech
      @ControllersTech  3 года назад

      What you mean filtered ?

    • @betulguncaldi4676
      @betulguncaldi4676 3 года назад

      @@ControllersTech I want to filter my pressure, acceleration sensors. Is this something done during coding?

    • @ControllersTech
      @ControllersTech  3 года назад

      I still don't understand what you mean by filter the acceleration..
      But anyway yes you have to do all at the time of coding itself.
      If your query is more related to sensor, you can check the datasheet. There might be some register which can help you

    • @betulguncaldi4676
      @betulguncaldi4676 3 года назад

      @@ControllersTech thank you anyway, I couldn't explain myself.

  • @ManojKumar-mg5wb
    @ManojKumar-mg5wb 5 лет назад

    The readings are coming but the values are unreliable, Can you help me to config it? Also you have commented the gyro config ..should we enable it for good values..

    • @ControllersTech
      @ControllersTech  5 лет назад

      Right now only acceleration values are usable. I tested some theories and some other methods to calibrate gyro but wasn't successful. They always drift away 🤦‍♂️. I will soon start working on dmp port from arduino. That will definitely stabilize the gyro

    • @kazimkhan4259
      @kazimkhan4259 Год назад

      @@ControllersTech Any joy with porting DMP to STM32?

  • @egar1956
    @egar1956 3 года назад

    It is redundant WHO_AM_I register, I think. Because if I'm not address it correctly, the device will not ACK

    • @ControllersTech
      @ControllersTech  3 года назад +1

      I don't think that affects it.
      That's just to confirm if the device is connected and is responding

    • @Muhammad-qf9vl
      @Muhammad-qf9vl 2 года назад

      @@ControllersTech Hello.Thank you for your great tutorial!
      I tried a lot but i couldn't receive correct data from MPU6050.
      I followed everything that you said.
      Also why do you Define MPU address D0? shouldn't it be 0x68 or 0x69?
      Regards

  • @pusatberk4193
    @pusatberk4193 5 лет назад

    Thank you !