esphome: name: b16m friendly_name: b16m 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.1.0 # Enable logging # hardware_uart: USB_SERIAL_JTAG # Enable Home Assistant API api: encryption: key: "WeVOuL5oNhjXcfzXtTirlOwvtWvCD5yqIxd3oV4es1k=" ethernet: type: W5500 clk_pin: GPIO42 mosi_pin: GPIO43 miso_pin: GPIO44 cs_pin: GPIO41 interrupt_pin: GPIO2 reset_pin: GPIO1 i2c: - id: bus_a sda: 38 scl: 39 scan: true frequency: 400kHz pcf8574: - id: 'pcf8574_hub_out_1' # for output channel 1-16 i2c_id: bus_a address: 0x25 pcf8575: true - id: 'pcf8574_hub_in_1' # for input channel 1-16 i2c_id: bus_a address: 0x24 pcf8575: true uart: - id: uart_1 #RS485 baud_rate: 9600 debug: direction: BOTH dummy_receiver: true after: timeout: 10ms tx_pin: 18 rx_pin: 8 - id: tuya_mcu_uart tx_pin: GPIO16 rx_pin: GPIO17 baud_rate: 9600 tuya_wifi_mcu: # tuya mcu product id product_id: tg4bava25acki7vz uart_id: tuya_mcu_uart wifi_reset_pin: 28 wifi_led_pin: 16 switch: - platform: uart uart_id: uart_1 name: "RS485 Button" data: [0x11, 0x22, 0x33, 0x44, 0x55] - platform: gpio name: "b16m-output01" id: "b16m_output01" pin: pcf8574: pcf8574_hub_out_1 number: 0 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output1-tuya dp_id: 1 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output01" - platform: gpio name: "b16m-output02" id: "b16m_output02" pin: pcf8574: pcf8574_hub_out_1 number: 1 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output2-tuya dp_id: 2 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output02" - platform: gpio name: "b16m-output03" id: "b16m_output03" pin: pcf8574: pcf8574_hub_out_1 number: 2 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output3-tuya dp_id: 3 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output03" - platform: gpio name: "b16m-output04" id: "b16m_output04" pin: pcf8574: pcf8574_hub_out_1 number: 3 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output4-tuya dp_id: 4 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output04" - platform: gpio name: "b16m-output05" id: "b16m_output05" pin: pcf8574: pcf8574_hub_out_1 number: 4 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output5-tuya dp_id: 5 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output05" - platform: gpio name: "b16m-output06" id: "b16m_output06" pin: pcf8574: pcf8574_hub_out_1 number: 5 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output6-tuya dp_id: 6 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output06" - platform: gpio name: "b16m-output07" id: "b16m_output07" pin: pcf8574: pcf8574_hub_out_1 number: 6 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output7-tuya dp_id: 101 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output07" - platform: gpio name: "b16m-output08" id: "b16m_output08" pin: pcf8574: pcf8574_hub_out_1 number: 7 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output8-tuya dp_id: 102 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output08" - platform: gpio name: "b16m-output09" id: "b16m_output09" pin: pcf8574: pcf8574_hub_out_1 number: 8 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output9-tuya dp_id: 103 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output09" - platform: gpio name: "b16m-output10" id: "b16m_output10" pin: pcf8574: pcf8574_hub_out_1 number: 9 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output10-tuya dp_id: 104 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output10" - platform: gpio name: "b16m-output11" id: "b16m_output11" pin: pcf8574: pcf8574_hub_out_1 number: 10 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output11-tuya dp_id: 105 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output11" - platform: gpio name: "b16m-output12" id: "b16m_output12" pin: pcf8574: pcf8574_hub_out_1 number: 11 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output12-tuya dp_id: 106 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output12" - platform: gpio name: "b16m-output13" id: "b16m_output13" pin: pcf8574: pcf8574_hub_out_1 number: 12 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output13-tuya dp_id: 107 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output13" - platform: gpio name: "b16m-output14" id: "b16m_output14" pin: pcf8574: pcf8574_hub_out_1 number: 13 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output14-tuya dp_id: 108 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output14" - platform: gpio name: "b16m-output15" id: "b16m_output15" pin: pcf8574: pcf8574_hub_out_1 number: 14 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output15-tuya dp_id: 109 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output15" - platform: gpio name: "b16m-output16" id: "b16m_output16" pin: pcf8574: pcf8574_hub_out_1 number: 15 mode: OUTPUT inverted: true - platform: tuya_wifi_mcu name: b16m-output16-tuya dp_id: 110 # hide from homeassistant ui internal: true # bind other switch, sync state bind_switch_id: "b16m_output16" binary_sensor: - platform: gpio name: "b16m-input01" id: "b16m_input01" pin: pcf8574: pcf8574_hub_in_1 number: 0 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input1-tuya dp_id: 111 bind_binary_sensor_id: b16m_input01 internal: true - platform: gpio name: "b16m-input02" id: "b16m_input02" pin: pcf8574: pcf8574_hub_in_1 number: 1 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input2-tuya dp_id: 112 bind_binary_sensor_id: b16m_input02 internal: true - platform: gpio name: "b16m-input03" id: "b16m_input03" pin: pcf8574: pcf8574_hub_in_1 number: 2 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input3-tuya dp_id: 113 bind_binary_sensor_id: b16m_input03 internal: true - platform: gpio name: "b16m-input04" id: "b16m_input04" pin: pcf8574: pcf8574_hub_in_1 number: 3 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input4-tuya dp_id: 114 bind_binary_sensor_id: b16m_input04 internal: true - platform: gpio name: "b16m-input05" id: "b16m_input05" pin: pcf8574: pcf8574_hub_in_1 number: 4 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input5-tuya dp_id: 115 bind_binary_sensor_id: b16m_input05 internal: true - platform: gpio name: "b16m-input06" id: "b16m_input06" pin: pcf8574: pcf8574_hub_in_1 number: 5 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input6-tuya dp_id: 116 bind_binary_sensor_id: b16m_input06 internal: true - platform: gpio name: "b16m-input07" id: "b16m_input07" pin: pcf8574: pcf8574_hub_in_1 number: 6 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input7-tuya dp_id: 117 bind_binary_sensor_id: b16m_input07 internal: true - platform: gpio name: "b16m-input08" id: "b16m_input08" pin: pcf8574: pcf8574_hub_in_1 number: 7 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input8-tuya dp_id: 118 bind_binary_sensor_id: b16m_input08 internal: true - platform: gpio name: "b16m-input09" id: "b16m_input09" pin: pcf8574: pcf8574_hub_in_1 number: 8 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input9-tuya dp_id: 119 bind_binary_sensor_id: b16m_input09 internal: true - platform: gpio name: "b16m-input10" id: "b16m_input10" pin: pcf8574: pcf8574_hub_in_1 number: 9 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input10-tuya dp_id: 120 bind_binary_sensor_id: b16m_input10 internal: true - platform: gpio name: "b16m-input11" id: "b16m_input11" pin: pcf8574: pcf8574_hub_in_1 number: 10 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input11-tuya dp_id: 121 bind_binary_sensor_id: b16m_input11 internal: true - platform: gpio name: "b16m-input12" id: "b16m_input12" pin: pcf8574: pcf8574_hub_in_1 number: 11 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input12-tuya dp_id: 122 bind_binary_sensor_id: b16m_input12 internal: true - platform: gpio name: "b16m-input13" id: "b16m_input13" pin: pcf8574: pcf8574_hub_in_1 number: 12 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input13-tuya dp_id: 123 bind_binary_sensor_id: b16m_input13 internal: true - platform: gpio name: "b16m-input14" id: "b16m_input14" pin: pcf8574: pcf8574_hub_in_1 number: 13 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input14-tuya dp_id: 124 bind_binary_sensor_id: b16m_input14 internal: true - platform: gpio name: "b16m-input15" id: "b16m_input15" pin: pcf8574: pcf8574_hub_in_1 number: 14 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input15-tuya dp_id: 125 bind_binary_sensor_id: b16m_input15 internal: true - platform: gpio name: "b16m-input16" id: "b16m_input16" pin: pcf8574: pcf8574_hub_in_1 number: 15 mode: INPUT inverted: true - platform: tuya_wifi_mcu name: b16m-input16-tuya dp_id: 126 bind_binary_sensor_id: b16m_input16 internal: true ##pull-up resistance on PCB - platform: gpio name: "b16m-W1-io40" pin: number: 40 inverted: true - platform: gpio name: "b16m-W1-io15" pin: number: 15 inverted: true - platform: gpio name: "b16m-W1-io48" pin: number: 48 inverted: true - platform: gpio name: "b16m-W1-io47" pin: number: 47 inverted: true ## without resistance on PCB - platform: gpio name: "b16m-W1-io13" pin: number: 13 inverted: false - platform: gpio name: "b16m-W1-io14" pin: number: 14 inverted: false - platform: gpio name: "b16m-W1-io21" pin: number: 21 inverted: false 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 web_server: port: 80 font: - file: "gfonts://Roboto" id: roboto size: 20 display: - platform: ssd1306_i2c i2c_id: bus_a model: "SSD1306 128x64" address: 0x3C lambda: |- it.printf(0, 0, id(roboto), "KinCony B16M");