GQ1wD4b

Multi-function lamp controller based on ESP32-C3

 
Overview
Project Description:
This project, based on the ESP32-C3, creates a multi-functional control module for lighting. It can be connected to Home Assistant to achieve various automated controls. The project integrates an LD2410 human presence sensor, a temperature and humidity sensor, touch sensing, and offline voice functionality.
Schematic Design:
Power Supply:
220V; Lights
: SSD1306; Display: Control
Sensors :
Temperature and Humidity Sensor;
Touch Sensing and Human Presence Sensor;
Offline Voice Function: Main
Control Chip:
ESP32-C3;
PCB Design:
The temperature and humidity sensor is placed separately on the outside of the casing to prevent heat-generating components from affecting the temperature.
The software part
uses esphome to program c3 and access the homeassistant
code block:
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: Hello temperature is wet!"%()+,-_.:°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, eg, 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 #This is essential; it acts as a filter.


# Set GPIO10 as an output pin to control the light
output:
- platform: gpio
pin: GPIO10
id: gpio_output
inverted: false

# Define a light that uses the GPIO10 pin defined above
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

Physical display instructions
and precautions
: This project involves high-voltage electricity, please handle with caution!
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2026-03-26 03:15:54

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号