Bubble spirit level Lovelace card?

Hello!

I’m looking for a bubble spirit level Lovelace card to visualise roll/pitch of my MPU6050 gyro + accelerometer.

At the moment, I use 2 separate gauges (for roll & pitch):

But I prefer a bubble spirit level, if such is available, i.e. something like this:

(the round part alone would be sufficient)

Are you aware of such a Lovelace card for Home Assistant? Thanks for sharing! :slight_smile:

2 Likes

Neat request.

2 Likes

Thank you! :+1:

It was not intended as a request but a question if some Lovelace card like this exists (and I haven’t found it yet, not even in HACS).

If this should now become a request, do I have to add something here in this thread? Or should I request it in another sub-forum or even on GitHub? (where I have an account, too)

It is a request now, since no one has built this. Ask a mod, perhaps, to move the thread to either the custom integrations category, or the WTH / feature requests categories.

Dear Moderators,

Can you please move this thread to a more appropriate sub-forum? It seems as it is now a feature request. Thank you so much! :slight_smile:

Hello!
Can you please share any guidance on how you connected and configured your MPU6050 and got the data into HA?

I have HA on a floating house and I would like to use this to measure the pitch & roll of the house. I’d like to connect an MPU6050 to my Raspberry Pi running HA, but no idea where to start (I’m new to HA)

Many thanks in advance !
Tom

Here you go:

1 Like

The MPU6050 is connected to an ESP32, which is connected (via USB) to a Raspberry Pi 4 (that obviously runs Home Assistant), which is connected to a Teltonika RUXT11. :wink:

This is the relevant excerpt of the ESPHome config for the ESP32:

# Project-specific stuff below

# i2c
i2c:
  sda: 21
  scl: 22
  scan: true
  id: i2c_bus_a

# MPU6050 accelerometer/gyroscope sensor 
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: 250ms

  - 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: 250ms

  - 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: 250ms

It’s not as nice as a spirit bubble but works for the time being:

Obviously, the car needs to be considerably higher at its end (roll), whereas left/right is ok (pitch). :slight_smile:

The HA lovelace card code follows:

- title: Level
    path: level
    icon: mdi:spirit-level
    badges: []
    cards:
      - type: gauge
        entity: sensor.esp32_ha2_pitch
        min: -20
        max: 20
        needle: true
        name: Pitch
        unit: °
      - type: gauge
        entity: sensor.esp32_ha2_roll
        name: Roll
        unit: °
        min: -20
        max: 20
        needle: true

People might be interested in this, too:
https://van-automation.com/adding_van_tilt_sensor.html

I have the same scenario but am curious if you manage to expose the sensors to HA by reading them over USB not Wi-Fi. I see the log over USB but cannot get the entity to HA

I never thought about this. It just works with the MPU6050 connected to the ESP32 that is connected to the RPi via USB.

It does not in your case? Do you see if the ESP32 is recognised by the RPi when plugged in? (dmesg | grep usb)

Maybe your RPi needs a better electric plug (with more power to supply the ESP32 etc. sufficiently)?