An open API service indexing awesome lists of open source software.

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

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);
}
}
```