1
0
Fork 0
1 ESP32-C3 + WS2812 + battery
finkregh edited this page 2024-11-14 17:58:57 +00:00

The wonderful bleeptrack created https://a-star.bleeptrack.de/, and shows https://vis.social/@bleeptrack/113350197702251142 that you can put some LEDs in them to make them extra fancy.

This is a howto with parts, connections, configuration examples.

Features

Parts used

ESPHome / Homeassistant integration

All config values can be looked up in the esphome documentation: https://esphome.io/

This configuration will:

  • be discoverable in HomeAssistant
  • enable the LEDs with slowly randomly changing colors
  • enable an wifi access point in case the wifi connection breaks or no credentials have been saved
  • log events (visible in e.g. the devices' website)
  • enable a webserver, where you can configure the light (access via e.g. http://a-star.local)
---
esp32:
 board: seeed_xiao_esp32c3
 #variant: 
 flash_size: 4MB

# not available on esp32c3
# perhaps some help is available here: <https://community.home-assistant.io/t/seeed-studio-xiao-esp32c3-seeed-xiao-esp32c3-enable-touchpad/794810>
#esp32_touch:
#  setup_mode: true
#
#binary_sensor:
#  - platform: esp32_touch
#    name: "ESP32 Touch Pad GPIO20"
#    pin: GPIO20
#    threshold: 1000
#  - platform: esp32_touch
#    name: "ESP32 Touch Pad GPIO21"
#    pin: GPIO21
#    threshold: 1000

light:
 - platform: neopixelbus
   type: GRB
   variant: WS2812
   pin: GPIO3
   num_leds: 2
   name: "NeoPixel Light"
   id: star_leds
   restore_mode: ALWAYS_ON
   on_turn_on:
       - light.turn_on:
           id: star_leds
           effect: "My Slow Random Effect"
   effects:
     - random:
     - random:
         name: "My Slow Random Effect"
         transition_length: 30s
         update_interval: 30s
     - random:
         name: "My Fast Random Effect"
         transition_length: 4s
         update_interval: 5s
     - pulse:
     - pulse:
         name: "Fast Pulse"
         transition_length: 0.5s
         update_interval: 0.5s
         min_brightness: 0%
         max_brightness: 100%
     - pulse:
         name: "Slow Pulse"
         # transition_length: 1s      # defaults to 1s
         update_interval: 2s
     - pulse:
         name: "Asymmetrical Pulse"
         transition_length:
           on_length: 1s
           off_length: 500ms
         update_interval: 1.5s
     - addressable_twinkle:
     - addressable_twinkle:
         name: Twinkle Effect With Custom Values
         twinkle_probability: 5%
         progress_interval: 4ms

esphome:
   name: "a-star"

# Enable Home Assistant API
api:
 encryption:
   key: "" # get a random string from <https://esphome.io/components/api.html>

ota:
 platform: esphome
 password: "" # just use a random string


wifi:
 #ssid: ""
 #password: ""

 # Enable fallback hotspot (captive portal) in case wifi connection fails or no credentials have been saved (see above)
 # you will need to wait 1 minute for this to come up if credentials have been entered and the device is searching for wifi
 ap:
   ssid: "A-Star Fallback Hotspot"
   password: "esphome1234"

captive_portal:

# Enable logging
logger:

# internal webserver
web_server:
 port: 80
 # all content served from flash, inline
 local: true

Simple variant for standalone operation

---
esp32:
 board: seeed_xiao_esp32c3
 #variant: 
 flash_size: 4MB

# not available on esp32c3
# perhaps some help is available here: <https://community.home-assistant.io/t/seeed-studio-xiao-esp32c3-seeed-xiao-esp32c3-enable-touchpad/794810>
#esp32_touch:
#  setup_mode: true
#
#binary_sensor:
#  - platform: esp32_touch
#    name: "ESP32 Touch Pad GPIO20"
#    pin: GPIO20
#    threshold: 1000
#  - platform: esp32_touch
#    name: "ESP32 Touch Pad GPIO21"
#    pin: GPIO21
#    threshold: 1000

light:
 - platform: neopixelbus
   type: GRB
   variant: WS2812
   pin: GPIO3
   num_leds: 2
   name: "NeoPixel Light"
   id: star_leds
   restore_mode: ALWAYS_ON
   on_turn_on:
       - light.turn_on:
           id: star_leds
           effect: "My Slow Random Effect"
   effects:
     - random:
     - random:
         name: "My Slow Random Effect"
         transition_length: 30s
         update_interval: 30s
     - random:
         name: "My Fast Random Effect"
         transition_length: 4s
         update_interval: 5s
     - pulse:
     - pulse:
         name: "Fast Pulse"
         transition_length: 0.5s
         update_interval: 0.5s
         min_brightness: 0%
         max_brightness: 100%
     - pulse:
         name: "Slow Pulse"
         # transition_length: 1s      # defaults to 1s
         update_interval: 2s
     - pulse:
         name: "Asymmetrical Pulse"
         transition_length:
           on_length: 1s
           off_length: 500ms
         update_interval: 1.5s
     - addressable_twinkle:
     - addressable_twinkle:
         name: Twinkle Effect With Custom Values
         twinkle_probability: 5%
         progress_interval: 4ms

esphome:
   name: "stern-test"

ota:
 platform: esphome
 password: "" # a random string

wifi:
 ssid: ""
 password: ""

 # Enable fallback hotspot (captive portal) in case wifi connection fails or no credentials have been saved (see above)
 # you will need to wait 1 minute for this to come up if credentials have been entered and the device is searching for wifi
 ap:
   ssid: "a-star Fallback Hotspot"
   password: "esphome1234"

captive_portal:

# Enable logging
#logger:

# internal webserver
web_server:
 port: 80
 # all content served from flash, inline
 local: true

Firmware installation

If you connect the board via USB to a computer and follow https://esphome.io/guides/getting_started_command_line#first-uploading you should be able to flash it.

Physical connections / cables

Battery

On the backside of the board you can see BAT with two copper pads above and + / -. Connect the red cable from the battery to + and the black one to -.

WS2812B LEDs

The LEDs can be connected one after another in serial, see Din/Dout on the backside to get an orientation on where stuff goes in and out. For this project I connected the ESP32 board to LED1 via Din and its Dout to Din of LED2.

  • ESP32 GND -> GND[Din side] on LED1

  • ESP32 3V -> 5V[Din side] on LED1

  • ESP32 GPIO 3 -> Din on LED1

  • LED1 all from Dout side to LED2 on Din side