Skip to content

Instantly share code, notes, and snippets.

@rosaldanha
Last active July 6, 2023 04:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosaldanha/ede8eb221becd02e39b7966c9cabc7ac to your computer and use it in GitHub Desktop.
Save rosaldanha/ede8eb221becd02e39b7966c9cabc7ac to your computer and use it in GitHub Desktop.
LD1115H using output pin on esphome
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
@harphere
Copy link

Hi, can you confirm please - LD1115H_INPUT_PIN: GPIO17, do you mean V0 from LD1115H to GPIO17 on ESP32?

@rosaldanha
Copy link
Author

rosaldanha commented Feb 28, 2023 via email

@klipper-vp
Copy link

vc tem a ligaçao dos fios? do D1 para o sensor

@rosaldanha
Copy link
Author

vc tem a ligaçao dos fios? do D1 para o sensor

GPIO17 <= vout
GPIO1 = rx (no d1)
GPIO3 = tx (no d1)
3v (d1) = vin
gnd = gnd

@klipper-vp
Copy link

Oi muito obrigadoooo so ta dando erro aqui nao sei porque

${LD1115H_INPUT_PIN}
o que pode ser?

@klipper-vp
Copy link

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