Last active
July 6, 2023 04:30
-
-
Save rosaldanha/ede8eb221becd02e39b7966c9cabc7ac to your computer and use it in GitHub Desktop.
LD1115H using output pin on esphome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
substitutions: | |
location: Escritorio | |
devicename: mmwescritorio | |
LD1115H_INPUT_PIN: GPIO17 | |
TXPIN: GPIO1 | |
RXPIN: GPIO3 | |
esphome: | |
name: ${devicename} | |
esp32: | |
board: esp32dev | |
framework: | |
type: arduino | |
# Enable Home Assistant API | |
api: | |
ota: | |
password: !secret ota_password | |
wifi: | |
ssid: !secret wifi_ssid | |
password: !secret wifi_password | |
# Enable logging | |
logger: | |
level: VERY_VERBOSE | |
baud_rate: 0 | |
############################################################################################################################# | |
uart: | |
id: uart_bus | |
tx_pin: ${TXPIN} | |
rx_pin: ${RXPIN} | |
baud_rate: 115200 | |
debug: | |
direction: BOTH | |
dummy_receiver: true | |
after: | |
delimiter: "\n" | |
sequence: | |
- lambda: UARTDebug::log_string(direction, bytes); | |
switch: | |
- platform: safe_mode | |
internal: true | |
name: use_safe_mode | |
number: | |
- platform: template | |
name: ${devicename}_motion_detection_sensitivity | |
id: ${devicename}_motion_detection_sensitivity | |
min_value: 1 | |
max_value: 240 | |
initial_value: 120 | |
optimistic: true | |
step: 1 | |
restore_value: true | |
mode: box | |
set_action: | |
- uart.write: !lambda | |
int cm = (int)x; | |
std::string cms = "th1=" + to_string(cm) +" \n"; | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "save\n" | |
- platform: template | |
name: ${devicename}_presence_detection_sensitivity | |
id: ${devicename}_presence_detection_sensitivity | |
min_value: 1 | |
max_value: 450 | |
initial_value: 250 | |
optimistic: true | |
step: 1 | |
restore_value: true | |
mode: box | |
set_action: | |
- uart.write: !lambda | |
int cm = (int)x; | |
std::string cms = "th2=" + to_string(cm) +" \n"; | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "save\n" | |
- platform: template | |
name: ${devicename}_delay_detection_time | |
id: ${devicename}_delay_detection_time | |
min_value: 1 | |
max_value: 60 | |
initial_value: 5 | |
optimistic: true | |
step: 1 | |
restore_value: true | |
mode: box | |
set_action: | |
- uart.write: !lambda | |
int cm = (int)x; | |
std::string cms = "dtime=" + to_string(cm) +" \n"; | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "save\n" | |
- platform: template | |
name: ${devicename}_gpio_pullup_mov_times | |
id: ${devicename}_gpio_pullup_mov_times | |
min_value: 1 | |
max_value: 60 | |
initial_value: 3 | |
optimistic: true | |
step: 1 | |
restore_value: true | |
mode: box | |
set_action: | |
- uart.write: !lambda | |
int cm = (int)x; | |
std::string cms = "mov_sn=" + to_string(cm) +" \n"; | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "save\n" | |
- platform: template | |
name: ${devicename}_gpio_pullup_occ_times | |
id: ${devicename}_gpio_pullup_occ_times | |
min_value: 1 | |
max_value: 60 | |
initial_value: 5 | |
optimistic: true | |
step: 1 | |
restore_value: true | |
mode: box | |
set_action: | |
- uart.write: !lambda | |
int cm = (int)x; | |
std::string cms = "occ_sn=" + to_string(cm) +" \n"; | |
return std::vector<unsigned char>(cms.begin(), cms.end()); | |
- delay: 1s | |
- uart.write: "save\n" | |
binary_sensor: | |
- platform: gpio | |
name: occup_${location} | |
device_class: occupancy | |
pin: | |
number: ${LD1115H_INPUT_PIN} | |
mode: | |
input: true | |
pulldown: true | |
button: | |
- platform: restart | |
name: Restart $device_name | |
Oi muito obrigadoooo so ta dando erro aqui nao sei porque
${LD1115H_INPUT_PIN}
o que pode ser?
binary_sensor:
- platform: gpio
name: occup_${location}
device_class: occupancy
pin:
number: GPIO17
mode:
input: true
pulldown: true
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GPIO17 <= vout
GPIO1 = rx (no d1)
GPIO3 = tx (no d1)
3v (d1) = vin
gnd = gnd