• Stars
    star
    333
  • Rank 126,599 (Top 3 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

STM32 HAL library for GY-521 (MPU6050) with Kalman filter

STM32 HAL library for GY-521 (MPU6050) with Kalman filter

English note

A simple C library (STM32 HAL) for working with the GY-521 module (MPU6050) https://www.aliexpress.com/af/gy%25252d521.html?trafficChannel=af&d=y&CatId=0&SearchText=gy-521&ltype=affiliate&SortType= total_tranpro_desc & groupsort = 1 & page = 1

Start and initialize the I2C bus using the STM32CubeMX.

I2C

Configure STM32CubeMX by setting "General peripheral Initalizion as a pair of '.c / .h' file per peripheral" in the project settings.

Copy the library header and source file to the appropriate project directories (Inc, Src).

In the head file of your project (main.c), include the header file

/ * USER CODE BEGIN Includes * /
#include "mpu6050.h"
/ * USER CODE END Includes * /

add structure to the section

/ * USER CODE BEGIN PV * /
MPU6050_t MPU6050;
/ * USER CODE END PV * /

add int main (void) to the function section

/ * USER CODE BEGIN 2 * /

while (MPU6050_Init(&hi2c1) == 1);

/ * USER CODE END 2 * /

for initial initialization of the GY-521 (MPU6050).

add int main (void) to the function section

/ * USER CODE BEGIN WHILE * /
while (1)
{
/ * USER CODE END WHILE * /

/ * USER CODE BEGIN 3 * /
  MPU6050_Read_All(&hi2c1, &MPU6050);
  HAL_Delay (100);
}
/ * USER CODE END 3 * /

On this project setup is ready. After starting the program, information from the GY-521 (MPU6050) will be available through the MPU6050 structure

MPU6050.KalmanAngleX

The Kalman filter algorithm for calculating angles is taken from the project https://github.com/TKJElectronics/KalmanFilter

Russian note

Простая библиотека на Си (STM32 HAL) для работы с модулем GY-521 (MPU6050) https://www.aliexpress.com/af/gy%25252d521.html?trafficChannel=af&d=y&CatId=0&SearchText=gy-521&ltype=affiliate&SortType=total_tranpro_desc&groupsort=1&page=1

Запустите и инициализируйте шину I2C c помощью STM32CubeMX.

I2C

Сконфигурируйте STM32CubeMX установив "General peripheral Initalizion as a pair of '.c/.h' file per peripheral" в настройках проекта.

Скопируйте заголовочный и исходный файл библиотеки в соотвесвтующие директории проекта (Inc, Src).

В головном файл вашего проекта (main.c) подключите заголовочный файл

/* USER CODE BEGIN Includes */
#include "mpu6050.h"
/* USER CODE END Includes */

в секцию добавьте структуру

/* USER CODE BEGIN PV */
MPU6050_t MPU6050;
/* USER CODE END PV */

добавьте в секцию функции int main(void)

/* USER CODE BEGIN 2 */

while (MPU6050_Init(&hi2c1) == 1);

/* USER CODE END 2 */

для начальной инициализации GY-521 (MPU6050).

добавьте в секцию функции int main(void)

/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
  MPU6050_Read_All(&hi2c1, &MPU6050);
  HAL_Delay(100);
}
/* USER CODE END 3 */

На этом настройка проекта готова. После запуска программы информация от GY-521 (MPU6050) будет доступна через структуру MPU6050

MPU6050.KalmanAngleX

Алгоритм фильтра Калмана для расчета углов взят из проекта https://github.com/TKJElectronics/KalmanFilter

More Repositories

1

SIM800MQTT

STM32 HAL library for SIM800 release MQTT client over AT command
C
135
star
2

gps

STM32 HAL library for GPS module NEO-6M
C
56
star
3

hass-mqtt-discovery

Python class library for generate and send to Home Assistant over MQTT (AutoDiscovery) device data
Python
32
star
4

RF-BARRIER

STM32 HAL library for reading and sending code for Radio frequency (RF) barrier (Came, Nice) simple code 12, 24 bit and HCS301 with keeloq 66 bit.
C
28
star
5

HCS301

STM32 HAL library for reading code from HCS301 433Mhz Keeloq
C
19
star
6

micros

STM32 HAL library for release function micros() and delay_us().
C
18
star
7

SimpleKalman

A project to implement a one-dimensional Kalman filter in Dart language
Dart
13
star
8

TempControl-ESP8266

Temp control on ESP8266
Python
6
star
9

OpenOCD-CS32

OpenOCD config for CS32F103C8T6 (CKSF103C8T6)
6
star
10

MotoBoard

Auto oiler for lube on moto chain
C
5
star
11

NRF24L01

HAL library for NRF24L01 on STM32
C
5
star
12

Temp_control

Orange PI temp control (ds18b20, GPIO, Telegram, telepot)
Python
4
star
13

HTTPyCheck

The Python HTTP(S) - PING check availability sites over Telegram bot project
Python
4
star
14

process_metrics_exporter

Prometheus process metrics exporter
Go
4
star
15

Security-fire-alarm-ESP8266

Security fire alarm on ESP8266
Python
3
star
16

rf-leak-module

Leak module based on STM32G030F6P6 and NRF24L01
C
3
star
17

STM32-FreeRTOS-float

Support for working with float in STM32 in conjunction with FreeRTOS
C
3
star
18

SIM800-StatsD

STM32 HAL library for SIM800 (GPRS) release send metric StatsD over AT command
C
2
star
19

MQ9

Micropython MQ9 library for ESP8266
Python
2
star
20

LeakControlESP8266

Leak control on ESP8266 ( MQTT ) and Orange PI
Python
1
star
21

blackmagic-docker

Docker image to build BlackMagic binary
Shell
1
star
22

SIM800-RTT

STM32 HAL library for SIM800 (GPRS) release send GPS metric to RTT server over AT command
C
1
star