M5Stack Dial - ESP32-S3 Smart Rotary Knob

I like the gadget, who has creative ideas to use it in HA?
Volume and brightness control of easy, what about the rest?

5 Likes

Would be awesome to automatically get all entities with variable input like dimmers, volume, fans, blinds and more. One knob to rule them all.

Wall thermostat for every room (with existing zigbee temp sensors)

I just ordered them and was curious about this as well

2 Likes

Just brought one from Vallejo, this thing will be great once implemented in HA, anyone able to integrate it yet?

1 Like

isnt the default ESP integration helping anything?

I don’t believe that you can use most of the Dial functionality with the current ESPhome implementation, beyond basic ESP32

fair enough, so would it be integration of its own or an extension of esp32?

Probably part of the ESPhome cache, which will make it super easy to implement. Waiting for smart people to try it and help with the implementation :slight_smile:

1 Like

thermostat - perfect hardware for this project. lets try to it

Hello all,
I wanted to share what I have been able to accomplish with the M5Dial into HA. Short answer – the rotary encoder only. But it is a start.

M5Video2

I created a new ESP32-S3 device in ESPHome and copied the rotary encoder details into the yaml file. ESPHome Rotary Encoder Component

M5Dial Documentation

esphome:
  name: m5rotary
  friendly_name: m5rotary

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    pin_a: 
      number: GPIO40
      mode:
       input: true
       pullup: true
    pin_b: 
      number: GPIO41
      mode:
       input: true
       pullup: true
    accuracy_decimals: 0
  
# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret encryption_key
    #My encryption key is in my secrets folder as yours should also be

ota:
  password: "!secret ota password"
  #This is provided by ESPHome when the new device is created

wifi:
  ssid: "!secret ssid"
  password: !secret home_wifi_key
  manual_ip:
    #I set up all of my devices to a static IP - makes my life easier
    # Set this to the IP of the ESP
    static_ip: 192.168.1.25
    # Set this to the IP address of the router. Often ends with .1
    gateway: 192.168.1.1
    # The subnet of the network.
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "M5Rotary Fallback Hotspot"
    password: "Provided_by_ESPHome_as_well"

captive_portal:

Now my successes:

  1. The rotary encoder is now seen as an entity in HA.
  2. I can see the entity reporting steps as both positive and negative integers.

And failures:

  1. All I have now as an entity is the rotary encoder in HA. No display, no beeps, no touch screen.
  2. Once the M5Dial stops sending steps, HA reports ‘unknown’. I think there is a setting I can code that states for the device to hold it’s last step report.
  3. In the ESPHome log file there is a warning that the device disconnected from the API.

Next steps:

  1. The ESP32 S3 WiFi is not that strong – at least for me. I believe that M5Stack is using what they call the STAMP packaging for the ESP32 and that small of a package limits it’s WiFi capability
  2. I have noticed that the entity card on my dashboard either reacts slowly or not at all compared to the ESPHome log file. That could also be part of the WiFi issue but something to look into/resolve.
  3. Do something with this encoder

I see where others are looking at a light dimmer but I am also thinking to use it for a digital combination lock - so the combination could be 57, -22, 18 to unlock a door or something.

1 Like

nice work. Steps are to be made, but I can think already an event based logic on this entity. for examle if media is playing back, its controling the volume of ampilifier.
If a specific light just turned on, it could be the dimmer.
When we have buttons on the display, we can make it more user friendly to choose what it contorls.

the wifi weakness is kinda concerning, any idea how it would handle multiple accecss points? I know some devices get reallly confused (disconnected) with those setups

1 Like

Not at the moment. The house I live in is made in the 1950’s with cinder block that wreaks havoc on wifi so that is my initial guess regarding the stability. The ESPHome log files do report the signal strength so that is probably how I will test.

I got mine today and been playing around for the past hour. Have the encoder working, as well as the display using some work from someone else integrating a similar screen into esphome (not really hooked up to anything important just yet).

You have to turn the backlight on, so I temporarily have a manual light setup to do it - I’ll eventually automate it when I figure out exactly what I want to use the dial for.

external_components:
  - source: github://the-smart-home-maker/esphome-4cello@gc9a01
    components: [ gc9a01 ]

spi:
  mosi_pin: GPIO5
  clk_pin: GPIO6

display:
- platform: gc9a01
  reset_pin: GPIO8
  cs_pin: GPIO7
  dc_pin: GPIO4
  rotation: 180
  lambda: |-
      it.filled_circle(it.get_width() / 2, it.get_height() / 2, 20);

binary_sensor:
  - platform: gpio
    pin: GPIO42
    name: "BacklightButton"

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    min_value: 16
    max_value: 31
    pin_a: 
      number: GPIO40
      mode:
       input: true
       pullup: true
    pin_b: 
      number: GPIO41
      mode:
       input: true
       pullup: true
    accuracy_decimals: 0

light:
  - platform: binary
    name: "OLED Backlight"
    output: light_output

output:
  - id: light_output
    platform: gpio
    pin: GPIO9

A long way still to go to make anything useful. But i have it hooked up to an LD2410C presence sensor (currently via bluetooth, but will hardwire it) to turn the backlight on/off when someone is within 70cm of the dial.

1 Like

Can’t wait to see what the possibilities are with this little guy, thank you for you who know how to for sharing your work!

Awesome! Travelled for Thanksgiving so I will have to wait until I get back home to try this out. Thanks for sharing your code and Happy Thanksgiving to all!

I also have it displaying the rotary encoder value on the screen - which is not much use either, but it works. I’m a novice with esphome and displays, so it’s taking a long time to figure it out, but fun to play with

display:
- platform: gc9a01
  reset_pin: GPIO8
  id: my_lcd
  cs_pin: GPIO7
  dc_pin: GPIO4
  rotation: 180
  lambda: |-
    it.printf(it.get_width() / 2, it.get_height() / 2, id(my_font), TextAlign::TOP_CENTER, "%.0f", id(rotaryencoder).state);

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    id: rotaryencoder
    min_value: 16
    max_value: 31
    pin_a: 
      number: GPIO40
      mode:
       input: true
       pullup: true
    pin_b: 
      number: GPIO41
      mode:
       input: true
       pullup: true
    accuracy_decimals: 0
    on_value:
       - component.update: my_lcd

There’s currently no touch screen support in esphome that I can find, so still designing a UI using the rotary encoder to change pages.

Ideally once touchscreen support is available I can use that to control light brightness, climate setpoint and mediavolume. At the moment it just reflects the state in HA of each device, but I can turn on lights, climate or mute/unmute using the physical button.

There’s an LD2410 mmwave sensor to the left of the controller, plugged into the pins in Port B, that will turn the screen backlight on when someone is within a metre of the screen, and off when they leave.

3 Likes

Fancy. Is back light dimmable?

According to the specs it does, and from testing it fades in/out when the backlight is turned off.

But I haven’t got around to playing with that part in esphome yet.

2 Likes