Salut @bentou,
tu compte te lancer quand pour le M5Stick Plus 2 ?
Un coup de main serait pas de refus, pour essayer de finaliser un firmware stable pour un voice assistant.
j’ai essayé, mais je n’arrive pas à aller bien loin…
j’ai le plus2 et le spk2, chargé un esphome, mais il n’écoute pas, l’effronté !!!
AH ! ta commencer a bosser deçu
Impeccable, on a le même matos
Allez, je te partage les recherches que j’ai faite.
substitutions:
name: m5stickc-plus2-voice
friendly_name: M5StickC PLUS2 Voice
esphome:
name: ${name}
name_add_mac_suffix: false
friendly_name: ${friendly_name}
project:
name: m5stack.atom-echo-voice-assistant
version: "1.0"
min_version: 2023.11.1
platformio_options:
upload_speed: 115200
on_boot:
- priority: 600
then:
- output.turn_on: output_high
- then:
- light.turn_on:
id: display_bl
brightness: 75%
on_shutdown:
- priority: 600
then:
- output.turn_off: output_high
esp32:
board: m5stick-c
framework:
type: esp-idf
flash_size: 8MB
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
improv_serial:
esp32_improv:
authorizer: none
script:
- id: reset_led
then:
- if:
condition:
switch.is_on: use_wake_word
then:
- light.turn_on:
id: led
else:
- light.turn_off: led
output:
- platform: ledc
pin: GPIO19
id: led_pwm
# Buzzer output
- platform: ledc
pin:
number: GPIO2
id: buzzer
inverted: false
# Backlight TFT LCD
- platform: ledc
pin: 27
inverted: false
id: backlight
# Battery output
- platform: gpio
id: output_high
pin:
number: GPIO4
mode:
output: true
spi:
clk_pin: GPIO13
mosi_pin: GPIO15
#i2s_audio:
# i2s_lrclk_pin: GPIO0
i2s_audio:
- id: mic_adc
i2s_lrclk_pin:
number: GPIO0
allow_other_uses: true
ignore_strapping_warning: true
- id: spk_adc
i2s_lrclk_pin:
number: GPIO0
allow_other_uses: true
ignore_strapping_warning: true
i2s_bclk_pin: GPIO26
microphone:
- platform: i2s_audio
id: echo_microphone
i2s_din_pin: GPIO34
adc_type: external
channel: left
i2s_audio_id: mic_adc
# bits_per_sample: 16bit
# sample_rate: 44100
pdm: true
#speaker:
# - platform: i2s_audio
# dac_type: internal
# i2s_audio_id: spk_adc
# mode: right
#speaker:
# - platform: i2s_audio
# id: echo_speaker
# i2s_dout_pin: GPIO25
# i2s_audio_id: spk_adc
# dac_type: external
# mode: mono
voice_assistant:
id: va
microphone: echo_microphone
# speaker: echo_speaker
noise_suppression_level: 2
auto_gain: 31dBFS
volume_multiplier: 2.0
vad_threshold: 3
on_listening:
- light.turn_on:
id: led
effect: "Listening"
on_stt_vad_end:
- light.turn_on:
id: led
effect: "Listening"
on_tts_start:
- text_sensor.template.publish:
id: tts
state: !lambda 'return x;'
- light.turn_on:
id: led
brightness: 60%
- delay: 100ms
- light.turn_off: led
on_end:
- delay: 100ms
# - wait_until:
# not:
# speaker.is_playing:
- script.execute: reset_led
on_error:
- light.turn_on:
id: led
effect: "Error"
- delay: 2s
- script.execute: reset_led
- script.wait: reset_led
on_client_connected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.start_continuous:
- script.execute: reset_led
on_client_disconnected:
- if:
condition:
switch.is_on: use_wake_word
then:
- voice_assistant.stop:
- light.turn_off: led
binary_sensor:
- platform: gpio
pin:
number: GPIO37
inverted: true
name: Button A
disabled_by_default: true
entity_category: diagnostic
id: a_button
on_multi_click:
- timing:
- ON for 40ms to 400ms
- OFF for at least 330ms
then:
- if:
condition:
switch.is_off: use_wake_word
then:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
else:
- output.turn_off: buzzer
- voice_assistant.start:
else:
- voice_assistant.stop
- delay: 1s
- script.execute: reset_led
- script.wait: reset_led
- voice_assistant.start_continuous:
- timing:
- ON for 40ms to 400ms
- OFF for 40ms to 300ms
- ON for 40ms to 400ms
- OFF for at least 330ms
then:
- light.toggle: display_bl
light:
- platform: monochromatic
id: led
name: None
disabled_by_default: true
entity_category: config
output: led_pwm
effects:
- pulse:
name: "Listening"
transition_length: 1s
update_interval: 1s
min_brightness: 0%
max_brightness: 30%
- pulse:
name: "Error"
transition_length: 0.25s
update_interval: 0.25s
min_brightness: 0%
max_brightness: 100%
# Backlight TFT LCD
- platform: monochromatic
output: backlight
name: Backlight
id: display_bl
restore_mode: ALWAYS_ON
switch:
- platform: template
name: Use wake word
id: use_wake_word
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
entity_category: config
on_turn_on:
- lambda: id(va).set_use_wake_word(true);
- if:
condition:
not:
- voice_assistant.is_running
then:
- voice_assistant.start_continuous
- script.execute: reset_led
on_turn_off:
- voice_assistant.stop
- lambda: id(va).set_use_wake_word(false);
- script.execute: reset_led
text_sensor:
- platform: template
name: "text-to-speech"
id: tts
font:
- file: "gfonts://Roboto"
id: roboto
size: 18
glyphs: "<>!'%()+,-_.:;*=°?#0123456789AÀBCDEÉÈÊFGHIJKLMNOPQRSTUVWXYZ aàbcdeéèêfghijklmnopqrstuvwxyzôöç"
color:
- id: my_white
red: 100%
green: 100%
blue: 100%
- id: my_blue
red: 0%
green: 0%
blue: 100%
- id: my_red
red: 100%
green: 0%
blue: 0%
- id: my_green
red: 0%
green: 100%
blue: 0%
- id: my_yellow
red: 100%
green: 100%
blue: 0%
- id: my_orange
red: 100%
green: 50%
blue: 0%
# 1.14 inch, 135*240 Colorful TFT LCD, ST7789v2
display:
- platform: ili9xxx
model: st7789v
cs_pin: GPIO5
dc_pin: GPIO14
reset_pin: GPIO12
rotation: 90
dimensions:
height: 240
width: 135
offset_height: 40
offset_width: 52
# Required or the colors are all inverted, and Black screen is White
invert_colors: true
lambda: |-
it.printf(5, 4, id(roboto), id(my_white), "Réponse:");
it.printf(5, 30, id(roboto), id(my_green), id(tts).state.c_str());
external_components:
- source: github://pr#5230
components:
- esp_adf
refresh: 0s
esp_adf:
Avec c’est config, ta le led rouge , l’écran, le micro, la battery ( activer , si tu débranche l’usb ).
Le bouton A ( logo M5 ) active le wakeword et tu dit ta commande.
La réponse est écrite sur l’écran, mais attention si le texte est trop long, l’écran peut bugger ( un point a améliorer ).
Maintenant pour activer le speaker, dans le M5Stickc Plus 2 ta un buzzer ( speaker ) sur le GPIO2 et si il est utiliser le microphone ne fonctionne pas. Il utilise le même GPIO0 pour le LRCLK.
Faut désactiver le buzzer, pour que le micro fonctionne.
Pour le speaker SPK2, il utilise le GPIO0 LRCLK, le GPIO26 BCLK et le GPIO25 DATA. Ca reviens au même que le buzzer GPIO2 il utilise le même GPIO0 pour le LRCLK.
Le but serais de pouvoir, activer ou désactiver le micro et speaker suivant le besoin dans voice_assistant. Mais je bloque sur la facon de mettre ca en place.
J’ai un code arduino, pour utiliser le micro et speaker ( buzzer ou SPK2 ).
Mais du mal a convertir ca pour esphome.
Y’a un truc qui doit manquer chez moi… ???
11:20:16 [D] [binary_sensor:036]
'Button A': Sending state ON
11:20:19 [D] [binary_sensor:036]
'Button A': Sending state OFF
11:20:30 [W] [web_server_idf:070]
Only application/x-www-form-urlencoded supported for POST request
11:20:30 [D] [light:036]
'M5StickC PLUS2 Voice' Setting:
11:20:30 [D] [light:047]
State: ON
11:20:30 [D] [light:109]
Effect: 'Listening'
11:20:36 [D] [esp-idf:000]
e[0;33mW (42825) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:20:36 [D] [esp-idf:000]
e[0;33mW (42829) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:20:36 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:21:06 [D] [esp-idf:000]
e[0;33mW (72827) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:21:06 [D] [esp-idf:000]
e[0;33mW (72831) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:21:06 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:21:36 [D] [esp-idf:000]
e[0;33mW (102842) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:21:36 [D] [esp-idf:000]
e[0;33mW (102846) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:21:58 [D] [api:102]
Accepted 192.168.92.25
11:21:58 [W] [component:237]
Component api took a long time for an operation (62 ms).
11:21:58 [W] [component:238]
Components should block for at most 30 ms.
11:21:59 [D] [api.connection:1210]
Home Assistant 2024.4.4 (192.168.92.25): Connected successfully
11:22:01 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:22:01 [W] [component:237]
Component display took a long time for an operation (682 ms).
11:22:01 [W] [component:238]
Components should block for at most 30 ms.
11:22:01 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:22:01 [E] [voice_assistant:392]
Multiple API Clients attempting to connect to Voice Assistant
11:22:01 [E] [voice_assistant:393]
Current client: Home Assistant 2024.4.4 (192.168.92.25)
11:22:01 [E] [voice_assistant:394]
New client: Home Assistant 2024.4.4 (192.168.92.25)
11:22:01 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:22:06 [D] [esp-idf:000]
e[0;33mW (132831) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:22:06 [D] [esp-idf:000]
e[0;33mW (132836) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:22:07 [W] [api.connection:102]
Home Assistant 2024.4.4 (192.168.92.25): Connection reset
11:22:36 [D] [esp-idf:000]
e[0;33mW (162845) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:22:36 [D] [esp-idf:000]
e[0;33mW (162848) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:22:36 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:23:08 [D] [esp-idf:000]
e[0;33mW (192839) httpd_uri: httpd_uri: Method '2' not allowed for URI '/'
11:23:08 [D] [esp-idf:000]
e[0;33mW (192843) httpd_txrx: httpd_resp_send_err: 405 Method Not Allowed - Request method for this URI is not handled by server
11:23:08 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:23:08 [E] [spi-esp-idf:081]
Transmit failed - err 101
11:23:22 [E] [spi-esp-idf:081]
Transmit failed - err 101
la seule différence c’est çà:
# Enable Home Assistant API
api:
encryption:
key: !secret api_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
web_server:
port: 80
Oui, j’ai eu c’est erreur. Chez pas comment il remédier encore ( peut être activer - output.turn_off: buzzer
au boot ).
Je pense que c’est le GPIO2 du buzzer qui est activer, et fait conflit avec le micro.
Essaye d’appuer sur le button A ( logo m5 ), pour activer le micro.
j’ai ajouter - output.turn_off: buzzer
on_multi_click:
- timing:
- ON for 40ms to 400ms
- OFF for at least 330ms
then:
- if:
condition:
switch.is_off: use_wake_word
then:
- if:
condition: voice_assistant.is_running
then:
- voice_assistant.stop:
- script.execute: reset_led
else:
- output.turn_off: buzzer
- voice_assistant.start:
Tu peut essayer d’éteindre l’esp et le rallumer aussi ( bouton C ).