Setting up a Zigbee WiFi bridge using Tasmota and Sonoff hardware


This post is about bridging Zigbee devices to my Home Assistant server.

From Wikipedia : “Zigbee is a low-cost, low-power, wireless mesh network standard targeted at battery-powered devices in wireless control and monitoring applications. Zigbee delivers low-latency communication. Zigbee chips are typically integrated with radios and with microcontrollers.”

zigbee logo

Make sure to not confuse with Z-Wave, they are not compatible even if they are wireless low-power mesh networks.

Being low-power, Zigbee is especially useful to battery powered devices like:

In case you’re wondering, left box is the Sonoff Zigbee Bridge (ZBBridge) and is required.

Mesh network​

The zigbee wireless networking uses a mesh topology, meaning that devices known as routers are speaking to each other, routing message all around as needed to reach far nodes. One cost is that this drains battery, so having always on nodes is not practical when running on batteries. I recommend on any big network to have a few nodes powered by main, such as plugs, light switches or light bulbs.

In a nutshell:

  • Zigbee Coordinator : Usually a bridge or USB dongle, this is the brain of the network and is required;
  • Zigbee Router : Usually always-on devices like switches on mains power, not required but helps a LOT for bigger networks;
  • Zigbee End Device : All devices actually, this includes battery powered devices and are not able to relay packets between devices, thus not enough for a big network.


This post assumes you already have a working installation of Home Assistant on your LAN network.

To build below minimum setup, on top of your Wi-Fi and Home Assistant, you need a Sonoff Zigbee Bridge (ZBBridge) and a Sonoff temperature / humidity sensor (SNZB-02).

The flashing process is done using a Serial-to-USB adapter, easiest is to grab one based on the CH340G chip or FTDI. Always double check voltage when using such adapter, using accordingly either 3.3V or 5V.

The zigbee bridge has two chips to connect to both zigbee and Wi-Fi networks, assuming the routing between both networks.

The nodes have a single zigbee chip for networking.

Getting started

We are going to setup a few things to use our temperature sensor node. Here are the building blocks, starting from the end node:

  • The temperature sensor has a single button to pair it to the zigbee network.
  • The Sonoff zigbee bridge is powered over USB and has a single button to enable pairing of new sensors. To use it with Home Assistant instead of the built-in eWeLink cloud app, we are going to flash a new firmware called Tasmota.
  • Lastly Home Assistant needs to add an integration to use zigbee bridge. This integration also helps manage the zigbee sensors.

The trickiest part being to flash Tasmota, most of this post is about that specific step.

Flashing Tasmota to Sonoff ZBBridge

A note about Tasmota and requirements

Tasmota is an open source firmware aimed at ESP8266 or ESP8285 based devices. It features a great flexibility and abilities to set it up using its built-in web interface.

Using the dedicated ZBBridge image (tasmota-zbbridge.bin), it is very easy to set its Wi-Fi network and MQTT connection settings.

So the macro steps are:

  • Open the ZBBridge device to access the PCB
  • Wire the Serial-to-USB on the ZBBridge PCB
  • Flash Tasmota using Tasmotizer
  • Disconnect the adapter
  • Power the ZBBridge over regular USB
  • Access the Tasmota web interface and finally configure the device
  • If everything went fine, put back the PCB in its enclosure

You’ll need some hardware:

  • Sonoff Zigbee bridge as our main victim of the day
  • Serial-to-USB adapter to flash firmware, one supporting 3.3V (5V would likely destroy your chip)
  • Breadboard and jumping wires
  • Computer with Wi-Fi or smartphone to setup Tasmota over Wi-Fi
  • Obviously, a computer with a USB port

… and a few pieces of software:

  • Tasmotizer for flashing. This is an all-in-one tool to automatically flash Tasmota to a device
  • Windows, if you use Tasmotizer as in this guide
  • web browser, I’m using Google Chrome

Refer to Tasmota Getting Started page if you’re new or not using Windows.

Wiring the ZBBridge to the Serial-to-USB adapter

If you’re used to flashing, don’t get fooled, you have to ground an extra pin, also there are multiple TX/RX on the ZBBridge.

Here is the correct wiring:

Adapter sideZBBridge sideNotes
GNDIO0Enable flashing of ESP chip
VCC3V3Power, don’t forget to set adapter to 3V3 and NOT 5V
RXETXData exchange
TXERXData exchange

I’m using breadboard jumper wires, there pins are thinner than usual Dupont cables. A Dupont won’t fit the small thru holes of the ZBBridge. Having proper connection might get tricky.


Connecting to Tasmota

After successfully flashing Tasmota firmware, the device starts a new Wi-Fi hotspot in the form tasmota_XXXXXX-####.

Connect to it and open to administrate the device.

Tasmota configuration​

Tasmota needs a few tweaks to work properly in our situation:

  • Updated firmware for the zigbee chip
  • Setup MQTT server and credentials
  • Activate Home Assistant ZHA template, delegating full control to Home Assistant
  • Optional : Network configuration, always nice to set a static IP address on the network

