All Projects → openlumi → openlumi.github.io

openlumi / openlumi.github.io

Licence: other
OpenWrt for Xiaomi Zigbee gateway with imx6 SoC DGNWG05LM, ZHWG11LM

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to openlumi.github.io

Openwrtinvasion
Root shell exploit for several Xiaomi routers: 4A Gigabit, 4A 100M, 4, 4C, 3Gv2, 4Q, miWifi 3C...
Stars: ✭ 366 (+173.13%)
Mutual labels:  openwrt, xiaomi
homebridge-zigbee-nt
A standalone ZigBee plugin that works with CC2531 USB dongle or Deconz
Stars: ✭ 53 (-60.45%)
Mutual labels:  zigbee, xiaomi-smart-home
miio-go
An implementation of the miIO home protocol by Xiaomi written in Golang.
Stars: ✭ 35 (-73.88%)
Mutual labels:  xiaomi, xiaomi-smart-home
Abeille
Abeille pour Jeedom (Gateway ZiGate)
Stars: ✭ 56 (-58.21%)
Mutual labels:  xiaomi, zigbee
xiaomi-mi-air-purifier
Homebridge plugin for Xiaomi Mi Air Purifier
Stars: ✭ 67 (-50%)
Mutual labels:  xiaomi, xiaomi-smart-home
Mi Flower mate plugin
A plugin for Domoticz, the open source home automation software, which allows it to easily connect to Xiaomi Mi Flower Mate devices
Stars: ✭ 13 (-90.3%)
Mutual labels:  xiaomi, xiaomi-smart-home
homebridge-zigbee
ZigBee Platform plugin for HomeBridge
Stars: ✭ 101 (-24.63%)
Mutual labels:  xiaomi, zigbee
xiaomi-r3g-openwrt-builder
OpenWrt builder for any supported routers using Docker. Scheduled to run weekly
Stars: ✭ 25 (-81.34%)
Mutual labels:  openwrt, xiaomi
Ac2100 Openwrt Guide
Install OpenWrt on the AC2100 (black cylinder)
Stars: ✭ 80 (-40.3%)
Mutual labels:  openwrt, xiaomi
nrf24 zigbee
This project is about running zigbee protocol in nrf24l01.
Stars: ✭ 26 (-80.6%)
Mutual labels:  zigbee
Student-homeassistant-config
🎓 Student Home configuration. Stay informed by 🌟 this repository for updates!
Stars: ✭ 160 (+19.4%)
Mutual labels:  zigbee
go-uci
Native Go bindings for OpenWrt's UCI.
Stars: ✭ 69 (-48.51%)
Mutual labels:  openwrt
nrf52840-experiments
802.15.4 experiments with nRF52840
Stars: ✭ 23 (-82.84%)
Mutual labels:  zigbee
hass-miio-yeelink
Xiaomi Miio Yeelink/Yeelight devices for Home Assistant
Stars: ✭ 140 (+4.48%)
Mutual labels:  xiaomi
custom-brand-icons
Custom brand icons for Home Assistant
Stars: ✭ 242 (+80.6%)
Mutual labels:  xiaomi
mifitxiaomipiholelist
MiFit/Xiaomi PiHole Bock List
Stars: ✭ 28 (-79.1%)
Mutual labels:  xiaomi
Lede
Lean's OpenWrt source
Stars: ✭ 19,062 (+14125.37%)
Mutual labels:  openwrt
SwiftyXBee
⚡️ A Swift library for communicating with XBee radios in API mode
Stars: ✭ 22 (-83.58%)
Mutual labels:  zigbee
node-lumi-aqara
Control your Xiaomi Smart Home devices with this Lumi Aqara library
Stars: ✭ 45 (-66.42%)
Mutual labels:  xiaomi
saklarku
Aplikasi mobile remote control untuk mengendalikan saklar/relay yang terhubung dengan port LED/GPIO di router berbasis OpenWRT
Stars: ✭ 20 (-85.07%)
Mutual labels:  openwrt

Install an Alternate OpenWRT firmware on DGNWG05LM and ZHWG11LM gateways

These instructions apply only to:

  • The European version of the gateway mieu01 from Xiaomi, with a European plug
  • A version of the gateway from Aqara ZHWG11LM, with a Chinese or European plug.

