Giter Site home page Giter Site logo

mpu6050's Introduction

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 <mpu6050.h>

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

Author

Created by Ailton Fidelix

Linkedin Badge

mpu6050's People

Contributors

ailtonfidelix avatar

Stargazers

Trinh Cao Cuong avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.