GPIO0 on Mn Cast [resolved]

Hello, I’ve got a couple of these recently & have been working on creating an esphome config for it similar to what’s available for espmuse luxe/proto. I’ve been able to get the rotary encoder working but am struggling with the encoder button config, it’s listed as using the GPIO0 pin here:

Encoder
A=32
B=19
Button =0

when validating the config in esphome it appears that’s a strapping pin:

WARNING GPIO0 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.

The docs I’ve read recommend only using this pin for output and I’m getting strange results using this config, if I remove the delay filters it rapidly flips on/off continuously:

binary_sensor:
  - platform: gpio
    pin:
      number: 0 
      mode: INPUT_PULLUP
      inverted: true
    filters:
     - delayed_on: 100ms
     - delayed_off: 150ms
    name: "Play/Pause"
    on_click:
      then:
       - media_player.toggle: 

Any recommendations or am I missing something here? I presume the ino test config here works without issue, thanks!

Hello and welcome,
Short answer, IO0 could be used for input as long as there is no external pull-up/down resistor attached to it. This is working fine on our demo app with a debounce you have mentioned but I will give it a too on HA.

longer answer:
IO0 is indeed a specific pin that is used to put the device in bootloader mode if push on the button (state == 0) while turning the device reboot, then it allows to upload a new firmware. This is usually managed by the autoboot loader but I like to have IO0 button in case the auto bootloader fails for some reason.

Can you get it working with the display on ESPHome? When I was testing, the music was distorted every time on display refresh.
Please do post your full config when it’s up and running.

yes I will look at it, also because this is the only missing app in my new apps store !!!

Try it out : http://apps.raspiaudio.com/

Great idea with the store!
Looking forward to having ESPHome support :grinning:

I can see that the IO0 button is working in HA using the yalm file of the PROTO, so I rewrote one on that base. Light, button, and music is working, I also added screen to display time.

The display seems to add some noise on the audio, pretty sure this is not hardware related as it is working with others apps.

So here my first attempt of writing a yalm file.

I first add to use ESP web tool with a dummy device, adopt it in HA, then modify the yalm, update wirelessly.

need to be done : adding rotary encoder

This rotary encoder config is working quite well for volume control

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    pin_b:
      number: GPIO32 
      mode: INPUT_PULLUP
    pin_a:
      number: GPIO19
      mode: INPUT_PULLUP
    on_clockwise:
     - media_player.volume_up  
     - logger.log: "Turned Clockwise"
    on_anticlockwise:
     - media_player.volume_down
     - logger.log: "Turned Anticlockwise"

oh thanks, I will give it a try, now I also need to add IR receiver and fix the annoying sound when the screen refreshes

here is the yalm without the display


# These substitutions allow the end user to override certain values
substitutions:
  name: "mn-cast"

esphome:
  name: "${name}"
  # Automatically add the mac address to the name
  # so you can use a single firmware for all devices
  name_add_mac_suffix: true


# Sets up the i


esp32:
  board: esp-wrover-kit
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "password_is_musemuse"
    password: "musemuse"

   
improv_serial:

media_player:
  - platform: i2s_audio
    id: media_out
    name: MnCast
    dac_type: external
    i2s_lrclk_pin: GPIO25
    i2s_dout_pin: GPIO26
    i2s_bclk_pin: GPIO5
    mode: stereo
    mute_pin:
      number: GPIO33
      inverted: true

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      inverted: true
      mode:
        input: true
        pullup: true
    name: Button
    on_click:
      - media_player.toggle: media_out

light:
  - platform: fastled_clockless
    name: LED
    pin: GPIO22
    chipset: SK6812
    num_leds: 1
    rgb_order: grb

sensor:
  - platform: rotary_encoder
    name: "Rotary Encoder"
    pin_b:
      number: GPIO32 
      mode: INPUT_PULLUP
    pin_a:
      number: GPIO19
      mode: INPUT_PULLUP
    on_clockwise:
      - media_player.volume_up  
      - logger.log: "Turned Clockwise"
    on_anticlockwise:
      - media_player.volume_down
      - logger.log: "Turned Anticlockwise"

yalm with the display :