09-09-2025, 02:39 AM
Code:
esphome:
name: dm16
friendly_name: dm16
platformio_options:
board_build.extra_flags:
# WIFI_CONTROL_SELF_MODE = 0
# WIFI_CONTROL_SELF_MODE = 1
- "-DWIFI_CONTROL_SELF_MODE=1"
esp32:
board: esp32-s3-devkitc-1
framework:
type: arduino
external_components:
- source:
type: git
url: https://github.com/hzkincony/esphome-tuya-wifi-mcu
ref: v1.2.0
# Enable logging
logger:
baud_rate: 0
hardware_uart: UART0
# Enable Home Assistant API
api:
ota:
platform: esphome
web_server:
port: 80
ethernet:
type: W5500
clk_pin: GPIO1
mosi_pin: GPIO2
miso_pin: GPIO41
cs_pin: GPIO42
interrupt_pin: GPIO43
reset_pin: GPIO44
i2c:
- id: bus_a
sda: 8
scl: 18
scan: true
frequency: 400kHz
text_sensor:
- platform: ethernet_info
ip_address:
name: ESP IP Address
id: eth_ip
address_0:
name: ESP IP Address 0
address_1:
name: ESP IP Address 1
address_2:
name: ESP IP Address 2
address_3:
name: ESP IP Address 3
address_4:
name: ESP IP Address 4
dns_address:
name: ESP DNS Address
mac_address:
name: ESP MAC Address
font:
- file: "gfonts://Roboto"
id: roboto
size: 15
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
lambda: |-
it.printf(0, 15, id(roboto), "IP: %s", id(eth_ip).state.c_str());
uart:
- id: dac_uart
rx_pin: 4
tx_pin: 6
baud_rate: 115200
stop_bits: 1
data_bits: 8
parity: NONE
- id: tuya_mcu_uart
tx_pin: 16
rx_pin: 17
baud_rate: 9600
tuya_wifi_mcu:
# tuya mcu product id
product_id: qdmpkznox0g9kkvo
uart_id: tuya_mcu_uart
wifi_reset_pin: 28
wifi_led_pin: 16
modbus:
- uart_id: dac_uart
modbus_controller:
- address: 1
update_interval: 5s
output:
# CH1 (0x0FA0 / 4000)
- platform: modbus_controller
id: dac_ch1_out
address: 0x0FA0
value_type: U_WORD
write_lambda: |-
// state = 0.0 ~ 1.0 → 0 ~ 4095
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH2 (0x0FA1 / 4001)
- platform: modbus_controller
id: dac_ch2_out
address: 0x0FA1
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH3
- platform: modbus_controller
id: dac_ch3_out
address: 0x0FA2
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH4
- platform: modbus_controller
id: dac_ch4_out
address: 0x0FA3
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH5
- platform: modbus_controller
id: dac_ch5_out
address: 0x0FA4
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH6
- platform: modbus_controller
id: dac_ch6_out
address: 0x0FA5
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH7
- platform: modbus_controller
id: dac_ch7_out
address: 0x0FA6
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH8
- platform: modbus_controller
id: dac_ch8_out
address: 0x0FA7
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH9
- platform: modbus_controller
id: dac_ch9_out
address: 0x0FA8
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH10
- platform: modbus_controller
id: dac_ch10_out
address: 0x0FA9
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH11
- platform: modbus_controller
id: dac_ch11_out
address: 0x0FAA
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH12
- platform: modbus_controller
id: dac_ch12_out
address: 0x0FAB
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH13
- platform: modbus_controller
id: dac_ch13_out
address: 0x0FAC
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH14
- platform: modbus_controller
id: dac_ch14_out
address: 0x0FAD
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH15
- platform: modbus_controller
id: dac_ch15_out
address: 0x0FAE
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# CH16
- platform: modbus_controller
id: dac_ch16_out
address: 0x0FAF
value_type: U_WORD
write_lambda: |-
uint16_t reg = (uint16_t) round(x * 4095.0);
return reg;
# -------------------
# 16 路 Light (调光灯)
# -------------------
light:
- platform: monochromatic
name: "DAC CH1"
output: dac_ch1_out
id: light_1
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH1"
# bind other light, sync state
bind_light_id: light_1
output: dac_ch1_out
dp_id: 2
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH2"
output: dac_ch2_out
id: light_2
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH2"
# bind other light, sync state
bind_light_id: light_2
output: dac_ch2_out
dp_id: 8
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH3"
output: dac_ch3_out
id: light_3
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH3"
# bind other light, sync state
bind_light_id: light_3
output: dac_ch3_out
dp_id: 16
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH4"
output: dac_ch4_out
id: light_4
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH4"
# bind other light, sync state
bind_light_id: light_4
output: dac_ch4_out
dp_id: 101
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH5"
output: dac_ch5_out
id: light_5
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH5"
# bind other light, sync state
bind_light_id: light_5
output: dac_ch5_out
dp_id: 102
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH6"
output: dac_ch6_out
id: light_6
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH6"
# bind other light, sync state
bind_light_id: light_6
output: dac_ch6_out
dp_id: 103
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH7"
output: dac_ch7_out
id: light_7
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH7"
# bind other light, sync state
bind_light_id: light_7
output: dac_ch7_out
dp_id: 104
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH8"
output: dac_ch8_out
id: light_8
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH8"
# bind other light, sync state
bind_light_id: light_8
output: dac_ch8_out
dp_id: 105
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH9"
output: dac_ch9_out
id: light_9
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH9"
# bind other light, sync state
bind_light_id: light_9
output: dac_ch9_out
dp_id: 106
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH10"
output: dac_ch10_out
id: light_10
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH10"
# bind other light, sync state
bind_light_id: light_10
output: dac_ch10_out
dp_id: 107
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH11"
output: dac_ch11_out
id: light_11
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH11"
# bind other light, sync state
bind_light_id: light_11
output: dac_ch11_out
dp_id: 108
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH12"
output: dac_ch12_out
id: light_12
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH12"
# bind other light, sync state
bind_light_id: light_12
output: dac_ch12_out
dp_id: 109
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH13"
output: dac_ch13_out
id: light_13
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH13"
# bind other light, sync state
bind_light_id: light_13
output: dac_ch13_out
dp_id: 110
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH14"
output: dac_ch14_out
id: light_14
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH14"
# bind other light, sync state
bind_light_id: light_14
output: dac_ch14_out
dp_id: 111
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH15"
output: dac_ch15_out
id: light_15
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH15"
# bind other light, sync state
bind_light_id: light_15
output: dac_ch15_out
dp_id: 112
# hide from homeassistant ui
internal: true
- platform: monochromatic
name: "DAC CH16"
output: dac_ch16_out
id: light_16
default_transition_length: 0s
- platform: tuya_wifi_mcu
name: "Tuya DAC CH16"
# bind other light, sync state
bind_light_id: light_16
output: dac_ch16_out
dp_id: 113
# hide from homeassistant ui
internal: true
pcf8574:
- id: 'pcf8574_hub_in_1' # for input channel 1-16
i2c_id: bus_a
address: 0x22
pcf8575: true
binary_sensor:
- platform: gpio
name: "dm16-input01"
pin:
pcf8574: pcf8574_hub_in_1
number: 8
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input02"
pin:
pcf8574: pcf8574_hub_in_1
number: 9
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input03"
pin:
pcf8574: pcf8574_hub_in_1
number: 10
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input04"
pin:
pcf8574: pcf8574_hub_in_1
number: 11
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input05"
pin:
pcf8574: pcf8574_hub_in_1
number: 12
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input06"
pin:
pcf8574: pcf8574_hub_in_1
number: 13
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input07"
pin:
pcf8574: pcf8574_hub_in_1
number: 14
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input08"
pin:
pcf8574: pcf8574_hub_in_1
number: 15
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input09"
pin:
pcf8574: pcf8574_hub_in_1
number: 0
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input10"
pin:
pcf8574: pcf8574_hub_in_1
number: 1
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input11"
pin:
pcf8574: pcf8574_hub_in_1
number: 2
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input12"
pin:
pcf8574: pcf8574_hub_in_1
number: 3
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input13"
pin:
pcf8574: pcf8574_hub_in_1
number: 4
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input14"
pin:
pcf8574: pcf8574_hub_in_1
number: 5
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input15"
pin:
pcf8574: pcf8574_hub_in_1
number: 6
mode: INPUT
inverted: true
- platform: gpio
name: "dm16-input16"
pin:
pcf8574: pcf8574_hub_in_1
number: 7
mode: INPUT
inverted: true
ads1115:
- address: 0x48
sensor:
- platform: ads1115
multiplexer: 'A0_GND'
gain: 6.144
resolution: 16_BITS
name: "ADS1115 Channel A0-GND"
update_interval: 5s
- platform: ads1115
multiplexer: 'A1_GND'
gain: 6.144
name: "ADS1115 Channel A1-GND"
update_interval: 5s
- platform: ads1115
multiplexer: 'A2_GND'
gain: 6.144
name: "ADS1115 Channel A2-GND"
update_interval: 5s
- platform: ads1115
multiplexer: 'A3_GND'
gain: 6.144
name: "ADS1115 Channel A3-GND"
update_interval: 5s
DM16-HA-with-Tuya.txt (Size: 13.11 KB / Downloads: 85)
YouTube: https://www.youtube.com/c/KinCony
Online Store: https://shop.kincony.com
Alibaba Store: https://kincony.en.alibaba.com/
Online Store: https://shop.kincony.com
Alibaba Store: https://kincony.en.alibaba.com/

