Everyday Presence 1 with i2s microphone

I’am a happy user of the EP1.
Last week i installed microphones in every ep1 i have around the house in the hopes i could make te ultimate sensor.

I made it work but not really reliable, after some time it times out and the mic is not responding anymore.

The voice assistant is not always active, or it is and after a while it just stops then i have to disable the wake word and actived it again to work.

Is the esp32-wroom not powerfull enough to run everything? or more likely am i making a mistake.
i will try to keep an eye out on the errors its trowing my way.

If i made a mistake hopefully somebody can help me make it more stable.

The following code is what i’am using:

substitutions:
  name: "woonkamer-multisensor"
  room: "Woonkamer"
  friendly_name: "Woonkamer Multisensor"
  project_name: "Everything Smart Technology.Everything Presence One"
  project_version: "1.1.7"
  temperature_offset: "-3"
  humidity_offset: "5"
  temperature_update_interval: "60s"
  illuminance_update_interval: "30s"
  pir_delay_off: "10s"
  occupancy_delay_off: "15s"
  hidden_ssid: "false"
  factory_reset_disabled: "true"
  uart_target_output_disabled: "true"
  uart_presence_output_disabled: "true"

esphome:
  name: "${name}"
  friendly_name: ${friendly_name}
  name_add_mac_suffix: true
  project:
    name: "${project_name}"
    version: "${project_version}"
  on_boot:
     - priority: -100
       then:
         - wait_until: api.connected
         - delay: 1s
         - if:
             condition:
               switch.is_on: use_wake_word
             then:
               - voice_assistant.start_continuous:

esp32:
  board: esp32dev
  framework:
    type: esp-idf
    version: recommended

logger:

ota:
  password: "****************"


api:
  encryption:
    key: "****************"

web_server:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
      static_ip: ***
      gateway: ***
      subnet: ***
  ap:
    ssid: "Woonkamer Fallback Hotspot"
    password: "***"

bluetooth_proxy: 

captive_portal:
  
improv_serial:

i2s_audio:
  i2s_lrclk_pin: GPIO18
  i2s_bclk_pin: GPIO19

microphone:
  - platform: i2s_audio
    id: mic
    adc_type: external
    i2s_din_pin: GPIO23
    pdm: false

voice_assistant:
  microphone: mic
  use_wake_word: true
  noise_suppression_level: 1
  auto_gain: 31dBFS
  volume_multiplier: 5.0
  id: assist

esp32_improv:
  authorizer: none

dashboard_import:
  package_import_url: github://everythingsmarthome/everything-presence-one/everything-presence-one.yaml@main
  import_full_config: false

light:
  - platform: status_led
    name: ESP32 status LED
    pin: GPIO32
    entity_category: config
    disabled_by_default: True
  - platform: binary
    name: mmWave LED
    restore_mode: RESTORE_DEFAULT_OFF
    output: mmwave_led_output
    entity_category: config
    disabled_by_default: True

output:
  - platform: template
    id: mmwave_led_output
    type: binary
    write_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - if:
          condition:
            lambda: !lambda return state;
          then:
            - uart.write: "setLedMode 1 0"
          else:
            - uart.write: "setLedMode 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor

i2c:
  sda: 26
  scl: 25
  scan: true

sensor:
  - platform: shtcx
    id: "shtc3_sensor"
    temperature:
      name: ${room} Temperatuur
      id: temperature_sensor
      filters:
        - offset: ${temperature_offset}
        - lambda: "return x + id(temperature_offset_ui).state;"
    humidity:
      name: ${room} Luchtvochtigheid
      id: humidity_sensor
      filters:
        - offset: ${humidity_offset}
        - lambda: "return x + id(humidity_offset_ui).state;"
    address: 0x70
    update_interval: ${temperature_update_interval}
  - platform: bh1750
    name: ${room} Lichtsterkte
    id: illuminance_sensor
    address: 0x23
    update_interval: ${illuminance_update_interval}
    filters:
      - lambda: "return x + id(illuminance_offset_ui).state;"

binary_sensor:
  - platform: gpio
    name: ${room}mmWave
    id: mmwave
    device_class: occupancy
    pin:
      number: GPIO15
      mode: INPUT_PULLDOWN
  - platform: gpio
    pin:
      number: 33
      mode: INPUT_PULLDOWN
    name: ${room} Bewegingsmelder
    id: pir_motion_sensor
    device_class: motion
    filters:
      - delayed_off:  !lambda 'return id(pir_off_latency).state * 1000.0;'
  - platform: template
    name: ${room} Bezet
    id: occupancy
    device_class: occupancy
    filters:
      - delayed_off: !lambda 'return id(occupancy_off_latency).state * 1000.0;'
    on_state:
      - lambda: 'id(illuminance_sensor).update();'
    lambda: |-
      if ( id(mmwave).state or id(pir_motion_sensor).state) {
        return true;
      } 
      else if (id(mmwave).state == 0 and id(pir_motion_sensor).state == 0) {
        return false;
      } 
      else {
        return id(occupancy).state;
      }
uart:
  id: uart_bus
  tx_pin: GPIO13
  rx_pin: GPIO14
  baud_rate: 115200
  debug:
    direction: BOTH
    dummy_receiver: true
    after:
      delimiter: "\n"
    sequence:
      - lambda: UARTDebug::log_string(direction, bytes);

