
专业版
基于esp32-c3的多合一台灯控制器
359
0
0
0
简介
本项目基于ESP32-C3,做了一个可控制灯光的多功能控制模块,可接入homeassistant,实现多样的自动化控制。项目集成了人体存在传感器LD2410,温湿度传感器、触摸感应、离线语音等功能。
简介:本项目基于ESP32-C3,做了一个可控制灯光的多功能控制模块,可接入homeassistant,实现多样的自动化控制。项目集成了人体存在传感器LD2410,温湿度传感器、触摸感应、离线语音等功能。开源协议
:MIT License
(未经作者授权,禁止转载)创建时间:2024-08-12 09:03:44更新时间:2024-09-05 02:21:27
描述
项目描述
本项目基于ESP32-C3,做了一个可控制灯光的多功能控制模块,可接入homeassistant,实现多样的自动化控制。项目集成了人体存在传感器LD2410,温湿度传感器、触摸感应、离线语音等功能。
原理图设计说明
供电部分
220V灯
ssd1306显示控制
传感器
温湿度传感器
触摸感应及人体存在传感器
离线语音
####主控芯片
ESP32-C3
PCB设计说明
将温湿度传感器单独放在外壳的外边,防止发热部分对温度造成影响。
软件部分
采用esphome对c3进行编程并接入homeassistant
代码块:
esphome:
name: esp32-c3controler
friendly_name: esp32_c3controler
esp32:
board: airm2m_core_esp32c3
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
ota:
password: "XXXXXXXXXXXXXXXX"
wifi:
ssid: "XXXXXXXXXXXXXXXX"
password: "XXXXXXXXXXXXXXXX"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32-C3Controler"
password: "h8OEhLousCaS"
captive_portal:
font:
- file: "fonts/ZhuqueFangsong.ttf"
id: ch_font
size: 22
glyphs: 你好温度为湿!"%()+,-_.:°0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
- file: "fonts/simkai.ttf"
id: time_font
size: 28
- file: "fonts/simkai.ttf"
id: my_font3
size: 18
# Example configuration entry
i2c:
sda: GPIO19
scl: GPIO18
image:
- file: mdi:home-thermometer-outline
id: temp
resize: 30x30
- file: mdi:water-percent
id: hum
resize: 30x30
- file: mdi:white-balance-sunny
id: sunny
resize: 30x30
- file: mdi:weather-partly-cloudy
id: cloudy
resize: 30x30
- file: mdi:weather-rainy
id: rainy
resize: 30x30
- file: mdi:weather-pouring
id: pouring
resize: 30x30
time:
- platform: homeassistant
id: esptime
uart:
- id: ld24100
tx_pin: GPIO5
rx_pin: GPIO4
baud_rate: 256000
parity: NONE
stop_bits: 1
# - id: uart_bus_cmd
# rx_pin: GPIO10 # Modify according to your wiring, e.g., D6
# baud_rate: 9600
# text_sensor:
# - platform: custom
# lambda: |-
# auto my_custom_sensor = new UartReadLineSensor(id(uart_bus_cmd));
# App.register_component(my_custom_sensor);
# return {my_custom_sensor};
# text_sensors:
# name: "c3-controler"
# id: "c3controler"
# # update_interval: 5s
# on_value:
# then:
# - delay: 5s
# - lambda: |-
# id(c3controler).publish_state("abc");
ld2410:
binary_sensor:
- platform: gpio
pin:
number: GPIO3
inverted: false
mode: INPUT
name: "2410motion-out"
device_class: motion
- platform: ld2410
has_target:
name: Presence
has_moving_target:
name: Moving Target
has_still_target:
name: Still Target
out_pin_presence_status:
name: out pin presence status
- platform: gpio
pin:
number: 6
mode:
input: true
pullup: true
name: "C3-TOUCH"
filters:
- delayed_on_off: 50ms #这里一定要加这个这个起到滤波的作用。
# 将 GPIO10 设置为输出引脚,用于控制灯
output:
- platform: gpio
pin: GPIO10
id: gpio_output
inverted: false
# 定义一个灯,它使用上面定义的 GPIO10 引脚
light:
- platform: binary
name: "c3-light"
output: gpio_output
switch:
- platform: gpio
pin: GPIO7
name: "ssd1306-switch"
id: ssd1306switch
restore_mode: RESTORE_DEFAULT_ON
sensor:
- platform: sht4x
temperature:
name: "Temperature"
humidity:
name: "Relative Humidity"
- platform: ld2410
light:
name: light
moving_distance:
name : Moving Distance
still_distance:
name: Still Distance
moving_energy:
name: Move Energy
still_energy:
name: Still Energy
detection_distance:
name: Detection Distance
g0:
move_energy:
name: g0 move energy
still_energy:
name: g0 still energy
g1:
move_energy:
name: g1 move energy
still_energy:
name: g1 still energy
g2:
move_energy:
name: g2 move energy
still_energy:
name: g2 still energy
g3:
move_energy:
name: g3 move energy
still_energy:
name: g3 still energy
g4:
move_energy:
name: g4 move energy
still_energy:
name: g4 still energy
g5:
move_energy:
name: g5 move energy
still_energy:
name: g5 still energy
g6:
move_energy:
name: g6 move energy
still_energy:
name: g6 still energy
g7:
move_energy:
name: g7 move energy
still_energy:
name: g7 still energy
g8:
move_energy:
name: g8 move energy
still_energy:
name: g8 still energy
- platform: homeassistant
id: temperature
entity_id: sensor.miaomiaoce_t2_b84f_temperature_humidity_sensor
internal: true
- platform: homeassistant
id: humidity
entity_id: sensor.miaomiaoce_t2_b84f_relative_humidity
internal: true
- platform: homeassistant
id: current_weather
entity_id: weather.he_feng_tian_qi
attribute: condition_cn
- platform: homeassistant
id: update_time
entity_id: weather.he_feng_tian_qi
attribute: update_time
- platform: homeassistant
id: day1_forecast
entity_id: weather.he_feng_tian_qi
attribute: daily_forecast[0].text
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
id: my_display
# lambda: |-
# if (id(adcin).has_state()) {
# it.printf(90, 10, id(ch_font), TextAlign::TOP_CENTER , "%.4f", id(adcin).state);
# }
pages:
- id: showtime
lambda: |-
it.strftime(60, 40, id(time_font), TextAlign::BASELINE_CENTER, "%H:%M:%S", id(esptime).now());
- id: show_tem_hum
lambda: |-
if (id(temperature).has_state()) {
it.printf(90, 10, id(ch_font), TextAlign::TOP_CENTER , "%.1f°C", id(temperature).state);
it.image(20, 10, id(temp));
}
if (id(humidity).has_state()) {
it.printf(90, 40, id(ch_font), TextAlign::TOP_CENTER , "%.1f%%", id(humidity).state);
it.image(20, 40, id(hum));
}
interval:
- interval: 2s
then:
- display.page.show_next: my_display
- component.update: my_display
实物展示说明
注意事项
提示:本项目涉及强电,请谨慎处理!
设计图

BOM


添加到专辑
0
0
分享
侵权投诉
评论