Atom S3 Lite - Toggle GPIO27 Led on Press

Hi All,

Is there a way to toggle Atom Lite led on press the integrated button?
I did some search but I didn’t find anything.

This is what I have at the moment in the yam file:

binary_sensor:
  - platform: status
    name: "Node Status"
    id: system_status
  - platform: gpio
    name: Button
    pin:
      number: GPIO41
      inverted: true
      mode:
        input: true
        pullup: true
    filters:
      - delayed_off: 10ms
    on_press:
      then:
        - homeassistant.service:
            service: ssh_command.exec_command
            data:
              host: "xxxxxxxx"
              port: "xx"
              user: "xxxxxxxxx"
              pass: "xxxxxxxxxxx"
              command: "DISPLAY=:0 mumble rpc togglemute"

What I would like is to turn its led on/off when I press the integrated button (GPIO41)

Thank you!

Thank you for your prompt reply!
Sorry, I am a newbie and maybe I am asking stupid things.
Do I have to declare the light somewhere before add the onclick lines?

I tried adding this:

- platform: gpio
    name: Led
    pin:
      number: GPIO27

But it gives: This pin cannot be used on ESP32-S3s and is already used by the SPI/PSRAM interface(function: SPIHD).

I see on there site that the GPIO is 27:

Hi, here I am again :slight_smile:

I tried this solution using the documentation above (thank you for it), but now I am getting this error when try to compile:

.piolibdeps/esphome-web-6670e8/FastLED/src/sensors/digital_pin.cpp:15:9: warning: "USE_ARDUINO" redefined
   15 | #define USE_ARDUINO 0
      |         ^~~~~~~~~~~
<command-line>: note: this is the location of the previous definition
In file included from .piolibdeps/esphome-web-6670e8/FastLED/src/third_party/yves/I2SClockLessLedDriveresp32s3/driver.h:9,
                 from .piolibdeps/esphome-web-6670e8/FastLED/src/platforms/esp/32/clockless_i2s_esp32s3.cpp:19:
.piolibdeps/esphome-web-6670e8/FastLED/src/third_party/yves/I2SClockLessLedDriveresp32s3/src/I2SClockLessLedDriveresp32s3.h:38:10: fatal error: esp_lcd_panel_interface.h: No such file or directory

***************************************************************************************
* Looking for esp_lcd_panel_interface.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:esp_lcd_panel_interface.h"
* Web  > https://registry.platformio.org/search?q=header:%1B%5Bm%1B%5BKesp_lcd_panel_interface.h
*
***************************************************************************************

   38 | #include "esp_lcd_panel_interface.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pioenvs/esphome-web-6670e8/lib6ad/FastLED/platforms/esp/32/clockless_i2s_esp32s3.cpp.o] Error 1
========================= [FAILED] Took 206.49 seconds =========================

My config is the following:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO35
    num_leds: 4
    rgb_order: GRB
    id: led_1
    name: led_1
    restore_mode: RESTORE_DEFAULT_OFF
    effects:
      - pulse:
          name: "Pulse"
          transition_length: 1s
          update_interval: 1s
      - strobe:
          name: "Strobe"
      - random:
          name: "Random"
          transition_length: 5s
          update_interval: 3s    

binary_sensor:
  - platform: status
    name: "Node Status"
    id: system_status
  - platform: gpio
    name: Button
    pin:
      number: GPIO41
      inverted: true
      mode:
        input: true
        pullup: true
    on_press:
      then:
        - homeassistant.service:
            service: ssh_command.exec_command
            data:
              host: "xxxx"
              port: "xx"
              user: "xxxxxxxx"
              pass: "xxxxxxxxx"
              command: "DISPLAY=:0 mumble rpc togglemute"
    on_release:
      then:
        - light.turn_on:
            id: led_1
            effect: "Random"

Do you have any idea of the problem?

Thank you very much for your help!

I have AtomS3 Lite.

Tried also this:

light:
  - platform: esp32_rmt_led_strip
    rgb_order: GRB
    pin: GPIO35
    num_leds: 1
    rmt_channel: 0
    chipset: WS2812B
    name: "LED"
    id: led_1  

But getting this:

Failed config