Flashing Zigbee firmware

Get latest firmware for zigbee chip from

From the Tasmota web UI, go to Firmware Upgrade > Upgrade by file upload

Note: Might be possible to use the direct OTA URL but I haven’t tried 🙂

Updating MQTT

From the Tasmota web UI, go to Console this time.

Issue below command to setup your MQTT server (you COULD use Configuration > Configure MQTT but I had issues saving credentials).

Adjust the command as per your requirements, especially mqtthost, mqttuser and mqttpassword.

Backlog mqtthost; mqttport 1883; mqttuser XXXX; mqttpassword XXXX; topic zigbridge

Device will restart.

Activate Home Assistant ZHA template

Back to the console, use this line as-is, except if you want to use a custom port (default is 8888).

backlog rule1 on system#boot do TCPStart 8888 endon ; rule1 1 ; template {"NAME":"Sonoff ZHABridge","GPIO":[56,208,0,209,59,58,0,0,0,0,0,0,17],"FLAG":0,"BASE":18} ; module 0

Defining a static IP address

This is optional but my ISP router limits DHCP to range x.x.x.2 to x.x.x.26.

The “IPAddressX” commands means:

  1. IP address
  2. Gateway
  3. Mask
  4. DNS server (here, Google)
IPAddress1 192.168.0.XXX
restart 1

Restart one more time, but the device is very fast to reboot and reconnect!

See Tasmota Commands / Wi-Fi for full reference. If you do this often, consider using backlog command.

Adding ZBBridge to Home Assistant

Finally, let’s add the Zigbee bridge to Home Assistant.

In Home Assisstant, go to Configuration > Integrations > Add integration

Select Zigbee Home Automation from the list of integrations.

Configure using :

  • Serial port : Enter manualy
  • Ratio type : EZSP
  • Serial device path : socket://:8888
  • Speed: 115200

It should detect your bridge and add it to integrations.

Adding devices

To add a zigbee device, go to Configuration > Integrations and hit Configure on your Zigbee Home Automation integration.

At the bottom right is a “+ Add device” button, hit it.

This starts pairing mode for the coordinator, it’s time to press pairing button on the SNZB-02 temp/humidity device.

As you add devices, they’ll appear in the screen, proposing to set their name.

About devices

Once you’re done adding devices, you can review what’s done from Devices menu.

Since these are not using WiFi, that’s the only place you can check their state and especially the battery level.

The sensors are automatically created for them. You’re done for the zigbee configuration!

About sensors

When sensors are created, use the Developer Tools menu of Home Assistant to have a look.

I’m filtering here on the one added for the demo:

Post Author: Shut

6 thoughts on “Setting up a Zigbee WiFi bridge using Tasmota and Sonoff hardware


    (2021-02-12 - 18:47)

    Hello !
    Ok, it works well, thanks! but if I have more than one bridge? I cannot add multiple ZHAs ..


    (2021-03-31 - 01:09)

    Hi, thanks for the article. I have a question. Sonoff says this bridge supports only 32 devices, also as far as my research has told me, that seems to be the limit to any zigbee coordinator. So if I need more devices do I have to pair another bridge to the existing bridge and they will talk to each other? How does that work?


      (2021-03-31 - 02:01)

      I haven’t seen anything about a 32 devices limit, except if specific to a device/chip, can you point me to that?
      I found however this thread :
      Some people are able to achieve network of 100’s devices. However the feasibility is rather limited by network use and distances.
      My zigbee network is currently quite small (1 coordinator, 2 routers, 6 nodes), but I’ve added 2 powered devices to act as routers and limit dependencies on battery powered devices.


    (2021-03-31 - 11:27)

    Turns out I found an answer earlier.
    I saw a paper online that says the theoretical capacity for a zigbee network is of around 64000 total devices.
    But any zigbee COORDINATOR has a maximum capacity of around 32 “end devices” like maybe battery powered sensors (some people report getting around 40).
    The way out seems to be to use devices that are always plugged in (like sonoff mini zigbee, or some light bulb) since MOST of them can work as a router also. By using those devices there’s virtually no limit for the network. Also, the more routers you have the better the mesh network will become (it seems to take time to get to “Know” every node in the network).
    As you said, I don’t really know about the feasibility of that either, but it sure would be fun to try with thousands of devices lol
    This guy mapped a zigbee mesh network:


      (2021-04-02 - 12:02)

      Thanks for feedback, that was also my understanding.
      Anyway it kind of is mandatory to have “always on” devices. If you don’t have any, I doubt the network throughput and latency would make it usable.

      For the fun of it, please note I’ve recently published about bridging zigbee and z-wave devices using a Sonoff ZBBridge and Z-Wave ME USB dongle. I mostly use Home Assistant and in that case also Node-RED.

Leave a Reply

Your email address will not be published. Required fields are marked *