粘配置:
由于esphome相对成熟只需要少量的配置文件就可。
本文是一个自制舵机门锁案例,esp8266,s90g,电池,门锁,hass。
esphome:
name: esp82661
friendly_name: ESP82661
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "JCyqHo6ED3rwKNq3KO2sY1SLNmojftdrruXOYrQ="
services:
- service: control_servo
variables:
level: float
then:
- servo.write:
id: my_servo
level: !lambda 'return level / 100.0;'
ota:
safe_mode: true
password: baivbaipass
wifi:
ssid: BV
password: 08611558
manual_ip:
static_ip: 192.168.2.70
gateway: 192.168.2.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp82661 Fallback"
password: "FYjfyhwTdX1bp"
captive_portal:
light:
- platform: status_led
name: "lock state"
pin: GPIO2
servo:
- id: my_servo
output: pwm_output
# Example output platform
# On ESP32, use ledc output
output:
- platform: esp8266_pwm
id: pwm_output
pin: GPIO0
frequency: 50 Hz
interval:
- interval: 20s
then:
- servo.detach: my_servo
最后四行,添加了,平时没事要关闭伺服电机的驱动输出的配置,这里是因为最开始忽略这个问题,导致门锁不运行的时候,也有相对较大的私服控制输出,消耗着大量的电,这次回想起来做的优化。
Servo Component — ESPHome 这里有伺服电机相关的文档
ESPHome示例代码-CSDN博客 这里是一些非常不错的学习示例
暂无评论