Jaba
(Erwin Hijdra)
September 6, 2020, 12:56pm
1
I am building for my kids a board with a lot of arcade buttons and some other fun things.
I have all the inputs connected and working more or less.
10 buttons with 10 leds on 1 esp32 (working)
5 analoge Resistance Sensors for the sliding potentiometers.
1 SK6812 led strip with 21 leds.
Now what i want and cant figure out how to do it the best way (or any way).
i want to control the RGB values with the Potentiometers so they can slide the red / green and blue channels to mix and match collors.
1 slider will be the white channel
and the last slider will be the brightness control.
I get an Ohm readout of the Potentiometers from 0 to ~10000
In my opinion there are 3 ways to control the led strip.
Internal by the ESP with Esphome and probably some lambda filters (i will need help with that).
by automations within HA
With node red connected to HA
I guess that the first option would be the best but as i mentioned i need help with that.
Someone willing to help me with this for my 2 girls.
Jaba
(Erwin Hijdra)
September 6, 2020, 1:35pm
2
Just my ESPhome config file as it is for now.
Just tried some things that are in there.
Dont bother about that.
substitutions:
bord_name: kids_toys_2_
esphome:
name: ${bord_name}
platform: ESP32
board: lolin32
#board: mhetesp32devkit
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
captive_portal:
# Enable logging
logger:
# Enable Web server
web_server:
port: 80
# Enable Home Assistant API
api:
password: !secret esp_api_password
reboot_timeout: 12h
# Enable over-the-air updates
ota:
password: !secret esp_ota_password
# Sync time with Home Assistant
time:
- platform: homeassistant
id: homeassistant_time
# Text sensors with general information
text_sensor:
# - platform: version
# name: ${bord_name}_version
- platform: wifi_info
ip_address:
name: ${bord_name}_ip
# ssid:
# name: ${bord_name}_ssid
# deep_sleep:
# id: deep_sleep_1
# # run_duration: 30s
# # sleep_duration: 360min
# wakeup_pin: 12
# wakeup_pin_mode: INVERT_WAKEUP
sensor:
# Uptime sensor
- platform: uptime
name: ${bord_name}_Uptime
filters:
- lambda: return x / 3600.0;
unit_of_measurement: "hours"
accuracy_decimals: 2
# WiFi Signal sensor
# - platform: wifi_signal
# name: ${bord_name}_wifi_signal
# update_interval: 60s
# # Batterij Voltage
# - platform: adc
# pin: 32
# name: ${bord_name}_18650_volt
# update_interval: 120s
# attenuation: 11db
# filters:
# - multiply : 1.06
- platform: resistance
sensor: red
configuration: DOWNSTREAM
resistor: 27kOhm
name: ${bord_name}_red
# - platform: resistance
# sensor: green
# configuration: DOWNSTREAM
# resistor: 27kOhm
# name: ${bord_name}_green
# - platform: resistance
# sensor: blue
# configuration: DOWNSTREAM
# resistor: 27kOhm
# name: ${bord_name}_blue
# - platform: resistance
# sensor: white
# configuration: DOWNSTREAM
# resistor: 27kOhm
# name: ${bord_name}_white
# - platform: resistance
# sensor: brightness
# configuration: DOWNSTREAM
# resistor: 27kOhm
# name: ${bord_name}_brightness
######## ADC #########
# Red
- platform: adc
update_interval: 1s
attenuation: 11db
id: red
pin: 39
filters:
## - throttle: 1s
## - heartbeat: 5s
## - debounce: 0.1s
# - delta: 0.001
# - lambda: return x/100;
# - lambda: if (x > 0.001 && x < 0.002) return 1;
# - lambda: if (x > 0.002 && x < 0.003) return 2;
# - lambda: if (x > 0.003 && x < 0.004) return 3;
# - lambda: if (x > 0.004 && x < 0.005) return 4;
# - lambda: if (x > 0.005 && x < 0.006) return 5;
# - lambda: if (x > 0.006 && x < 0.007) return 6;
# - lambda: if (x > 0.007 && x < 0.008) return 7;
# - lambda: if (x > 0.008 && x < 0.009) return 8;
# - lambda: if (x > 0.009 && x < 0.010) return 9;
# - lambda: if (x > 0.010 && x < 0.020) return 10; else return {};
# # Green
# - platform: adc
# update_interval: 1s
# attenuation: 11db
# id: green
# pin: 34
# filters:
# # Blue
# - platform: adc
# update_interval: 1s
# attenuation: 11db
# id: blue
# pin: 35
# filters:
# # White
# - platform: adc
# update_interval: 1s
# attenuation: 11db
# id: white
# pin: 32
# filters:
# # Brightness
# - platform: adc
# update_interval: 1s
# attenuation: 11db
# id: brightness
# pin: 33
# filters:
##### ledstrip ######
light:
- platform: neopixelbus
type: GRBW
pin: 25
id: ledstrip
num_leds: 21
name: "NeoPixel Light"
effects:
- addressable_rainbow:
- addressable_rainbow:
name: Rainbow Effect With Custom Values
speed: 10
width: 5
- addressable_color_wipe:
name: Color Wipe Effect With Custom Values
colors:
- red: 100%
green: 100%
blue: 100%
num_leds: 1
- red: 0%
green: 0%
blue: 0%
num_leds: 1
add_led_interval: 100ms
reverse: False
- addressable_scan:
name: Scan Effect With Custom Values
move_interval: 100ms
scan_width: 1
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_random_twinkle:
name: Random Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 32ms
- addressable_fireworks:
name: Fireworks Effect With Custom Values
update_interval: 32ms
spark_probability: 10%
use_random_color: false
fade_out_rate: 120
- addressable_flicker:
name: Flicker Effect With Custom Values
update_interval: 16ms
intensity: 5%
- automation:
name: Custom Automation Effect
sequence:
- light.addressable_set:
id: ledstrip
red: 100%
green: 100%
blue: 100%
- delay: 100ms
- light.addressable_set:
id: ledstrip
range_from: 0
range_to: 20
red: 100%
green: 0%
blue: 0%
- addressable_lambda:
name: "Custom lambda Effect"
update_interval: 16ms
lambda: |-
// it.size() - Number of LEDs
// it[num] - Access the LED at index num.
// Set the LED at num to the given r, g, b values
// it[num] = ESPColor(r, g, b);
// Get the color at index num (ESPColor instance)
// it[num].get();
// Example: Simple color wipe
for (int i = it.size() - 1; i > 0; i--) {
it[i] = it[i - 1].get();
}
it[0] = ESPColor::random_color();
// Bonus: use .range() and .all() to set many LEDs without having to write a loop.
it.range(0, 50) = ESPColor::BLACK;
it.all().fade_to_black(10);
nickrout
(Nick Rout)
September 7, 2020, 4:35am
3
I think that an automation to set the brightness of the relevant channel if the analog figure changes.
Brightnesses are 0.0-1.0, your ohms are 0-10000. Just divide by 10000, you’ll get a figure between 0 and 1.
You want the light_turn_on action
https://esphome.io/components/light/index.html#light-turn-on-action
1 Like
zimbron
January 20, 2021, 10:55pm
5
@Jaba Were you able to accomplish your plan?
Jaba
(Erwin Hijdra)
January 26, 2021, 7:50pm
6
i fixed it sort of, most of the logic is now in Node red.
1 Like