ESP32 S3 Box3

I have the at581x radar configured, with the following relevant code in my firmware:

at581x:
  id: "Radar"
  i2c_id: bus_a

switch:
  - platform: at581x
    at581x_id: "Radar"
    name: "Enable Radar"

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO21
    name: "Presence detect"
    disabled_by_default: false
    publish_initial_state: true
    device_class: "occupancy"
    filters:
      - delayed_off: !lambda return id(radar_delayed_off).state * 1000;
    (further code here which is not relevant)

However, when I turn the Radar switch on and off I get the following error in my log:

[E][at581x:188]: Failed to write AT581X RF mode

I think this is why Radar is always on even if I turn it off (@CChris, this may be why even when you turn the radar off, the device still shuts off the display when no motion is detected - I presume that if the radar switch worked, and the radar was off, it wouldn’t trigger no presence/motion state).

Does anyone else get this error?

I had to change the radar bus…
that was a mistake from my side - it is bus_b

at581x:
  id: "Radar"
  i2c_id: bus_b

with this config, the display goes off, when the “timeout” for movement has been reached, but then, it will not turn on again, because the radar has been disabled

Thanks for that. I fixed my repository so that the radar works and the display doesn’t go off if the radar is turned off.

1 Like

impossible compile

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

font:

  • file:
    type: gfonts
    family: Orbitron
    weight: 500
    glyphs: “0123456789:”
    id: font_large

    bpp: 4

    size: 95

text_sensor:

  • id: text_time
    platform: homeassistant
    entity_id: sensor.local_clock
    on_value:
    then:
    - component.update: s3_box_lcd
  • id: time_remaining
    platform: homeassistant
    entity_id: sensor.remaining_time
    on_value:
    then:
    - component.update: s3_box_lcd

color:

  • id: countdown_color
    hex: “FFEA00”

