Tuya MCU does not respond to UART

Hello! I’m new here…

I’ve just followed this to control a CREATE ceiling fan with ESPHome instead oif Tuya : GitHub - christiaanderidder/esphome-create-wind-calm: A guide and configuration for converting the Create Wind Calm fan to ESPHome

My controller looks pretty much the same as there.
I forst replaced the WBR3 with an ESP32-12F module but got some soldering issues and pads were destroyed. I then soldered a ESP8266 board instead, with nice wires, and flashed it with ESPHome.
It boots up nicely and is seen is HomeAssistant.

However, as i see in the logs collected in HA, the ESP sends a heartbeat packet on TX but never receives anything on RX, and i get error "[E][tuya:489]: Initialization failed at init state 0 "

{C6DD5FAC-16A6-453E-9459-54CBCFBD228F}

Any idea why the tuya MCU wouldn’t respond at all?

My next step is to sniff traffic on the original WBR3 module but i thought someone misht have an insight…

Here is my configuration:

esphome:
  name: fan0-ctrl-8266
  friendly_name: Fan0_ctrl_8266

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: <snip>
ota:
  - platform: esphome
    password: <snip>

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: <snip>
    password: <snip>

captive_portal:

uart:
  id: uart_bus
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  debug:

tuya:
  id: "tuya_device"
  uart_id: uart_bus


fan:
  - platform: "tuya"
    name: "Fan0"
    switch_datapoint: 1
    speed_datapoint: 3

What exact esp8266 board you use? Did you carefully inspect your soldering quality?

Hello,
thanks for your reply.

I’m using a D1 mini connected to the RX and TX of the main board.

The soldering looks quite ok to me…

Many d1-mini clones have usb-serial converter connected to rx/tx pins improperly. It could be better option to swap uart to GPIO15/GPIO13.

I’m not as confident…

Hi,
i’ve tried several things:
1- connect the GND-TX-RX pins to an USB to serial converter, with no ESP involved. I sent 0x55AA00000000FF and got responses (tuya-like)
2- connect the ESP board’s TX to the USB2serial → i can see 0x55AA00000000FF being sent repeatedly (in bursts of 5 or so) as expected
3- connect the ESP’s TX to the tuya MCU. Connect the RX to the USB2serial only → I can see the responses from the MCU!
4- connect the ESP’s TX+RX (“normal” connection) and look in the ESPHOME logs → it tells me that device is stuck in init state 0, no data received on RX
5- in adition to 4, solder the RX of the USB2serial to “spy” the RX wire → now i don’t see traffic anymore

It seems that when the RX is connected to the ESP, there is no traffic anymore. I cannot figure out why this could be.

… any idea?

(NB : using GPIO 13+15 fried a chip, and i cannot figure out why neither)

I found a solution.

I guess that the RX (GPIO3) is internally pulled UP in the ESP8266, in a way that is not compatible with the Tuya MCU + board resistors. It is the only explanation i found to the RX traffic “disappearing” when the ESP is connected.

I switched to GPIO 4 and 5, as software UART is ok at 9600 bauds and i don’t need a faster serial link for simple fan control.

It worked immediately.

My final YAML is then the following:



esphome:
  name: fan0-ctrl-8266
  friendly_name: Fan0_ctrl_8266

esp8266:
  board: esp01_1m

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "fJxO0+tcyRr26lYj3zBCgPbUs/+k6QIfW3pXi4eTZ7Q="

ota:
  - platform: esphome
    password: "de5817d7984c7a710b8aa36ac2bf6068"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Fan0-Ctrl-8266 Fallback Hotspot"
    password: "K4tsnj2pUoVS"

captive_portal:

time:
  - platform: homeassistant
    id: homeassistant_time

uart:
  id: uart_bus
  rx_pin: GPIO4
  tx_pin: GPIO5
  baud_rate: 9600

tuya:
  id: "tuya_device"
  uart_id: uart_bus
  time_id: homeassistant_time

fan:
  - platform: "tuya"
    id: fan_01
    name: "Fan"
    switch_datapoint: 60
    speed_datapoint: 62
    direction_datapoint: 63
    speed_count: 6
    restore_mode: ALWAYS_OFF


binary_sensor:
  - platform: status
    name: "Status"
    device_class: connectivity

sensor:
  - platform: wifi_signal
    name: "Wifi Signal"
    update_interval: 60s
    icon: mdi:wifi

  - platform: uptime
    name: "Uptime Seconds"
    update_interval: 60s
    icon: mdi:clock-outline

More likely missing isolation resistor between esp and ch340.

Bad soldering, solder bridge between Gpio15 and 3.3V pin?

Maybe… i will never know.