switch:
  - platform: template
    name: mmWave sensor
    id: mmwave_sensor
    disabled_by_default: True
    entity_category: config
    optimistic: true
    restore_mode: RESTORE_DEFAULT_ON
    turn_on_action:
      - uart.write: "sensorStart"
      - delay: 1s
    turn_off_action:
      - uart.write: "sensorStop"
      - delay: 1s
  - platform: template
    name: Use wake word
    id: use_wake_word
    optimistic: true
    restore_mode: RESTORE_DEFAULT_ON
    entity_category: config
    on_turn_on:
      - lambda: id(assist).set_use_wake_word(true);
      - if:
          condition:
            not:
              - voice_assistant.is_running
          then:
            - voice_assistant.start_continuous
    on_turn_off:
      - voice_assistant.stop
      - lambda: id(assist).set_use_wake_word(false);

  - platform: template
    name: UART presence output
    id: uart_presence_output
    entity_category: config
    internal: ${uart_presence_output_disabled}
    optimistic: true
    turn_on_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
    turn_off_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 1 0"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: UART target output
    id: uart_target_output
    entity_category: config
    internal: ${uart_target_output_disabled}
    optimistic: true
    assumed_state: false
    turn_on_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 2 1 1 1"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
    turn_off_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "setUartOutput 2 0"
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 3s
      - switch.turn_on: mmwave_sensor

number:
  - platform: template
    id: mmwave_distance
    name: mmWave distance
    icon: mdi:arrow-left-right
    entity_category: config
    min_value: 0
    max_value: 800
    initial_value: 315
    optimistic: true
    step: 15
    restore_value: true
    unit_of_measurement: cm
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda int cm = (int)ceil(x / 15.0);
          std::string cms = "detRangeCfg -1 0 " + to_string(cm);
          return std::vector<unsigned char>(cms.begin(), cms.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave off latency
    icon: mdi:clock-end
    entity_category: config
    id: mmwave_off_latency
    min_value: 1
    max_value: 600
    initial_value: 15
    optimistic: true
    step: 5
    restore_value: true
    unit_of_measurement: seconds
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda |-
          std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave on latency
    icon: mdi:clock-start
    id: mmwave_on_latency
    entity_category: config
    min_value: 0
    max_value: 2
    initial_value: 0
    optimistic: true
    step: 0.25
    restore_value: true
    unit_of_measurement: seconds
    mode: slider
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: !lambda |-
          std::string mss = "setLatency " + to_string(id(mmwave_on_latency).state) + " " + to_string(id(mmwave_off_latency).state);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveCfg 0x45670123 0xCDEF89AB 0x956128C6 0xDF54AC89"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: mmWave sensitivity
    icon: mdi:target-variant
    id: mmwave_sensitivity
    entity_category: config
    min_value: 0
    max_value: 9
    initial_value: 7
    optimistic: true
    step: 1
    restore_value: true
    set_action:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write:
          !lambda std::string mss = "setSensitivity " + to_string((int)x);
          return std::vector<unsigned char>(mss.begin(), mss.end());
      - delay: 1s
      - uart.write: "saveConfig"
      - delay: 1s
      - switch.turn_on: mmwave_sensor

  - platform: template
    name: Occupancy off latency
    icon: mdi:clock-end
    entity_category: config
    id: occupancy_off_latency
    min_value: 1
    max_value: 600
    initial_value: 15
    optimistic: true
    step: 5
    restore_value: true
    unit_of_measurement: seconds
    mode: slider

  - platform: template
    name: PIR off latency
    icon: mdi:clock-end
    entity_category: config
    id: pir_off_latency
    min_value: 1
    max_value: 120
    initial_value: 10
    optimistic: true
    step: 1
    restore_value: true
    unit_of_measurement: seconds
    mode: slider

  - platform: template
    name: "Temperature Offset"
    id: temperature_offset_ui
    unit_of_measurement: "°C"
    min_value: -20
    max_value: 20
    step: 0.1
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 0
    icon: "mdi:thermometer"
    entity_category: config
    on_value:
      - lambda: 'id(shtc3_sensor).update();'
  - platform: template
    name: "Humidity Offset"
    id: humidity_offset_ui
    unit_of_measurement: "%"
    min_value: -50
    max_value: 50
    step: 0.1
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 0
    icon: "mdi:water-percent"
    entity_category: config
    on_value:
      - lambda: 'id(shtc3_sensor).update();'
  - platform: template
    name: "Illuminance Offset"
    id: illuminance_offset_ui
    unit_of_measurement: "lx"
    min_value: -50
    max_value: 50
    step: 1
    mode: box
    update_interval: never
    optimistic: true
    restore_value: true
    initial_value: 0
    icon: "mdi:brightness-5"
    entity_category: config
    on_value:
      - lambda: 'id(illuminance_sensor).update();'

button:
  - platform: restart
    id: restart_internal
    entity_category: config
    internal: true
  - platform: template
    name: Restart mmWave sensor
    id: restart_mmwave
    entity_category: config
    internal: true
    on_press:
      - uart.write: "resetSystem"
  - platform: template
    name: Restart
    icon: mdi:restart
    entity_category: config
    disabled_by_default: True
    on_press:
      - button.press: restart_mmwave
      - button.press: restart_internal
  - platform: safe_mode
    internal: false
    name: Safe mode
    entity_category: config
    disabled_by_default: True
  - platform: template
    name: Factory reset mmWave
    icon: mdi:cog-counterclockwise
    id: factory_reset_mmwave
    internal: ${factory_reset_disabled}
    entity_category: config
    on_press:
      - switch.turn_off: mmwave_sensor
      - delay: 1s
      - uart.write: "resetCfg"
      - delay: 3s
      - switch.turn_on: mmwave_sensor
1 Like

Little bump