light.esp32_rmt_led_strip: [source /config/esphome/esphome-web-6670e8.yaml:49]
  platform: esp32_rmt_led_strip
  rgb_order: GRB
  pin: GPIO35
  num_leds: 1
  
  [rmt_channel] is an invalid option for [light.esp32_rmt_led_strip]. Please check the indentation.
  rmt_channel: 0
  
  Unknown value 'WS2812B', did you mean 'WS2812', 'WS2811', 'SK6812'?.
  chipset: WS2812B
  name: LED
  id: led_1

Sorry, forgot to add the yaml:

substitutions:
  name: esphome-web-6670e8
  friendly_name: M5-lite

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  platformio_options:
    board_build.flash_mode: dio
  project:
    name: esphome.web
    version: '1.0'

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

logger:

api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  platform: esphome
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  networks:
    - ssid: !secret 1_wifi_ssid
      password: !secret 1_wifi_password
    - ssid: !secret 2_wifi_ssid
      password: !secret 2_wifi_password
    - ssid: !secret 3_wifi_ssid
      password: !secret 3_wifi_password

# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO35
    num_leds: 4
    rgb_order: GRB
    id: led_1
    name: LED
    restore_mode: RESTORE_DEFAULT_OFF
    effects:
      - pulse:
          name: "Pulse"
          transition_length: 1s
          update_interval: 1s
      - strobe:
          name: "Strobe"
      - random:
          name: "Random"
          transition_length: 5s
          update_interval: 3s    

binary_sensor:
  - platform: status
    name: "Node Status"
    id: system_status
  - platform: gpio
    name: Button
    pin:
      number: GPIO41
      inverted: true
      mode:
        input: true
        pullup: true
    on_press:
      then:
        - homeassistant.service:
            service: ssh_command.exec_command
            data:
              host: "xxxxxxxxxxxxxxxxx"
              port: "xxxxxxxxxxxx"
              user: "xxxxxxxxxxxxxxxxx"
              pass: "xxxxxxxxxxxxxxxxx"
              command: "DISPLAY=:0 mumble rpc togglemute"
    on_release:
      then:
        - light.turn_on:
            id: led_1
            effect: "Random"

dashboard_import:
  package_import_url: github://esphome/bluetooth-proxies/m5stack-atom-lite.yaml@main

esp32_ble_tracker:
  scan_parameters:
    active: true

bluetooth_proxy:
  active: true

esp32_improv:
  authorizer: none

web_server:

Jus remove the rmt_channel line.
And switch to the IDF framework.

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

Upload with usb-cable.

Got this:

light.esp32_rmt_led_strip: [source /config/esphome/esphome-web-6670e8.yaml:49]
  platform: esp32_rmt_led_strip
  rgb_order: GRB
  pin: GPIO35
  num_leds: 1
  
  Unknown value 'WS2812B', did you mean 'WS2812', 'WS2811', 'SK6812'?.
  chipset: WS2812B
  name: LED
  id: led_1

Looking at the official documentation the following config would be correct:

light:
  - platform: fastled_clockless
    chipset: WS2812B
    pin: GPIO35
    num_leds: 4
    rgb_order: GRB
    id: led_1
    name: led_1
    restore_mode: RESTORE_DEFAULT_OFF
    effects:
      - pulse:
          name: "Pulse"
          transition_length: 1s
          update_interval: 1s
      - strobe:
          name: "Strobe"
      - random:
          name: "Random"
          transition_length: 5s
          update_interval: 3s    

The model is this one: M5Stack ATOM S3 Lite | ESPHome Devices

I also tried to use other options like “remote_transmitter” and it works without any errors…absurd.

Are we talking about Atom S3 Lite or Atom Lite here? I see the title says Atom Lite, and then in the discussions I also see people saying AtomS3 Lite. To be clear, those are different products, even though they look almost the same from the outside.

And, as such, the GPIO # for LED and for the button would therefore be different. @aleisdone you will have to pick the correct GPIO #s based on the device in your hand.

Furthermore, ESPHome recently had a relatively major framework change, maybe last month(?), where the default becomes esp-idf, and arduino becomes a subset of esp-idf.

And if you use the (now default) esp-idf framework, fastled_clockless would not be applicable because that is arduino framework only. The LED control equivalent is esp32_rmt_led_strip, just like what Karosm said above.
The official documentation is not wrong per se, but note that fastled_clockless would work only under arduino framework.

