Ad

Sunday, December 22, 2019

ZMAi-90 (or SMTONOFF WDS688) DIN rail meter/switch - more details on GPIOs and configuration

As an update to the previous post where I have shared the details on how to "Tasmotize" this device, I am adding more detail on what is the physical assignement of GPIO pins from the ESP8266, to other components in this device.

Given the pins from the ESP8266 microcontroller that are exposed in its breakout board (which in turn is SMD soldered to the main PCB):


We have the following identified connections:

TYWE3S module:

  • GPIO0 - not connected. Must be used to put the ESP in programming mode, by pulling it down to GND;
  • GPIO2 - in the original Tuya firmware is used as debug serial port (TX pin only) and is configured to 74880 8N1. It is one of the two available hardware serial ports in the ESP8266, but it only features a TX output;
  • GPIO4 - it is connected to the blue LED;
  • GPIO5 - apparently not connected to anything;
  • GPIO6 - N/A
  • GPIO7 - N/A
  • GPIO8 - N/A
  • GPIO9 - N/A
  • GPIO10 - N/A
  • GPIO11 - N/A
  • GPIO12 - Relay control - this connects to a GPIO pin on the V9821 chip. The later in turn provides the pulses to actually control the bistable relay;
  • GPIO13 - Push button - should be configured as Button1n in Tasmota, in order to be used to turn on and off the relay (this feature doesn't exist in the original Tuya firmware - hence another advantage of "Tasmotizing" this device);
  • GPIO14 - apparently not connected to anything;
  • GPIO15 - has a physical connection  on the PCB, but not yet clear what its role could have been on the original firmware. Is connected to R10, which is a 3.3 KOhm resistor that pulls to the V9821 analog ground (AVSS pin 4 on this device);
  • GPIO16 - apparently not connected to anything;
  • EN - to enable the ESP8266
  • ADC - provides an analog input to the ESP8266. Apparently not connected to anything;
  • RST - used to reset the ESP8266. Apparently not connected.
PCB:

  • RSTn - if set to low, causes the V9821 chip to reset. If left as low (i.e. pulled down to GND) causes the chip to remain inactive. It is necessary to leave it in this state while programming the ESP8266, otherwise the serial connection between the two will prevent the external UART (your PC serial port for example) to communicate with the ESP8266.
  • Relay1, Relay2 - these signals originate from the V9821 chip, and are used to control the relay driver, in order to turn the relay on or off;
  • Metering analog inputs - these provide the input signals for metering, namely the small voltage differential from the current shunt, and voltage signal which is provided by a resistive divider, which drops the mains voltage to a value within the spec of the metering chip;

For Tasmota, the correct configuration including also the push button, should therefore be set as:


With the push button configured this way, each button press will toggle the state of the relay, hence causing the power to be turned on or off directly from the device, which is quite useful.


10 comments:

Stargazer said...

You have done an amazing job. As a complete noob I manage to setup my WDS688 within less than an afternoon. I truly hope you manage to find a way to reset the data on the V9821 via a serial command or othwewise, without having to pull the nRst to ground.
Thanks again for your valuable work!

Creation Factory said...

Hi @Stargazer, I am happy that you were able to successfully convert the WDS688 device. At the same time it is useful to have the confirmation of the suspicion that this device was the same hardware as the ZMAi-90.

Nice one!

Thanks

Stargazer said...

Everything in your guide worked flawlessly
The only thing I can add is that if you set gpio to button it resets the esp and goes back to tasmota pairing mode. So to sum up an answer to your question yes I think they are identical. Is there any other way to reset the data of the V9821?

Creation Factory said...

Hi @Stargazer, regarding the GPIO please make sure you set it to Button1n and not Button1, bacause in the circuit, when pressing the button it pulls down the input and not the opposite.
Regarding the V9821, for programming the main chip, pulling down the RSTn pin was the simplest way I could find, to keep it from talking to the ESP8266. You will always need to disable the chip somehow, because otherwise its pin status will prevent the TX/RX pins of the ESP8266 to talk to another UART. In respect to resetting the data (the energy consumption counter I presume?), there may be a command to reset that register or something, but I haven't yet figured out which. Once the device is converted to Tasmota it is easier for someone to experiment with the commands, sending these through the console, e.g.:

SerialSend5 fe010f080000001c

You may risk messing up the calibration data if you discover such command first, though..

Mark said...

Hello

I had the same issue as stargazer, I pressed the button and it reset the wifi. I had mine set to button1n as well. Now I cannot do anything as no matter that tasmota button presses I do, I am getting nothing. Any way I can reset it please and start all over? I tried the press and hold for 40 seconds.. and nothing

Thanks

Creation Factory said...

Hello Mark, after the reset happens the devices shows up as an Access Point (tasmota-xxx)? Do you get the wifi password captive portal once you select it?

Cheers

Mark said...

Hello, it came up with the name I gave it and -xxx. So reentered the wifi details etc and it didn't connect. Eventually I did the 40 second press to reset and then, 4 short presses (a few times) and it came back after a while with tasmota-xxx and I configured it and it is all sorted. I just won't press the button again as I really don't need to :)

Unknown said...

Hi
THanks for this project its real helpful and got me well underway
the when i tasmotized it with lite and did an upgrade to 8.3.1 then setup the relay, wen i click the toggle button it says on and off bu only changes the www page not the relay im thinking the pins dont do what they did ? and the button just resets the wifi and does not toggle the relay either
welcome any comments

Creation Factory said...

Hi @Unknown, are you setting the GPIOs as described in the screenshot.? From your description it seems like both GPIO12 (wired to the relay) and GPIO13 (input from the push button) might not be correctly configured in the module configuration page. Can you verify?

Thanks

Cheers

Unknown said...

they are as per the screen shot, interesting if you press the button it resets the wifi config and possible other config the toggle does nothing