display:

  • id: !extend s3_box_lcd #<—this is the important part.
    pages:
    • id: !extend idle_page #<—this is the important part.
      lambda: |-
      it.fill(id(loading_color));
      it.printf(160, 120, id(font_large), id(listening_color), TextAlign::CENTER,

i2c:

  • id: bus_a
    sda: GPIO38
    scl: GPIO39
    scl_pullup_enabled: true
    frequency: 50kHz

  • id: bus_b
    sda: GPIO2
    scl: GPIO1
    scl_pullup_enabled: true
    frequency: 50kHz

sensor:

  • platform: aht10
    i2c_id: bus_b
    variant: AHT20
    temperature:
    name: “Temperature”
    id: s3temp
    humidity:
    name: “Humidity”
    update_interval: 60s

  • platform: adc
    pin: GPIO10
    name: “Battery voltage”
    id: battery_voltage
    unit_of_measurement: “V”
    accuracy_decimals: 1
    device_class: “voltage”
    entity_category: “diagnostic”
    disabled_by_default: true
    update_interval: 30s
    attenuation: auto
    filters:
    - multiply: 4.11

  • platform: copy
    id: battery_percent
    source_id: battery_voltage
    name: “Battery level”
    unit_of_measurement: “%”
    accuracy_decimals: 0
    device_class: “battery”
    entity_category: “diagnostic”
    filters:

    • lambda: return (x - 2.7) / (4.2 - 2.7) * 100;
    • clamp:
      min_value: 0
      max_value: 100

number:

  • platform: template
    name: “Presence duration”
    id: radar_delayed_off
    icon: mdi:account-clock
    optimistic: true
    restore_value: true
    initial_value: 60
    min_value: 0
    step: 5
    max_value: 300
    unit_of_measurement: s
    entity_category: config
    mode: box

binary_sensor:

  • platform: gpio
    pin:
    number: GPIO21
    name: “Presence detect”
    disabled_by_default: false
    publish_initial_state: true
    device_class: “occupancy”
    filters:
    • delayed_off: !lambda return id(radar_delayed_off).state * 1000;
      on_release:
      then:
      • if:
        condition:
        switch.is_on: mute_when_absent
        then:
        - switch.turn_on: mute
        - light.turn_off: led
        on_press:
        then:
      • if:
        condition:
        switch.is_on: mute_when_absent
        then:
        - switch.turn_off: mute
        - light.turn_on: led

at581x:
id: “Radar”
i2c_id: bus_b

thanks mate, that’s awsome :smiley:
Now, I have just to adjust some of the display elements and place them as I want.

Think that don’t seem to work (or maybe, because I made some errors while adopting your changes to my config)

  • volume up/down/speaker mute does not work when it is playing media files (f.e. HomeAssistant RadioBrowser)
  • when it’s playing back media, it is using the “reply” image, not the “media playback” image…

I wonder also, if it would be possible, to show somehow where the touch areas on the device are…
Maybe, some color-gradient in the background? :thinking:

Place the yaml between three backticks so we can properly see it. See chapter 11 of:

It looks like you arent using the default s3-box3 yaml configuration but someone elses. If you have the entire config in your yaml, you can just add the color, the text_sensor and the font to those existing sections. You’ll need to expose a local_clock text sensor and a timer text sensor from HA. You can create the timer and a template sensor for local_clock (template is just {{ now().timestamp() | timestamp_custom('%-I:%M') }} ) in your helpers section of devices and this is what i have in my configuration.yaml for remaining_time:

template:
  - trigger:
      - platform: time_pattern
        seconds: '/1'
    sensor:
      name: Remaining Time
      unique_id: remaining_time
    #   availability: >
    #     {{ state_attr('timer.timer1', 'finishes_at') | has_value }}
      state: >
          {% set entity_id = state_attr('timer.timer1', 'finishes_at') %}
          {% if entity_id != None %}
            {{ ((entity_id | as_datetime) - now()).total_seconds() | int | timestamp_custom('%-M:%S', default=0) }}          
          {% else %}
            0:00
          {% endif %}
1 Like

thank you it works

1 Like

EDIT: Never mind, my fault.

It’s not your adoption of the code. I consider the box3 to be primarily a voice assistant, rather than a media player (given the low quality of the speaker I didn’t think I would use it to listen to anything). As such, I didn’t pay much attention to the media player functions, other than using it as a speaker for the VA, and maybe for short announcements. This is why I used the reply image for playback and why I haven’t implemented the mute and volume functions when it is playing media (the volume up and down and mute do work during playback [the volume changes and mutes] but don’t show on the screen during playback).

I am happy to change the image to a “media playback” one, but I don’t have an image in that style for that purpose. Do you have one?

In my case, I can’t even play anything from the RadioBrowser on it - it fails to play and I am not sure why (it plays local files fine). I may look into making the volume controls graphics work when playing when I have some time, but for my usage it is not really an issue.

With the touch areas, it’s a good idea and I am sure it is possible, but I don’t really have time to look into it (too many projects :crazy_face:)

Hello all. Well I it seemed to me that my problems were somehow related to either the hardware my HA was installed on or the BOX3 itself. Since I could reflash the origanal espressif demo firmware with no problems I decided to tackle my HA hardware. I set up a NEW HA on a RPI 5 with 8GB ram and a 5 amp Pi power supply. I was sure I was ready to go!
Nope.
I cleaned out the BOX3, the used ESPHome to re-provision it, set the wifi and add it to my HA. All went well. But when I went to adopt it in ESPHome, the installation threw this out there…

INFO ESPHome 2024.5.5
INFO Reading configuration /config/esphome/esp32-s3-box-3-0502c8.yaml...
INFO Updating https://github.com/esphome/esphome.git@pull/5230/head
WARNING GPIO0 is a strapping PIN and should only be used for I/O with care.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
INFO Generating C++ source...
INFO Updating https://github.com/jesserockz/esp32-s3-box-3-board.git@main
INFO Updating https://github.com/espressif/[email protected]
INFO Updating submodules (components/esp-sr, components/esp-adf-libs) for https://github.com/espressif/[email protected]
Traceback (most recent call last):
  File "/usr/local/bin/esphome", line 33, in <module>
    sys.exit(load_entry_point('esphome', 'console_scripts', 'esphome')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1065, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 1052, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 479, in command_run
    exit_code = write_cpp(config)
                ^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 193, in write_cpp
    return write_cpp_file()
           ^^^^^^^^^^^^^^^^
  File "/esphome/esphome/__main__.py", line 211, in write_cpp_file
    writer.write_cpp(code_s)
  File "/esphome/esphome/writer.py", line 344, in write_cpp
    copy_src_tree()
  File "/esphome/esphome/writer.py", line 297, in copy_src_tree
    copy_files()
  File "/esphome/esphome/components/esp32/__init__.py", line 684, in copy_files
    repo_dir, _ = git.clone_or_update(
                  ^^^^^^^^^^^^^^^^^^^^
  File "/esphome/esphome/git.py", line 111, in clone_or_update
    run_git_command(
  File "/esphome/esphome/git.py", line 31, in run_git_command
    raise cv.Invalid(lines[-1][len("fatal: ") :])
voluptuous.error.Invalid: Unable to find current revision in submodule path 'components/esp-sr'

Anyone care to give me some clues on what is wrong here?
Perhaps my BOX3 is just trashed, even though it is connected to my network and HA and appears to be ready to have the YAML installed.
I’m really stumped.

Clean your build files and try again.

Thank you janstadt. I agree with you and I do a “clean build files” each time I try to do an install. After everything I’ve tried I’ve concluded that the box3 is defective. My conclusion is based on the fact that under the original espressif demo flash, only the temp/humidity and media player actually work.
I think I’ve exhausted my Box3 patience.
Thank you for replying.

Hello with the project of Lajos who gives me his authorization to modify it and post it to you he did a good job

S3-Box-3-firmware-fork/firmware.yaml at main · youkorr/S3-Box-3-firmware-fork (github.com)

2 Likes

Thank you youkorr. I will try it. I appreciate your willingness to help
I’ll report back.

1 Like

Bummer. Are you trying over wifi or connected directly to your machine? One other idea you could try is build the binary and download it, the. Connect your device at the espome flash site and upload the binary to it. I had some issues jumping from different yaml configs and ended up having to do this method but it works. Just make sure to connect and do the “prepare first time use” option or something along those lines before you flash.

Do you have in your code the following:

esp_adf:
  board: esp32s3box3

If so, delete it and try again. I wonder if this is the cause of your error.

First of all, THANK YOU to everyone who tried to help me. I appreciate it! This really is a great community .

Lesson learned:
When you add your device into Home Assistant, don’t change the PORT of the node you’re adding. I made the mistake of thinking that there’s no way that ESPHome knows what port to use on a new device and if I cleared that field, it would use whatever the default was. Boy was I wrong!

So, I left the port alone this time and everything worked great. I installed the yaml that “youkorr” provided and it installed without a hitch.

Again, thank you to everyone and I’m sorry I took up so much of your time with my bonehead mistake.

2 Likes

but for me the most beautiful is modifiable by yourself and the bobbas firmware which I recommend

3 Likes

btw:
has anyone already solved the topic, that the device will be shown as offline in the ESPHomeDashboard?
And that it does not get the ESPHomeUpdates?