Add TuyaMCU page for config

Shantur Rathore 2019-09-05 11:05:18 +01:00
parent 2bc301ef18
commit 503ef60750
1 changed files with 2 additions and 183 deletions

@ -59,7 +59,7 @@ TIP: If you are using jumper headers use `sleep 15 &&` before your commands, thi
2. On your PC, you should see a wifi network name "sonoff-xxxx" where is a number from ESP's mac address.
3. Connect to it and enter the Wifi details for your wifi router and click save.
4. Connect back to your wifi router and now you need to find the IP of newly connected Tasmota. Refer this very [good video from SuperHouseTV](https://www.youtube.com/watch?v=IcOFeIcLFFo&t=1623s) (ignore flashing information) about Tasmota configuration.
5. Once you get to Tasmota configuration you need to use `Tuya Dimmer` module and GPIO configuration below depending on your hardware. You already know pin connections to MCU.
5. Once you get to Tasmota configuration you need to use `TuyaMCU` module and GPIO configuration below depending on your hardware. You already know pin connections to MCU.
GPIO | Component
-|-
@ -73,188 +73,7 @@ GPIO | Component
7. Once this is saved and device is rebooted. Open the Tasmota configuration page and you should be able to use Toggle button to toggle dimmer or atleast one of the gangs in a multi gang switch.
8. Follow the process below depending on switch or dimmer.
### DP IDs
As mentioned earlier, the hardware is controlled by MCU and TYWE3S sends commands to MCU over serial to control the hardware. Each hardware function has a DP ID which can be different for different models even for same manufacturer. We need to identify the dp ids for each of the hardware.
To do that,
1. You need to go to `Configure` -> `Console` option in Tasmota web interface.
2. Type command `weblog 4` to enable verbose logging in web interface.
3. Observe that after every 9-10 seconds you will see things like
```
16:44:47 TYA: Heartbeat
16:44:49 TYA: RX Packet: "55aa0107000501010001000f"
16:44:49 TYA: RX Device-1 --> MCU State: Off Current State:Off
16:44:49 TYA: RX Packet: "55aa01070005020100010010"
16:44:49 TYA: RX Device-2 --> MCU State: Off Current State:Off
16:44:49 TYA: RX Packet: "55aa01070005030100010011"
16:44:49 TYA: RX Device-3 --> MCU State: Off Current State:Off
16:44:49 TYA: RX Packet: "55aa01070005040100010012"
16:44:49 TYA: RX Device-4 --> MCU State: Off Current State:Off
16:44:49 TYA: RX Packet: "55aa0107000807020004000000001c"
16:44:49 TYA: RX Unknown ID=7
16:44:49 TYA: RX Packet: "55aa0107000808020004000000001d"
16:44:49 TYA: RX Unknown ID=8
16:44:49 TYA: RX Packet: "55aa0107000809020004000000001e"
16:44:49 TYA: RX Unknown ID=9
16:44:49 TYA: RX Packet: "55aa010700080a020004000000001f"
16:44:49 TYA: RX Unknown ID=10
16:44:49 TYA: RX Packet: "55aa0107000865020004000000007a"
16:44:49 TYA: RX Unknown ID=101
16:44:49 TYA: RX Packet: "55aa0107000866020004000000007b"
16:44:49 TYA: Rx Unknown ID=102
16:44:49 TYA: RX Packet: "55aa0107000867020004000000007c"
16:44:49 TYA: Rx Unknown ID=103
16:44:49 TYA: RX Packet: "55aa0107000868020004000009870d"
16:44:49 TYA: Rx Unknown ID=104
```
4. The function ids are printed as `TYA: Rx Unknown ID=XXX` We will use these XXX ids in guide ahead
### Dimmer
We need to configure 3 functions of dimmer
1. Dimming DP ID
2. Dimming Range
3. Power metering if supported.
4. Dimming less than 10%
#### Dimming DP ID
Dimming DP ID is controlled by [SetOption34](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption34)
Generally this is `2` or `3`. The easiest is to try both
1. Goto console and type `SetOption34 2`
2. enter command `dimmer 10` and `dimmer 100`
If your bulb responds to `dimmer` commands you have successfully configured dimmer function id. Note it for future.
If not try id `3` and if even `3` doesn't work keep trying ids from all unknown ids from log till one works.
#### Dimming Range
Once you have figured out the dimming function id, we need to find the maximum dimming range. Once dimming id is set, the logs will keep showing like
```
16:50:55 TYA: Heartbeat
16:50:55 TYA: RX Packet: "55aa03070005010100010011"
16:50:55 TYA: RX Device-1 --> MCU State: Off Current State:Off
16:50:55 TYA: RX Packet: "55aa03070008020200040000000720"
16:50:55 TYA: RX Dim State=7
```
Now using the hardware buttons increase the dimmer to its maximum and observe the log. The `Dim State=XXX` shows the current dimmer level reported by MCU. Once the dimmer is at max, use this number. Now we need to tell Tasmota to use this as maximum. This controlled by [SetOption43](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption43)
We can set it using `SetOption43 XXX` where XXX is the maximum dimmer state reported in logs.
Once set try `dimmer 100` in the logs and check if the brightness of bulb is same is maximum set using hardware buttons.
#### Power metering
Some Tuya serial devices support Power measurement support over serial. For this its better to use a bulb with known rating.
Observe in console, the logs would show like
```16:51:13 TYA: RX Packet: "55aa03070005010100010011"
16:51:13 TYA: RX Device-1 --> MCU State: Off Current State:Off
16:51:13 TYA: RX Packet: "55aa03070008020200040000000720"
16:51:13 TYA: RX Dim State=7
16:51:13 TYA: RX Packet: "55aa0307000803020004000000001a"
16:51:13 TYA: RX Unknown ID=3
16:51:13 TYA: RX Packet: "55aa0307000804020004000000251b"
16:51:13 TYA: RX Unknown ID=4
16:51:13 TYA: RX Packet: "55aa0307000805020004000000591c"
16:51:13 TYA: RX Unknown ID=5
16:51:13 TYA: RX Packet: "55aa03070008060200040000098fb5"
16:51:13 TYA: RX Unknown ID=6
```
In here we are interested in the 3 digits before last 2 digits for example
`98f` in `"55aa03070008060200040000098fb5"`
1. Make sure the bulb if off at the moment.
2. Find out the voltage standard of your country (generally 220, 240, 110v) from [table here](https://www.worldstandards.eu/electricity/plug-voltage-by-country/) For example we have 240
3. Multiply that number by 10 (2400) and Convert that number (2400) to Hex using any [hex convertor](https://www.binaryhexconverter.com/decimal-to-hex-converter) which gives you 0x960.
4. Now see the number nearest to `960` in the logs. In our case it is `98f`. So we expect thats the voltage which is `ID=6` in our example.
5. Set voltage id using [SetOption44](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption44) by entering command `SetOption44 6`
6. Now set dimmer to 100% by command `dimmer 100` and observe logs.
7. Now we need the power rating of your bulb example `9W`. Multiply by 10 (90) and convert to hex which gives us `5A`. Check which unknown ID is close to `5A` in our case is `59` for `ID=5`. This is the id of `Active Power` function.
8. Set the active power id using [SetOption46](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption46) using command `SetOption46 5`
9. Once Power and Voltage are set the logs will start showing
```
16:51:13 TYA: RX Packet: "55aa03070005010100010011"
16:51:13 TYA: RX Device-1 --> MCU State: Off Current State:Off
16:51:13 TYA: RX Packet: "55aa03070008020200040000000720"
16:51:13 TYA: RX Dim State=7
16:51:13 TYA: RX Packet: "55aa0307000803020004000000001a"
16:51:13 TYA: RX Unknown ID=3
16:51:13 TYA: RX Packet: "55aa0307000804020004000000251b"
16:51:13 TYA: RX Unknown ID=4
16:51:13 TYA: RX Packet: "55aa0307000805020004000000591c"
16:51:13 TYA: Rx ID=5 Active_Power=9
16:51:13 TYA: RX Packet: "55aa03070008060200040000098fb5"
16:51:13 TYA: Rx ID=6 Voltage=244.7
```
10. To get current Id, Calculate `Current = Power / Voltage ( 9 / 244.7 ) = 0.0367`. `Multiply this by 1000 = 36.77.`
Now convert `36` to hex which is `0x24`. This is closest to `25` which is our current id 4.
11. Set the current id using [SetOption45](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption45) using command `SetOption45 4`.
12. Observe the logs should start showing
```
16:51:13 TYA: RX Packet: "55aa03070008020200040000000720"
16:51:13 TYA: RX Dim State=24
16:51:13 TYA: RX Packet: "55aa0307000803020004000000001a"
16:51:13 TYA: RX Unknown ID=3
16:51:13 TYA: RX Packet: "55aa0307000804020004000000251b"
16:51:13 TYA: Rx ID=4 Current=0.036
16:51:13 TYA: RX Packet: "55aa0307000805020004000000591c"
16:51:13 TYA: Rx ID=5 Active_Power=9
16:51:13 TYA: RX Packet: "55aa03070008060200040000098fb5"
16:51:13 TYA: Rx ID=6 Voltage=244.7
```
13. Power and current should change on dimming high / low. Tasmota web gui should show power values now.
#### Dimming less than 10%
By default tasmota blocks dimming less than 10% for dimmers. Some dimmers can handle less than 10% very well.
1. Turn the dimmer to lowest using hardware button.
2. Check the `Dim state=` in logs to see whats minimum.
3. If `Dim state` is less than 10% of maximum range that was set you need to unset [SetOption69](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption69) by `SetOption69 0` command.
### Switches
For switches we need to
1. Disable dimming control.
2. Configure the number of relays
3. Configure Power metering.
#### Disable dimming control
By default Tuya dimmer module expects device to be a dimmer so to let Tasmota know that device is a MCU based switch we need to disable dimming controls using [SetOption65](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption65) by using command `SetOption65 1`
#### Configure number of relays
By default Tuya Dimmer module expects 1 gang switch. There is no way currently to detect the number of relays present in MCU based switch, we need to tell it to Tasmota using [SetOption41](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands#Setoption41).
So for 4 gang switch we need to set `SetOption41 3` to tell that we have 3 more
#### Configure power metering
Power metering configuration is same as for dimmers. Check the power metering section for dimmers.
8. Follow the process [here](https://github.com/arendst/Sonoff-Tasmota/wiki/TuyaMCU) depending on switch or dimmer.
## Product Specific guides (below)