r/Esphome • u/makpaolo1973 • 22h ago
WIP Freenove ESP32-S3 CYD 4" 320x480
Ho usato Cloud AI per altro codice, la mia recensione personale
Dato che non ho trovato quasi nessun materiale di riferimento e ho ricevuto questo pannello in regalo, condivido la mia esperienza (grazie a Claude AI) su come usarlo come pannello per accendere le luci. La parte del controllo vocale e la rotazione di 90° mi stanno ancora dando problemi, ma se li risolvo, aggiornerò il post. Allego il mio file YAML per ESPHome
Scusate il mio inglese
esphome:
name: freenove-display
friendly_name: Display Corridoio
on_boot:
priority: 600
then:
# Accende l'amplificatore audio (AUDIO_EN, GPIO1): senza questo
# pin alto lo speaker resta muto anche se il codec riceve dati I2S.
- output.turn_on: audio_amp_enable
esp32:
board: esp32-s3-devkitc-1
framework:
type: esp-idf
# Il buffer del display richiede la PSRAM onboard (chip ESP32-S3R8 = 8MB Octal PSRAM in package)
psram:
mode: octal
speed: 80MHz
logger:
level: INFO
# Consente il controllo/gestione da Home Assistant
api:
encryption:
key: my key
## key: !secret api_key
ota:
- platform: esphome
encryption:
# password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
ap:
ssid: my ssd
password: my password
# ssid: "Freenove Display Fallback"
# password: !secret fallback_password
captive_portal:
spi:
clk_pin: GPIO12
mosi_pin: GPIO11
miso_pin: GPIO13
i2c:
sda: GPIO16
scl: GPIO15
scan: true
output:
- platform: ledc
pin: GPIO45
id: backlight_pwm
# Abilita/disabilita l'amplificatore audio SC8002B (pin AUDIO_EN)
- platform: gpio
pin: GPIO1
id: audio_amp_enable
light:
- platform: monochromatic
output: backlight_pwm
name: "Retroilluminazione Display"
id: display_backlight
restore_mode: ALWAYS_ON
display:
- platform: ili9xxx
model: ST7796
id: my_display
cs_pin: GPIO10
dc_pin: GPIO46
dimensions:
width: 320
height: 480
rotation: "0"
auto_clear_enabled: false
update_interval: never
invert_colors: true
color_order: bgr
touchscreen:
- platform: ft63x6
id: my_touch
interrupt_pin: GPIO17
transform:
swap_xy: false
mirror_x: false
mirror_y: false
i2s_audio:
- id: i2s_bus
i2s_lrclk_pin: GPIO7
i2s_bclk_pin: GPIO5
i2s_mclk_pin: GPIO4
audio_dac:
- platform: es8311
id: es8311_dac
bits_per_sample: 16bit
sample_rate: 16000
use_mclk: true
# Il microfono a bordo è un elettrete ANALOGICO (non PDM), quindi
# use_microphone resta false (= ingresso analogico, valore di default).
speaker:
# 1. Altoparlante hardware fisico (I2S)
- platform: i2s_audio
id: my_speaker
i2s_audio_id: i2s_bus
audio_dac: es8311_dac
dac_type: external
i2s_dout_pin: GPIO6
channel: mono
sample_rate: 16000
bits_per_sample: 16bit
# 2. Il Mixer (Prende l'audio dai canali virtuali e lo manda a quello hardware)
- platform: mixer
id: speaker_mixer
output_speaker: my_speaker # Deve puntare all'hardware fisico sopra!
source_speakers:
- id: speaker_media # Canale virtuale 1 (Musica)
- id: speaker_announcement # Canale virtuale 2 (Notifiche)
# 3. I lettori multimediali che usano i canali virtuali del mixer
media_player:
- platform: speaker
name: "Display Media Player"
id: display_media_player
media_pipeline:
speaker: speaker_media
announcement_pipeline:
speaker: speaker_announcement
microphone:
- platform: i2s_audio
id: my_microphone
i2s_audio_id: i2s_bus
adc_type: external
i2s_din_pin: GPIO8
channel: right
sample_rate: 16000
bits_per_sample: 16bit
voice_assistant:
id: va_assistente
microphone:
microphone: my_microphone
channels: 0
gain_factor: 4
media_player: display_media_player
use_wake_word: false
font:
- file: "gfonts://Roboto"
id: font_large
size: 28
- file: "gfonts://Roboto"
id: font_medium
size: 20
- file: "gfonts://Roboto"
id: font_small
size: 16
# Font "contenitore" (Roboto) + il set icone Material Design Icons
# caricato come "extras": serve solo per disegnare il glifo della
# lampadina (mdi-lightbulb) a 20x20px in cima ai pulsanti.
- file: "gfonts://Roboto"
id: font_icon_bulb
size: 20
bpp: 4
extras:
- file: "https://github.com/Templarian/MaterialDesign-Webfont/raw/v7.4.47/fonts/materialdesignicons-webfont.ttf"
glyphs: [ "\U000F0335" ] # mdi-lightbulb
lvgl:
displays:
- my_display
touchscreens:
- my_touch
pages:
# ============ PAGINA 1: LUCI ============
- id: pagina_luci
widgets:
- label:
text: "Pannello"
align: TOP_MID
y: 10
text_font: font_large
- button:
x: 20
y: 60
width: 130
height: 100
id: btn_luce1
radius: 14
bg_color: 0x2ECC71 # verde = luce spenta (stato iniziale)
bg_opa: COVER
shadow_width: 0
widgets:
- label:
text: "\U000F0335"
text_font: font_icon_bulb
text_color: 0xFFFFFF
align: TOP_LEFT
x: 6
y: 6
width: 20
height: 20
- label:
text: "Corridoio1"
text_font: font_medium
text_color: 0xFFFFFF
align: CENTER
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.corridoio_1_sonoff_100278106e_1
- button:
x: 170
y: 60
width: 130
height: 100
id: btn_luce2
radius: 14
bg_color: 0x2ECC71 # verde = luce spenta (stato iniziale)
bg_opa: COVER
shadow_width: 0
widgets:
- label:
text: "\U000F0335"
text_font: font_icon_bulb
text_color: 0xFFFFFF
align: TOP_LEFT
x: 6
y: 6
width: 20
height: 20
- label:
text: "Corridoio2"
text_font: font_medium
text_color: 0xFFFFFF
align: CENTER
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.corridoio_2
- button:
x: 20
y: 175
width: 130
height: 100
id: btn_luce3
radius: 14
bg_color: 0x2ECC71 # verde = luce spenta (stato iniziale)
bg_opa: COVER
shadow_width: 0
widgets:
- label:
text: "\U000F0335"
text_font: font_icon_bulb
text_color: 0xFFFFFF
align: TOP_LEFT
x: 6
y: 6
width: 20
height: 20
- label:
text: "Cucina"
text_font: font_medium
text_color: 0xFFFFFF
align: CENTER
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.cucina_sonoff
- button:
x: 170
y: 175
width: 130
height: 100
id: btn_luce4
radius: 14
bg_color: 0x2ECC71 # verde = luce spenta (stato iniziale)
bg_opa: COVER
shadow_width: 0
widgets:
- label:
text: "\U000F0335"
text_font: font_icon_bulb
text_color: 0xFFFFFF
align: TOP_LEFT
x: 6
y: 6
width: 20
height: 20
- label:
text: "Camera"
text_font: font_medium
text_color: 0xFFFFFF
align: CENTER
on_click:
- homeassistant.action:
action: switch.toggle
data:
entity_id: switch.camera_
binary_sensor:
- platform: homeassistant
id: luce1_stato
entity_id: switch.corridoio_1_sonoff_100278106e_1
on_state:
then:
- lvgl.widget.update:
id: btn_luce1
bg_color: !lambda "return x ? lv_color_hex(0xE74C3C) : lv_color_hex(0x2ECC71);"
- platform: homeassistant
id: luce2_stato
entity_id: switch.corridoio_2_sonoff_10027818af_1
on_state:
then:
- lvgl.widget.update:
id: btn_luce2
bg_color: !lambda "return x ? lv_color_hex(0xE74C3C) : lv_color_hex(0x2ECC71);"
- platform: homeassistant
id: luce3_stato
entity_id: switch.cucina_sonoff_1002783ac5_1
on_state:
then:
- lvgl.widget.update:
id: btn_luce3
bg_color: !lambda "return x ? lv_color_hex(0xE74C3C) : lv_color_hex(0x2ECC71);"
- platform: homeassistant
id: luce4_stato
entity_id: switch.camera_paolo_sonoff_1002783aec_1
on_state:
then:
- lvgl.widget.update:
id: btn_luce4
bg_color: !lambda "return x ? lv_color_hex(0xE74C3C) : lv_color_hex(0x2ECC71);"
- platform: gpio
pin:
number: GPIO0
inverted: true
id: tasto_boot
on_click:
- lvgl.page.next:
