edited for readability, format, links and common verbiage

blakadder 2019-10-22 13:42:53 +02:00
parent 03a032852f
commit cd9778e5e7
1 changed files with 39 additions and 36 deletions

@ -1,19 +1,23 @@
Many newer Tuya devices are designed to have a secondary MCU along with a ESP8266 based Tuya Wifi module (TYWE3S, TYWE2S, etc).
TuyaMCU module is used with Tuya devices (dimmers, curtain motors, humidifiers, etc) employing a secondary MCU to facilitate communication between Tasmota and that MCU.
In these devices Tuya Wifi module takes care of Wifi and software features while the MCU controls the hardware based on commands from Wifi module and reports status back to Wifi module. All this communication happens over UART (Serial) with ESP8266.
In those devices the Wi-Fi module takes care of Wi-Fi and software features while the MCU controls the hardware based on commands from the module or built-in controls (buttons, switches, remotes and similar) and reports its status back to the Wi-Fi module. TuyaMCU maps all the different functions to Tasmota components and issues serial commands to the MCU and interprets status messages sent over serial from the MCU.
# TuyaMCU command
The TuyaMCU module introduces a new command [`TuyaMCU`](commands#tuyamcu) which maps the FunctionIDs to DpIds.
> Used only if your device is defined as module `TuyaMCU (54)` (formerly: `Tuya Dimmer (54)`) .
## TuyaMCU Module (former Tuya Serial Dimmer)
## DpId
All the components (relays, dimmers, switches) controlled by the MCU are identified by a DpId.
Whenever a command is sent to the MCU, this DpId dictates which relay or dimmer needs to be changed and same is used when the status is received from MCU.
The TuyaMCU module is for devices employing an MCU to perform the device actions and does the job of mapping those actions to Tasmota commands. The TuyaMCU module introduces a new command `TuyaMCU` which maps the FunctionIDs to DpIds. The module supports maximum of 16 configured FunctionIDs.
There is no way the Wi-Fi module firmware knows the function of each DpId, so, just like [configuring GPIOs](Configuration-Procedure-for-New-Devices) for your device, you need to map DpId's with their functions.
### DpId
All the devices (relays, dimmers, switches) controlled by MCU are identified by a DpId. Whenever a command is sent to MCU, this DpId dictates which relay or dimmer needs to be changed and same is used when the status is received from MCU. There is no way the Wi-Fi module firmware can know the function of each DpId, so just like GPIO pin configuration for TuyaMCU devices we need to map DpId with its functions.
## FunctionID
FunctionID defines which type of [component](components) is located at which DpId.
### FunctionIDs
The FunctionID defines what type of component is located at DpId. These functions are similar to default Tasmota components (Relays, LEDs, Dimmer like PWM, etc). Currently the TuyaMCU module supports the following FunctionIDs:
TuyaMCU module supports the following:
Function | FunctionId
Component| FunctionId
-|-
Switch1 to Switch4 | 1 to 4
Relay1 to Relay8 | 11 to 18
@ -23,33 +27,31 @@ Current (in milli Amps) | 32
Voltage (in deci Volt) | 33
Relay Inverted1 to Relay Inverted8 | 41 to 48
## TuyaMCU command
The TuyaMCU command accepts two comma separated parameters; FunctionID and DpId. For example:
`TuyaMCU <fnId>,<dpId>`
> Array of various Tuya devices is vast and this component is under active development which means the function list may expand in the future. Currently it might not be possible to implement all functions of your device (for example: RGB color selection or multiple DpId states).<br>For multiple DpId states functionality can be regained using rules and captured serial commands from the original firmware.
## Command Usage
The TuyaMCU command value consists of two comma separated parameters: FunctionID and DpId.
```
TuyaMCU <fnId>,<dpId>
```
where `<fnId>` is FunctionID and `<dpId>` is the DpId to map the function to.
If any existing entry with same `fnId` or `dpId` is already present, it will be updated to the new values.
If any existing entry with same `fnId` or `dpId` is already present, it will be updated to the new value.
If any of `fnId` or `dpId` is `0` the entry is removed
If `fnId` or `dpId` is `0` the entry is removed.
If no parameters are provided then `TuyaMCU` command just prints the current mapping values.
If no parameters are provided `TuyaMCU` prints the current mapped values.
Example:
`TuyaMCU 11,1`
This command maps Relay1 (FunctionID 11) to DpId 1.
Output of TuyaMCU is the current mapping of fnIds and DpIds.
- `TuyaMCU 11,1` - maps Relay1 (FunctionID 11) to DpId 1.
## Identification of FunctionIDs and DpIds
As mentioned earlier, the hardware is controlled by an MCU. The Wi-Fi module sends commands to MCU over serial to control the hardware. Each hardware component has a DpId which can be different for different models even for same manufacturer. We need to identify these DpIds.
As mentioned, the hardware is controlled by an MCU. The Wi-Fi module sends commands to MCU over serial to control the hardware. Each hardware component has a DpId which can have different functions on each model.
To do that:
We need to identify these DpIds:
1. Go to `Configure` -> `Console` option in Tasmota web interface.
2. Type command `weblog 4` to enable verbose logging in web interface.
2. Use command `weblog 4` to enable verbose logging in web interface.
3. Observe the log. After every 9-10 seconds you should see log messages such as:
```
TYA: Heartbeat
@ -79,9 +81,9 @@ To do that:
TYA: FnId=0 is set for dpId=104
```
4. The function ids are printed as `TYA: FnId=0 is set for dpId=XXX` We will use these `XXX` ids in guide ahead
4. The function ids are printed as `TYA: FnId=0 is set for dpId=XXX` We will use these `XXX` ids in the guide ahead
### Setting up Dimmer
### Setting up a Dimmer
We need to configure four functions of a dimmer:
1. Dimming DpId
2. Dimming Range
@ -89,12 +91,11 @@ We need to configure four functions of a dimmer:
4. Dimming less than 10%
#### Dimming DpId
The dimmer FunctionId is `21`. The DpId generally is `2` or `3`. The easiest is to try both.
1. Go to the Tasmota web Console and type `TuyaMCU 21,2` and wait for it to reboot.
2. Enter `Backlog Dimmer 10; Dimmer 100` in the Console
If your bulb responds to `Dimmer` commands, you have successfully configured the dimmer FunctionId. Make note of it.
If not try id `3` and if even `3` doesn't work keep trying Ids from all unknown Ids from the log until one works.
The dimmer FunctionId is `21`. On a dimmer DpId generally is `2` or `3`. Try both.
1. Go to the Tasmota Console and type `TuyaMCU 21,2` and wait for it to reboot.
2. Enter `Backlog Dimmer 10; Dimmer 100` in the Console.
- If your bulb responds to `Dimmer` commands, you have successfully configured the dimmer FunctionId. Make note of it.
- If not try id `3` and if even `3` doesn't work keep trying Ids from all unknown Ids from the log until one works.
#### Dimming Range
Once you have figured out the dimming functionId, we need to find the maximum dimming range. Once the dimming Id is set, the logs will continue
@ -113,6 +114,7 @@ Now we need to tell Tasmota to use maximum and minimum values. This controlled b
Once set, try `dimmer 100` in the Console and check if the brightness of bulb is same is the same as when the maximum was set using hardware buttons.
#### Power metering
<a id="power-metering"></a>
Some Tuya MCU devices support Power measurement support over serial. For this its better to use an bulb with known wattage rating.
Observe the logs in the Console
@ -193,14 +195,15 @@ For switches we need to
2. Configure Power metering.
#### Configure number of relays
By default, the TuyaMCU module expects a 1 gang switch. There is no way currently to detect the number of relays present in an MCU based switch. We need to tell Tasmota using FunctionIDs 12 to 18 for Relay2 to Relay4. For example, for 4 gang switch we need to set `TuyaMCU 12,2`, `TuyaMCU 13,3` and `TuyaMCU 14,4` if the DpIds for Relays 2-4 are `2`,`3`,`4`.
By default, the TuyaMCU module expects a 1 gang switch. There is currenty no way to detect the number of relays present in an MCU based switch. We need to tell the number of relays to Tasmota using FunctionIDs 12 to 18 for Relay2 to Relay4.
* For a 4 gang switch set `TuyaMCU 12,2`, `TuyaMCU 13,3` and `TuyaMCU 14,4` if the DpIds for Relays 2-4 are `2`,`3`,`4`.
TIP: You can configure all at once by using `Backlog TuyaMCU 12,2; TuyaMCU 13,3; TuyaMCU 14,4`
> You can configure all at once by using `Backlog TuyaMCU 12,2; TuyaMCU 13,3; TuyaMCU 14,4`
#### Configure power metering
Power metering configuration is same as for dimmers. Check the power metering section for dimmers.
Power metering configuration is same as for [dimmers](#power-metering).
### Setting up Curtain Motor
### Setting up a Curtain Motor
The Zemismart WiFi curtain motor uses a Tuya TYWE1S inside the little white dongle as a radio modem.
`U1TX` is connected to "USB D+", `U1RX` is connected to "USB D-", and there is a blue LED in the dongle connected to "USB3 R-" controlled by the MCU. To flash Tasmota, we need `U0RX`, `U0TX`, and `GPIO0`. None of which are broken out on the PCB, so soldering or Tuya-Convert are necessary.