Core2 for AWS IoT EduKit BSP 1.5.1
MPU6886

The MPU6886 library provides convenience functions to interact with the 6-axis Inertial Measurement Unit (IMU) and built-in internal temperature sensor. The initialization function configures the Inertial Measurement Unit and the built-in internal temperature sensor with preset parameters.

Circuit Block Diagram for the MPU6886 6-axis inertial measurement unit

To enable this feature using KConfig, use the command pio run --environment core2foraws --target menuconfig from within the root of the project directory in your PlatformIO terminal window and go to the menu Component Config --> Core2 for AWS features to set the features you want to enable.

Example

The following example initializes the Core2 for AWS, which initializes the PMU for the battery and other user enabled hardware features — such as the MPU6886. From within a FreeRTOS task that loops every 200ms, it retrieves the accelerometer data which it stores in the variables accel_x, accel_y, and accel_z. Lastly, it prints the values using the ESP logger.

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "core2forAWS.h"
static const char *TAG = "EXAMPLE";
static void accel_task(void* pvParameters){
float accel_x = 0.00;
float accel_y = 0.00;
float accel_z = 0.00;
for(;;){
MPU6886_GetAccelData(&accel_x, &accel_y, &accel_z);
ESP_LOGI(TAG, "X: %.2f -- Y; %.2f -- Z: %.2f", accel_x, accel_y, accel_z);
vTaskDelay(pdMS_TO_TICKS(200));
}
vTaskDelete(NULL); /* Should never get to here... */
}
void app_main(void){
xTaskCreate(accel_task, "accelerometerTask", configMINIMAL_STACK_SIZE * 3, NULL, 1, NULL);
}
void Core2ForAWS_Init(void)
Initializes the power chip with default values, enables battery charging, and initializes all enabled...
Definition: core2forAWS.c:32
Functions to initialize and access Core2 for AWS IoT EduKit hardware features.
#define TAG
Definition: i2c_device.c:10
void MPU6886_GetAccelData(float *ax, float *ay, float *az)
Retrieves the accelerometer measurements from the MPU6886.
Definition: mpu6886.c:162

Enumerated Type Definitions

Functions