ESP-01S的一些使用

By Heanny
2026-07-17
6 read

安装ESPHome

pip install esphome   -i http://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

生成32key

openssl rand -base64 32

编写yaml配置文件

  1. DHT11温湿度传感器
    esp01_dht11.yaml
esphome: name: esp01s-test friendly_name: ESP01S模块 esp8266: board: esp01_1m restore_from_flash: true # WiFi配置 wifi: ssid: "WIFI名" password: "WIFI密码." ap: ssid: "ESP01S-热点" password: "12345678" captive_portal: api: encryption: key: "刚刚的32位key" web_server: port: 80 ota: platform: esphome password: "ota123456" logger: baud_rate: 115200 time: - platform: homeassistant id: ha_time # 巴法云MQTT配置 mqtt: broker: mqtt.bemfa.com port: 9501 username: "bemfa私钥" password: "" client_id: bemfa私钥 # 离线遗嘱 will_message: topic: "订阅主题004" payload: "offline" retain: true on_connect: then: - mqtt.publish: topic: "订阅主题004" payload: "online" retain: true # DHT11温湿度传感器 DATA接GPIO2 sensor: - platform: dht pin: GPIO2 model: DHT11 update_interval: 60s temperature: name: "室内温度_temp" id: temp_val filters: - round: 1 # 温度单独上报巴法主题 on_value: then: - mqtt.publish: topic: "eh73qf4H7004" payload: !lambda 'return "temp:" + to_string(id(temp_val).state);' retain: true humidity: name: "室内湿度_humi" id: humi_val filters: - round: 1 # 湿度单独上报 on_value: then: - mqtt.publish: topic: "eh73qf4H7004" payload: !lambda 'return "hum:" + to_string(id(humi_val).state);' retain: true

编译

esphome compile esp01_dht11.yaml

刷录

esphome run esp01_dht11.yaml
如何拥有一个无限制、可联网、带本地知识库的私人 DeepSeek?

Comments

暂无评论,还不快来坐沙发...

Leave a Reply