Hello Friends!!
I`ve tried to turn backlight of LCD2004 off when esp32 boot up, but it refuses to obey. When i use touchPin for turn backlight off it works fine. Please look at code and help if possible.
esphome:
name: greenhouse-controller
friendly_name: greenhouse _controller
on_boot:
priority: 600
then:
script.execute: backlight_off
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Greenhouse-Controller"
password: "cN6lTpQcO8"
captive_portal:
web_server:
port: 80
i2c:
sda: 21
scl: 22
scan: True
sensor:
- platform: bme280
temperature:
id: "t1"
name: "BME280 Temperature"
oversampling: 16x
pressure:
id: "p1"
name: "BME280 Pressure"
humidity:
id: "h1"
name: "BME280 Humidity"
address: 0x76
update_interval: 60s
time:
- platform: homeassistant
id: my_time
display:
- platform: lcd_pcf8574
id: mydisplay
user_characters:
- position: 0
data:
- 0b01100
- 0b10010
- 0b10010
- 0b01100
- 0b00000
- 0b00000
- 0b00000
- 0b00000
dimensions: 20x4
address: 0x3F
lambda: |-
it.strftime("%H:%M on %d.%m.%Y", id(my_time).now());
it.printf(0, 1,"Temperature: %1.0f", id(t1).state);
it.print(15, 1,"\x08");
it.print(16, 1,"C");
it.printf(0, 2,"Humidity: %1.0f", id(h1).state);
it.print(13, 2,"%");
it.printf(0, 3,"Pressure: %1.0f mmHg", id(p1).state*0.7500637);
esp32_touch:
setup_mode: false
binary_sensor:
- platform: esp32_touch
name: "Touch15"
pin: GPIO15
threshold: 1000
on_press:
then:
- binary_sensor.template.publish:
id: backlight
state: ON
- binary_sensor.template.publish:
id: backlight
state: OFF
- platform: template
id: backlight
filters:
- delayed_off: 10s
on_press:
then:
- lambda: |-
id(mydisplay).backlight();
on_release:
then:
- lambda: |-
id(mydisplay).no_backlight();
switch:
- platform: gpio
pin: GPIO16
name: "outside_path_light16"
script:
- id: backlight_off
then:
- lambda: |-
id(mydisplay).no_backlight();