https://github.com/ailtonfidelix/mpu6050
MPU6050 library for ESP-IDF
https://github.com/ailtonfidelix/mpu6050
c esp-idf esp32 i2c mpu6050
Last synced: about 2 months ago
JSON representation
MPU6050 library for ESP-IDF
- Host: GitHub
- URL: https://github.com/ailtonfidelix/mpu6050
- Owner: AiltonFidelix
- License: mit
- Created: 2022-07-31T16:46:40.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2026-04-25T17:16:33.000Z (2 months ago)
- Last Synced: 2026-04-25T19:15:17.113Z (2 months ago)
- Topics: c, esp-idf, esp32, i2c, mpu6050
- Language: C
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MPU6050 library for ESP-IDF
This library allow to do the configurations to work with the MPU6050 device and read the sensors values.
## How to use
If you are using PlatformIO like me, you can just clone this project in the **lib** folder.
```
cd lib/ && git clone https://github.com/AiltonFidelix/MPU6050.git
```
Otherwise, just copy this project and use however you want.
## Example
```
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
// Include the library
#include
void app_main()
{
printf("Starting MPU6050!\n");
// bool true parameter to install the I2C driver
mpuBegin(MPU6050_ACCEL_RANGE_2G, MPU6050_GYRO_RANGE_250DPS, true);
mpuSetFilterBandwidth(MPU6050_BAND_21_HZ);
while (1)
{
esp_err_t ret = mpuReadSensors();
if (ret == ESP_OK)
{
printf("Temperature: %.2f°C\n", mpuGetTemperature());
printf("Acceleration X: %.2f\n", mpuGetAccelerationX());
printf("Acceleration Y: %.2f\n", mpuGetAccelerationY());
printf("Acceleration Z: %.2f\n", mpuGetAccelerationZ());
printf("Gyroscope X: %.2f\n", mpuGetGyroscopeX());
printf("Gyroscope Y: %.2f\n", mpuGetGyroscopeY());
printf("Gyroscope Z: %.2f\n", mpuGetGyroscopeZ());
}
else
{
printf("Read sensors failed! Error: %s\n", esp_err_to_name(ret));
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
}
```