ESPHome MPU6050 Accelerometer - Gyroscope Sensor

The custom:plotly-graph card is handy to graph data and to examine. Also Grafana could help a lot in displaying data and you could consider to collect the data in InfluxDB as that database type is talored to recording this type of time data which updates at high intervals.

ESPHome sensor link: https://esphome.io/components/sensor/mpu6050.html

esphome:

name: gyro-sensor1


esp8266:

board: d1_mini_pro


# Enable logging

logger:


# Enable Home Assistant API

api:


ota:


wifi:

ssid: wifi-ap-name

password: whatsthepassword


# Enable fallback hotspot (captive portal) in case wifi connection fails

ap:

ssid: "Gyro-Sensor1 Fallback Hotspot"

password: "whatsthepassword"


captive_portal:


# Enable Web server.

web_server:

port: 80

# Sync time with Home Assistant.

time:

- platform: homeassistant

id: homeassistant_time

i2c:

sda: D2

scl: D3

frequency: 100kHz

scan: False


sensor:

- platform: mpu6050

address: 0x68

accel_x:

id: accel_x

name: "MPU6050 Accel X"

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

accel_y:

id: accel_y

name: "MPU6050 Accel Y"

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

accel_z:

id: accel_z

name: "MPU6050 Accel z"

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

gyro_x:

name: "MPU6050 Gyro X"

id: gyro_x

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

gyro_y:

name: "MPU6050 Gyro Y"

id: gyro_y

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

gyro_z:

name: "MPU6050 Gyro z"

id: gyro_z

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

temperature:

name: "MPU6050 Temperature"

filters:

- sliding_window_moving_average:

window_size: 10

send_every: 5

update_interval: 500ms


- platform: template

id: roll

name: roll

accuracy_decimals: 2

lambda: |-

return (atan( id(accel_y).state / sqrt( pow( id(accel_x).state , 2) + pow( id(accel_z).state , 2) ) ) * 180 / PI) ;

update_interval: 500ms


- platform: template

id: pitch

name: pitch

accuracy_decimals: 2

lambda: |-

return (atan(-1 * id(accel_x).state / sqrt(pow(id(accel_y).state, 2) + pow(id(accel_z).state, 2))) * 180 / PI);

update_interval: 500ms



#sensor:

# - platform: mpu6050

# address: 0x68

# accel_x:

# name: 'MPU6050 Accel X'

# accel_y:

# name: 'MPU6050 Accel Y'

# accel_z:

# name: 'MPU6050 Accel z'

# gyro_x:

# name: 'MPU6050 Gyro X'

# gyro_y:

# name: 'MPU6050 Gyro Y'

# gyro_z:

# name: 'MPU6050 Gyro z'

# temperature:

# name: 'MPU6050 Temperature'

# update_interval: 2s