Now, after that, I can see there was another mistake / misdirection / typo by Holdestimade - the chipset: (BTW @Holdestmade where did you get the below from?)

So @aleisdone , the error message you got is saying Unknown value 'WS2812B' , and that was your cue to visit the documentation of the esp32_rmt_led_strip platform. You likely will find that WS2812B is not a thing under esp32_rmt_led_strip, and you will have to try a different one.

Finally, which GPIO did you drive the remote_transmitter component? Did you drive IR or RF signal? What did you mean “it works”…?

Yes I figured that was probably why. S3 or not, arduino or esp-idf, whomever posted it and say it’s working is likely not, simply because:

  • “WS2812B” is an option for fastled_clockless, but not for esp32_rmt_led_strip
  • rmt_channel option is no longer a thing / not an option for esp32_rmt_led_strip either
  • Also the # of LEDs is not correct either, but that’s secondary

Anyways I was trying to explain to OP @aleisdone what has happened. Our goal here is to help him/her.

=====
Now, @aleisdone - I have a AtomS3 Lite, and my LED + button toggling LED config is verified to be compiled & working last week, using esp-idf framework. Do you have what you need at this point? All working? Or do you still need help? I could offer mine as a reference.

Hi @k8gg Thank you for your help.
Just to clarify, and sorry for my inaccuracy, I have the Atmon S3 Lite and the correct GPIO is 35.

Everything is working now!

Thank you also to all of you that help me in fixing it.

I also would change the title of the post to avoid confusion with Atom Lite and Atom S3 lite but seems not possible.

As requested, here is mine, as an example for you / for people to play with. Happy tweaking.

esphome:
  name: my_atoms3_lite
  name_add_mac_suffix: false
  friendly_name: AtomS3 Lite Example

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: esp-idf

# Enable Home Assistant API
api:
  encryption:
    key: 12345-54321-12345

wifi:
  ssid: your_wifi_ssid
  password: your_wifi_password

web_server:

##########################################################
## Adding LED and button controls

light:
  - platform: esp32_rmt_led_strip      # G35=RGB WS2812C-2020
    name: "AtomS3 Lite LED"
    id: atom_led
    icon: "mdi:led-off"
    pin: GPIO35
    chipset: ws2812                    # WS2812B if fastled_clockless
    num_leds: 4                        # There are 4 LEDs in there
    rgb_order: GRB
    restore_mode: RESTORE_DEFAULT_OFF  # When device restarts, LEDs start OFF
    effects:
      - strobe:
          name: "White Strobe"
      - random:
          name: "Random"
          transition_length: 4s  # How long to transition between colors (4 seconds)
          update_interval: 5s    # How often to pick a new random color (5 seconds)
      - pulse:
          name: "Breathing"
          transition_length:
            on_length: 2s
            off_length: 1.5s
          update_interval: 2.5s
          min_brightness: 15%
          max_brightness: 60%
      - pulse:
          name: "Pulse"
          transition_length: 250ms
          update_interval: 300ms
          min_brightness: 10%
          max_brightness: 90%

binary_sensor:
  - platform: gpio
    name: "AtomS3 Lite Button"
    id: atom_button
    icon: "mdi:gesture-tap-button"
    pin:
      number: GPIO41
      inverted: true        # Inverted means pressed=LOW, released=HIGH (common for buttons with pullup)
      mode:
        input: true         # Configure as input (reads signal)
        pullup: true        # Enable internal pullup resistor (keeps pin HIGH when button not pressed)
    filters:
      - delayed_off: 20ms   # Debouncing: Ignore button bouncing for 20 milliseconds
    on_click:
      - min_length: 0s
        max_length: 1s      
        then:
          - light.toggle: atom_led
  - platform: template
    name: "AtomS3 Lite Button Long Press"
    id: atom_button_longpress
    condition:
      binary_sensor.is_on: atom_button
    filters: 
      - delayed_on: 2s
    on_press: 
      then:
        - light.turn_on: 
            id: atom_led
            effect: breathing
            
##########################################################
## Adding Bluetooth Proxy

esp32_ble_tracker:
  scan_parameters:
    # We currently use the defaults to ensure Bluetooth
    # can co-exist with WiFi In the future we may be able to
    # enable the built-in coexistence logic in ESP-IDF
    active: true

bluetooth_proxy:
  active: true
3 Likes