Flashing a CC2531 Zigbee Dongle with the zigbee2mqtt firmware using a Raspberry Pi

I've recently started using Ikea Tradfri lights in my flat, and intend to get some Xiaomi sensors in the very near future to continue to improve my Home Automation. Both these platforms use a wireless protocol called Zigbee to communicate.

So far my experience with the Tradfri Hub has been reasonable, but I am cursed with a constant urge to fiddle with things and add more functionality. Enter zigbee2mqtt - "It bridges events and allows you to control your Zigbee devices via MQTT. In this way you can integrate your Zigbee devices with whatever smart home infrastructure you are using."

zigbee2mqtt is compatible with the Tradfri range and the Xiaomi sensors, and a bunch of other zigbee devices. It utilises a USB dongle, the CC2531 to handle the RF side. Clones are cheap and readily available.

zigbee2mqtt requires you to flash the USB dongle with a different firmware. For whatever reason most guides assume you'll be using a CC Debugger to do this, however it's an added expense and isn't necessary - You can also use an Arduino or Raspberry Pi to flash the firmware.

I opted to use a Raspberry Pi as I already had one on the bench. Click read more to learn how to use the Pi to flash the Dongle

CC2531 Dongle

Required Items

  • Raspberry Pi, Power Supply, 
  • CC2531 Dongle
  • CC2531 Cable Adapter
  • 4 Male to Female Jumper Wires


It's assumed you already have an Operating System running on the Raspberry Pi and know your way around the command line.

Connecting the dongle to the Pi

With the Raspberry Pi turned off, plug the Dongle into an available USB port. The smaller connector on the debug cable should be carefully fitted to the header pins on the dongle, with the ribbon cable coming off to the left assuming the dongle is orientated with the USB connector to the top, shown in the photo below

Dongle with debug cable connected
Next you need to connect the other end of the debug cable to the GPIO pins on the Raspberry Pi. There's some pinouts etc online, but the orientation wasn't clear to me. I did some verification with a multimeter and managed to figure it out. The pinout diagram assumes you're looking into the larger connector on the debug cable, with the locator at the top.

The debug cable (Click to expand)

You only need to connect 4 cables between the debug cable and the Raspberry Pi. These are ground, DC, DD and Reset. I used some short, Male to Female jumper cables.
Debug Cable Pinout
Raspberry Pi Pinout, Assuming USB ports are on the right.

Debug Connector Raspberry Pi GPIO
GND 1 39
RESET 4 35
DC 2 36
DD 7 38

Hopefully the above diagrams give you enough to figure out the wiring. I've included some photos below for reference. I was using Black for Ground, Grey for Reset, Orange for DC and Yellow for DD

Front view of large debug connector showing connections
Connections to Raspberry Pi GPIOs
Once everything is connected up, you can power on the Raspberry Pi. Hopefully you won't see any magic smoke escaping.

Flashing the firmware

The next step is to flash the zigbee2mqtt firmware to the dongle.

Sudo to root:
sudo su 

Install some dependancies:
apt-get install wiringpi git unzip

Change into the opt directory:
cd /opt

Clone the repo:
git clone

Change into the new directory:
cd flash_cc2531

Check the dongle is properly connected, by running the command below. It should return the ID as b524. If there is an error, check the connections!

Download the latest firmware and unzip it:


Erase and flash the firmware. It should take around 3 minutes:
./cc_write CC2531ZNP-Prod.hex

Once you see "Flash Ok" you've finished flashing the firmware and can start using the dongle.


  1. I think that the pinout drawing for the pi is wrong. USB ports should be on the RIGHT.

  2. Good tutorial! Clear and precise.