The instructions will not work for the Xiaomi gateway2 version, with the Chinese plug DGNWG02LM. That version has other hardware components installed.

Table of Contents

Before you begin

  • Get root
  • Make a backup

Get root

These instructions assume that you already have ssh access to the gateway. If you do not, follow the instructions to get root.

Make a backup

Do make a back-up copy.

If you decide to return to the stock firmware, you will need the tar.gz backup from your device, with an archive of your root filesystem.

You cannot use a generic backup, because all firmware contains unique IDs and keys.

Light backup

This command will send the content of the files with keys to termbin.com and print you an URL in console. Open the link in a browser and save the content. It will help you to restore keys using generic backup.

cd /lumi/conf/
for fn in *; do printf "=== Start $fn ===\n"; cat "$fn"; printf "=== End $fn ===\n"; done |  nc termbin.com 9999

Links to download generic backups without keys to connect to Xiaomi Cloud (replace with keys from backup):

Full backup

tar -cvpzf /tmp/lumi_stock.tar.gz -C / . --exclude='./tmp/*' --exclude='./proc/*' --exclude='./sys/*'

After the backup is done, download it to your local computer.

scp root@*GATEWAY_IP*:/tmp/lumi_stock.tar.gz .

You can also use WinScp in scp mode (dropbear on the gateway doesn't support sftp mode).

Even if you already have made a rootfs image with dd, make an archive anyway.

During the boot phase of the dd image, nand flash or ubifs errors usually occur. Using the tar.gz option avoids these drawbacks, because it formats the flash before writing the files.

Flash your device over the air

Flashing your device over the air (OTA) is the easiest and recommended way. The method does not require soldering, and you can do it with a serial console or via ssh.

Before flashing, make sure that the gateway is connected to the internet. You also need to double-check that you don't have any redundant archives in the /tmp directory. You'll need space to download the firmware binaries.

The following commands work only on stock firmware:

echo -e "GET /openlumi/owrt-installer/main/install.sh HTTP/1.0\nHost: raw.githubusercontent.com\n" | openssl s_client -quiet -connect raw.githubusercontent.com:443 -servername raw.githubusercontent.com 2>/dev/null | sed '1,/^\r$/d' | bash

This command stops all the processes on the gateway. If you are updating via ssh, the connection will drop─this is normal. The flashing process takes a few minutes. After it is done, the gateway will create an open Wi-Fi network with the name OpenWrt.

Error recovery: the Over-the-Air method did not work for you

If the preceding method fails for some reason, you can bring the gateway back to life by soldering the usb and uart, and flashing it through mfgtools.

See the instructions to flash over USB

How to use OpenWrt

After flashing, the gateway creates an open Wi-Fi network with the name OpenWrt.

Connect the gateway to your router

  1. To connect the gateway to your router, connect to the network and go to http://192.168.1.1/ .

    The default credentials for the gateway are:

     - login 'root': without a password.
    
  2. Go to the section Network > Wireless

Go to Wireless

  1. Press the Scan button against the first interface radio0. After a few seconds, you will see a list of networks. Find your network and press Join Network

Scan

  1. In the pop-up window, set the "Replace wireless configuration" checkbox. Enter the passphrase from your Wi-Fi network below

WiFi password

  1. Confirm the settings on the next window, press the Save.

WiFi password-2

  1. To apply the changes correctly, disable Access Poing by pressing Disable for the connection for the second interface.

Disable AP

The gateway will disconnect you from AP and apply the changes. After the firmware, the mac address of the gateway changes, because the IP address also most likely changes. Check it in the router or in the gateway itself.

The gateway is pre-installed:

  • OpenWrt LuCi GUI on port 80 http
  • command utility for flashing zigbee module jn5169
  • Web plugin for LuCi to flash a firmware

Do not enable Wi-Fi AP + Station modes on the gateway at the same time. The driver that is used in the system cannot work in two modes at the same time.

If you changed the LuCi settings and the gateway stopped connecting to the network, press the button on the gateway for 10 seconds. It will blink yellow 3 times and with start the initial network configuration mode with the create Wi-Fi Access Point.

Working with ZigBee

The Zigbee chip can work only with a single system. You have to choose which program you'd like to use. At the same time, you can use zigbee2mqtt to work with Zigbee and domoticz for other automation.

  1. Installing Zigbee2mqtt
  2. Installing Home Assistant with ZHA component
  3. Installing Zesp32
  4. Installing Domoticz and configuring Zigate plugin

Other software you might want to use

  1. https://github.com/openlumi/lumimqtt/ - a service that lets you manage gateway devices over the MQTT
  2. https://flows.nodered.org/node/node-red-contrib-xiaomi-gateway - a package for node red

Restore settings

If you want to go back some steps, these instructions can help you.

Reset to the defaults

Be careful with resetting, all programs and settings will be erased. Use it in case of emergency, when resetting Wi-Fi credentials does not help.

To go back to the initial set up (like you just flashed the gateway), there are two ways to erase the data on the OpenWRT:

  • Hold the button.

    You must hold the gateway button for 20 seconds. The gateway will blink red 3 times and reset to the initial set up for creating a Wi-Fi Access

  • UART

    Connect the gateway with the UART 2 USB adapter (like in the step get root) and wait for the system to load.

    Enter the following commands.

    firstboot -y && reboot now
    

If system boot doesn`t complete

  • press f multiple times while booting in progress for enter to failsafe mode.
  • Run ubirmvol /dev/ubi0 -Nrootfs_data && ubimkvol /dev/ubi0 -Nrootfs_data -m.

Return to stock firmware

To return to the stock firmware, you need to flash the original kernel, DTB, and rootfs from your backup. The Kernel and DTB are the same for all gateways. To keep the Mi Home working, you'll need your tar.gz backup.

mfgtools to return to the stock firmware

Name your backup lumi_stock.tar.gz. Put it in the directory Profiles/Linux/OS Firmware/files. This overwrites the empty file lumi_stock.tar.gz

Then put the gateway into boot mode via usb and use mfgtools to flash the original firmware.

To flash zigbee firmware back, you should log in to the gateway with stock firmware and run the command

touch /home/root/need_update_coordinator.tag

Then reboot. Once restarted, the gateway will automatically restore Zigbee firmware.

To allow zigbee chip accepting devices you have to clear internal memory PDM:

stty -F "/dev/ttymxc1" raw 115200
printf '\x01\x02\x10\x12\x02\x10\x02\x10\x12\x03' > /dev/ttymxc1

Reference of general-purpose input/output (GPIO)

Kudos to @Clear_Highway and @lmahmutov for these.

gateway_pinout_gpio

Install the kernel modules:

opkg update
opkg install gpioctl-sysfs
opkg install kmod-spi-gpio
opkg install kmod-spi-dev
opkg install kmod-spi-gpio-custom

Control─working with GPIO pins:

echo "69" > /sys/class/gpio/export
echo "70" > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio69/direction
echo "out" > /sys/class/gpio/gpio70/direction


echo "1" > /sys/class/gpio/gpio70/value
echo "0" > /sys/class/gpio/gpio70/value

GPIO numbers. Contact numbers start from the lowest and go up. DOWN and UP represents the type of pulling. Down to GND, UP - 3.3v

Num PULL GPIO
2 DOWN 69
1 DOWN 70
14 DOWN 71
15 DOWN 72
16 UP 73
4 DOWN 74
3 DOWN 75
17 UP 76
6 DOWN 77
5 DOWN 78
18 DOWN 79
20 UP 80
19 DOWN 81
8 DOWN 82
7 DOWN 83
22 DOWN 84
21 DOWN 85
10 DOWN 86
9 DOWN 87
24 DOWN 88
23 DOWN 89
12 DOWN 90
11 DOWN 91
13 DOWN 92

Links

  1. An article that details the changes and technical modifications: [Xiaomi Gateway (eu version - Lumi.gateway.mieu01) Hacked] (https://habr.com/ru/post/494296/)
  2. Collection of information on hardware and software modding of Xiaomi Gateway https://github.com/T-REX-XP/XiaomiGatewayHack
  3. Telegram channel with discussion of modifications https://t.me/xiaomi_gw_hack
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].