nur Bahnhof

ESP32-C3 + WS2812 + battery

(moved over from https://git.h.oluflorenzen.de/finkregh/scratchpad/wiki/ESP32-C3+%2B+WS2812+%2B+battery.-)

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:

 1---
 2esp32:
 3  board: seeed_xiao_esp32c3
 4  #variant:
 5  flash_size: 4MB
 6
 7# not available on esp32c3
 8# perhaps some help is available here: <https://community.home-assistant.io/t/seeed-studio-xiao-esp32c3-seeed-xiao-esp32c3-enable-touchpad/794810>
 9#esp32_touch:
10#  setup_mode: true
11#
12#binary_sensor:
13#  - platform: esp32_touch
14#    name: "ESP32 Touch Pad GPIO20"
15#    pin: GPIO20
16#    threshold: 1000
17#  - platform: esp32_touch
18#    name: "ESP32 Touch Pad GPIO21"
19#    pin: GPIO21
20#    threshold: 1000
21
22light:
23  - platform: neopixelbus
24    type: GRB
25    variant: WS2812
26    pin: GPIO3
27    num_leds: 2
28    name: "NeoPixel Light"
29    id: star_leds
30    restore_mode: ALWAYS_ON
31    on_turn_on:
32      - light.turn_on:
33          id: star_leds
34          effect: "My Slow Random Effect"
35    effects:
36      - random:
37      - random:
38          name: "My Slow Random Effect"
39          transition_length: 30s
40          update_interval: 30s
41      - random:
42          name: "My Fast Random Effect"
43          transition_length: 4s
44          update_interval: 5s
45      - pulse:
46      - pulse:
47          name: "Fast Pulse"
48          transition_length: 0.5s
49          update_interval: 0.5s
50          min_brightness: 0%
51          max_brightness: 100%
52      - pulse:
53          name: "Slow Pulse"
54          # transition_length: 1s      # defaults to 1s
55          update_interval: 2s
56      - pulse:
57          name: "Asymmetrical Pulse"
58          transition_length:
59            on_length: 1s
60            off_length: 500ms
61          update_interval: 1.5s
62      - addressable_twinkle:
63      - addressable_twinkle:
64          name: Twinkle Effect With Custom Values
65          twinkle_probability: 5%
66          progress_interval: 4ms
67
68esphome:
69  name: "a-star"
70
71# Enable Home Assistant API
72api:
73  encryption:
74    key: "" # get a random string from <https://esphome.io/components/api.html>
75
76ota:
77  platform: esphome
78  password: "" # just use a random string
79
80wifi:
81  #ssid: ""
82  #password: ""
83
84  # Enable fallback hotspot (captive portal) in case wifi connection fails or no credentials have been saved (see above)
85  # you will need to wait 1 minute for this to come up if credentials have been entered and the device is searching for wifi
86  ap:
87    ssid: "A-Star Fallback Hotspot"
88    password: "esphome1234"
89
90captive_portal:
91
92# Enable logging
93logger:
94
95# internal webserver
96web_server:
97  port: 80
98  # all content served from flash, inline
99  local: true

Simple variant for standalone operation

 1---
 2esp32:
 3  board: seeed_xiao_esp32c3
 4  #variant:
 5  flash_size: 4MB
 6
 7# not available on esp32c3
 8# perhaps some help is available here: <https://community.home-assistant.io/t/seeed-studio-xiao-esp32c3-seeed-xiao-esp32c3-enable-touchpad/794810>
 9#esp32_touch:
10#  setup_mode: true
11#
12#binary_sensor:
13#  - platform: esp32_touch
14#    name: "ESP32 Touch Pad GPIO20"
15#    pin: GPIO20
16#    threshold: 1000
17#  - platform: esp32_touch
18#    name: "ESP32 Touch Pad GPIO21"
19#    pin: GPIO21
20#    threshold: 1000
21
22light:
23  - platform: neopixelbus
24    type: GRB
25    variant: WS2812
26    pin: GPIO3
27    num_leds: 2
28    name: "NeoPixel Light"
29    id: star_leds
30    restore_mode: ALWAYS_ON
31    on_turn_on:
32      - light.turn_on:
33          id: star_leds
34          effect: "My Slow Random Effect"
35    effects:
36      - random:
37      - random:
38          name: "My Slow Random Effect"
39          transition_length: 30s
40          update_interval: 30s
41      - random:
42          name: "My Fast Random Effect"
43          transition_length: 4s
44          update_interval: 5s
45      - pulse:
46      - pulse:
47          name: "Fast Pulse"
48          transition_length: 0.5s
49          update_interval: 0.5s
50          min_brightness: 0%
51          max_brightness: 100%
52      - pulse:
53          name: "Slow Pulse"
54          # transition_length: 1s      # defaults to 1s
55          update_interval: 2s
56      - pulse:
57          name: "Asymmetrical Pulse"
58          transition_length:
59            on_length: 1s
60            off_length: 500ms
61          update_interval: 1.5s
62      - addressable_twinkle:
63      - addressable_twinkle:
64          name: Twinkle Effect With Custom Values
65          twinkle_probability: 5%
66          progress_interval: 4ms
67
68esphome:
69  name: "stern-test"
70
71ota:
72  platform: esphome
73  password: "" # a random string
74
75wifi:
76  ssid: ""
77  password: ""
78
79  # Enable fallback hotspot (captive portal) in case wifi connection fails or no credentials have been saved (see above)
80  # you will need to wait 1 minute for this to come up if credentials have been entered and the device is searching for wifi
81  ap:
82    ssid: "a-star Fallback Hotspot"
83    password: "esphome1234"
84
85captive_portal:
86
87# Enable logging
88#logger:
89
90# internal webserver
91web_server:
92  port: 80
93  # all content served from flash, inline
94  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.

Comments

#esp32 #iot #esphome #ws2812

Reply to this post by email ↪