Gateway Xiaomi: activate LAN mode when theapp Xiaomi Home does not allow it

4 minutes of reading
PURPOSES OF THE GUIDE:
  • To force activation of LAN mode (in order to allow integration with HUB personal, for example the one with Home Assistant) of a BRIDGE/Gateway Xiaomi Mi Smart Home (Mijia) for which theapp Xiaomi Home does not allow it
  • Difficulty level: medium
CONCEPTS FACED:
  • Firmware interface
Software components used:
  • Putty or similar software
Physical devices used:
GUIDE MOST INDICATED FOR:

All environments

Notes and disclaimer
  • qualsiasi modifica all'impianto elettrico dev'essere effettuata da personale qualificato;
  • any changes implemented in probefore is a propersonal responsibility as well as a profirst risk and danger (this guide is for educational purposes only);
  • any changes implemented in probefore a device will void the warranty.
Driving review: 1.4

Abstract

Il BRIDGE/Gateway Zigbee↔︎TCP/IP of the line Xiaomi Mi Smart Home (Mijia) is a simple but functional device that can act as a collector for devices ZigBee of his line (but also others, like those of the line IKEA TRÅDFRI) in order to allow it to be controlled via Wi-Fi through theapp Xiaomi Home. Moreover, the possibility of integration such gateway to HUB personal ensures that all the components connected to it are (in) directly manageable from procentralized personal home automation: sensors, actuators, and so on and so forth.

To implement this integration it is necessary to activate at the device LAN mode ("Dev mode"), a mode to open the door 9898 UDP / IP at Gateway same in order to be able to control it directly from the local network, and therefore from personal HUBinformation which additions provide appto connect directly to the device.

On the market there are two different models of gateway which are often confused: the Mi Smart Home (Mijia) (subject of this guide) and theAqara. The latter is compatible with Appthe HomeKits, but no it is possible to integrate it with Home Assistant (nor with others HUB) as there seems to be no way to activate the LAN mode ("dev mode") - a mode necessary for such additions instead of the gateway Mi Smart Home (Mijia) It supports.

The first though - in some unfortunate cases - suffers from a proBlema specific: if it was appa given updatenamento firmware (all versions subsequent to 1.41.159) before of the activation of the LAN mode, it it will no longer be activated means app Xiaomi Home (see for example the integration guide Home Assistant).

Xiaomi Gateway firmware update
NEVER EXECUTE IT!

There is no need to despair: it is in fact possible to physically connect to Gateway in order to execute a console command which prosee the forced opening of the 9898 UDP / IP port, which appactivates the much sought after LAN mode.

This technique is the subject of this guide.

Prerequisites

Being a technique of physical connection to the device it is obviously necessary a physical "link" that connects our computer to appto the device.

To this end we will use the well-known adapter USB / TTL and its USB connection cable (used extensively for the riprofirmware grammation of many home automation components and not), as well as of the Dupont connection cables; finally, a welder, necessary to weld the contacts on the device board.

Finally, a set is needed of screwdrivers with forked tip (U-shaped tip).

Prosubsidence

The sequence is simple:

  • open the device;
  • solder contacts;
  • connect the USB / TTL adapter;
  • install Putty;
  • turn on the device;
  • execute the command necessary to open the door.
Open the device

Opening it is easy: simply turn the unit over and remove the three t'sappthe whites on the bottom.With a fork screwdriver (tip U) remove the three screws in the three compartments.

At this point open - very gently - the device. On the back there is the speaker of the device, which is connected with a bipolar cable to the board: gently remove the connector and set the piece aside.

Solder contacts

Here comes the difficulty: it is necessary to identify the contact pad and weld on it three Dupont wires (previously stripped from the side that goes to the device). The pins on the pitch are: TX, GND, RX, VCC (from left to right in the photo); the pins to be welded are alone TX, GND and RX, while the VCC pin (the first from the right in the picture) it must absolutely not be welded:

Xiaomi Mijia - serialOnce the welding is completed, it is possible profollow over.

Install Putty

At this point install the Putty software on your computer (available for Windows, For macOS and Linux) and execute it.
Then open a new connection with the following parameters: 115200 8, N, 1 and flow control Xon / Xoff.

Connect the USB / TTL adapter

At this point connect the USB / TTL adapter to the USB and USB computer Gateway through the three welded contacts, remembering once again that the VCC pole it must not be connected for any reason between the USB / TTL adapter and the device.

Nb Remember to connect RX to TX and TX to RX. Before turning on the device, leave the RX pin disconnected (ie the USB of the USB / TTL adapter)

Turn on the device

At this point, power the device using 220v mains voltage.

ATTENZIONE!! The electric current non è un gioco. Pay particular attention to this phase, we decline all responsibility: this guide is for educational purposes only. Be careful what you do, be responsible.

After switching on, bootload will be performed (booting the operating system of Gateway); when finished, press send to Putty.
Appthe character "#" will appear on the Putty console. AppIf bootloading occurs, connect the RX contact.

Execute the command

At this point, at the Putty console, run the following command:

psm-set network.open_pf 3

Next, execute the verification command:

psm-get network.open_pf 

After this phase, turn off and on again the Gateway. After rebooting, run the following command:

sudo nmap -Pn -sU IP_DEL_GATEWAY -p 9898

(where is it "IP_DEL_GATEWAY"Is the IP assigned to the gateway from the router Wi-Fi) which should provide an output similar to the following:

Starting Nmap 7.40 ( https://nmap.org ) at 1980-01-01 22:20 CET
Nmap scan report for xxxxxx (xxx.xxx.xxx.xxx)
Host is up (0.10s latency).
PORT     STATE SERVICE
9898/udp open  monkeycom
MAC Address: XX:XX:XX:XX:XX (Unknown)

The presence of the string "9898 / udp open monkeycom”Denotes the effectiveness of the change implemented.

utilization

At this point it is possible disconnect everything, reassemble the Gateway and use it proseeing to integrate it in the manner provided at the various HUB personal.

An example? Integration with Home Assistant.


Please comment below