Skip to content

Latest commit

 

History

History
13 lines (11 loc) · 4.24 KB

README.md

File metadata and controls

13 lines (11 loc) · 4.24 KB

Alternative firmware ZMAi-90 (TYWE3S+V9821/V9821S) with Mqtt support.

PROJECT_PHOTO

Current version is 2024.02.05.

  • 2024.02.05. At startup, the gateway scans all WIFI APs with the required parameters and selects the AP with the best level. Relevant for mesh systems. Added selection of WIFI 802.11b/g/n mode in settings. The availability of devices in Home Assistant has been fixed. If the gateway is unavailable, all devices connected to it become unavailable.
  • 2023.08.04. Changed object names in Home Assistant Mqtt Discovery to be compatible with version 2023.8.0.

1. Opportunities

 Mqtt displays 4 main measured parameters: voltage, current, power and energy consumed. Apparent power and power factor are calculated. To synchronize energy readings with the commercial meter, the Energy offset option is provided. The value from this field is added (or subtracted) to the current readings when output to Mqtt. Relay control is available either by long pressing the button or via Mqtt. I can hardly imagine the meaning of a power outage in the entire house or apartment, and therefore the relay turns on every time the TYWE3S is rebooted. Two control modes via Mqtt are supported. If the option "Mqtt "OFF" switch to "ON" after 30sec delay" is disabled, when a turn-off command is received, the relay is turned off until the turn-on command arrives or the ZMAi-90 is rebooted. If at the same time the power to the smart home server or router is lost, it will no longer be possible to turn on the relay remotely. You will have to wait for the voltage to disappear at the input of the ZMAi-90 or press the button locally. If this option is enabled, the shutdown command only turns the relay off for 30 seconds, after which the relay turns on again. This makes it possible to remotely reset all devices in a house or apartment by removing the voltage. Home Assistant Mqtt Discovery is supported. The firmware is designed to work with the new revision (I have 2034) ZMAi-90, in which TYWE3S/ESP8266 uses only the serial port to control the device. Supported MCU V9821 or V9821S, selectable in settings. ZMAI-90 can be assembled on V9821S paired with WB3S. To work with this firmware, WB3S must be replaced with ESP12. The fzmai.bin file in the build folder is an already assembled binary for TYWE3S (esp8266) with 1 MB of memory and is flashed in one file from address 0x0000 to a clean TYWE3S/ESP8266. Instead, you can also use three standard files for flashing: bootloader.bin (address 0x000), partitions.bin (address 0x8000) and zmai.bin (address 0x10000). The zmai.bin file can also be used to update the firmware via the web interface. Before flashing the firmware, you need to short-circuit the RST input (47 leg) of the MCU V9821 to the case so that it does not interfere with the firmware. More details here. After flashing, the jumper must be removed. Then you need to create a guest Wi-Fi network in the router with ssid "zmai" and password "12345678", wait until TYWE3S connects to it, enter the TYWE3S IP address in the web browser and set the remaining parameters in the Setting tab. After which the guest network is no longer needed. TYWE3S will only attempt to connect to the "zmai" network if the main network is unavailable, for example if the password is incorrect. If you cannot connect to the guest network, TYWE3S reboots. It is possible to connect several ZMAi-90 to one MQTT server. To do this, you need to install your own ZMAi-90 Number in each device. Device number 0 will write to topic zmai/..., device number 1 - zmai1/..., etc.
PROJECT_PHOTO

2. Build the project

 To build the esp-01(esp8266) binary files, ESP8266_RTOS_SDK (IDF Style) version 3.2 was used (the latest version with OTA does not fit into the 1MB of esp-01 memory) with a description and toolchain 5.2.0. I got the more recent esp-mqtt library here.