Zigbee Switch Configurable Firmware (+Router)

This firmware allows you to create a Zigbee switch device with a flexible configuration of inputs and outputs. I’ve created a base firmware for CC2530, CC2530 + CC2590 , CC2530 + CC2591 and CC2530 + CC2592 chips. The attached configurator for Windows can write your device configuration to the selected base firmware. Then you can save the customized version to a separate HEX file and upload to your device.

Inputs and outputs can work independently. So you may create a switch without a control button, or a simple button only.

The device with this firmware also works as a router.

Note: the firmware is designed for constantly powered devices.

Options

Fig.1 The configuration window

Remember state – The firmware saves the output state to NVRAM and restores it after power off/on.

Link – The input immediately controls the state of the corresponding output. The device sends the on/off state of the output to a coordinator. Otherwise, the input is independent.

Long – The firmware detects and reports to the coordinator a long click (2000 ms).

Double – The firmware detects and reports double click (max 500 ms between clicks).

Triple – The firmware detects and reports triple-click (max 500 ms between clicks).

Zigbee internals

  1. The firmware creates a separate endpoint (1..5) for every configured output and/or input (max 5 endpoints).
  2. The firmware reports the state of an independent button via the “ZCL_CLUSTER_ID_GEN_MULTISTATE_INPUT_BASIC” cluster and the “PRESENT_VALUE” attribute. 1 – single click.
    2 – double click.
    3 – triple-click.
    4 – long click.
  3. The firmware does not send a separate report for the linked button. Otherwise, it sends reports about the output state via the “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster and the “ON_OFF” attribute.
  4. You may control the output state via the “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster and the “ON_OFF” attribute.
  5. The “ZCL_CLUSTER_ID_GEN_ON_OFF” cluster also accepts the “read”, “configure” and “onOffWithTimedOff” commands: “read” – returns the current state on the specified endpoint.
    “configure” – set the periodic reporting interval for the output. The “minReportInt” attribute specifies the reporting interval in seconds. If “minReportInt” is 65535, the firmware disables periodic reports. “onOffWithTimedOff” – sets the output state to “HIGH” for “onTime” milliseconds, and automatically resets to “LOW”.

Updates

2019-08-14: Fixed bug with 3rd and 4th inputs.
2019-06-27: First release.

Download

Download firmware


Comments
Harvey Specter
Posted at 20:37 August 3, 2019
Mülly
Reply
Author

Hello ptvo,

this looks really great and is exactly what I was looking for. I got a couple of “Z-Control” experimental boards (http://www.z-control.de/p/62/starter-kit-i-zsk101) which are based on CC2531. Therefore I’m wondering, if your code will also work for CC2531-based boards?
Btw: the package mentioned above is really wonderful: you not only get a CC2531 MCU but also some sort of CCDebug adapter (works with TI’s SmartRFProg), some I2C stuff and a power adapter.
I flashed it with the github coordinator firmware and another one with the router-diag firmware and both work well and communicate.

Thsnks a lot for your work,
Mülly

    Harvey Specter
    Posted at 07:05 August 4, 2019
    Owner
    Reply
    Author

    Hello Mülly,

    Sorry, but I’ve prepared the firmware for the CC2530 chip only because CC2531 is overabundant for DIY projects (USB is useless in most cases).

      Harvey Specter
      Posted at 08:13 August 19, 2019
      Mülly
      Reply
      Author

      Hello ptvo,

      you’re right, its overshoot. However, I can get an USB-dongle for not even EUR 5, and modify it to have some I/O pins (some even have already some sort of I/O header), whereas the cheepest CC2530 I can get without eBay/Alibaba is in the EUR 20-something (X-Bee).

      Best regards,
      Mülly

Harvey Specter
Posted at 14:47 August 4, 2019
Guest0007
Reply
Author

it’s really cool! I would like to try it to work with my zigbee2mqtt. Will it work with zigbee2mqtt?

    Harvey Specter
    Posted at 03:38 August 5, 2019
    Owner
    Reply
    Author

    Yes, but you should use the ‘dev’ branch.

Harvey Specter
Posted at 20:58 August 5, 2019
Olili
Reply
Author

Great! Exactly what I searched for.
I’m using the DIY firmware with E18-MS1 (CC2530+2592). Basically it is working perfectly. But I have problems reading INP3+4.
Some details: different HW assignments tested, Zigbee2MQtt + devices.js/toZigbee.js/fromZigbee.js from dev branch.

Any Ideas?

    Harvey Specter
    Posted at 03:46 August 6, 2019
    Owner
    Reply
    Author

    Could you please upload a screenshot with your firmware settings somewhere? What do you expect to get? What did you get in Z2M?

      Harvey Specter
      Posted at 09:06 August 10, 2019
      Olili
      Reply
      Author

      As written at z2m issue tracker – Logs and datasheet are available at niklas.ml/issue.zip.

      Any track in between?

      O

        Harvey Specter
        Posted at 04:59 August 11, 2019
        Owner
        Reply
        Author

        Sorry, I was busy at work. I’ll look at this in the next few days.

          Harvey Specter
          Posted at 04:42 August 14, 2019
          Owner
          Author

          Hi @Olli.

          I’ve fixed this bug in the firmware. Please, re-download the ZIP archive.

      Harvey Specter
      Posted at 06:42 August 14, 2019
      Olili
      Reply
      Author

      corrected version is working. Many thanks for your great work!

        Harvey Specter
        Posted at 06:54 August 14, 2019
        Owner
        Reply
        Author

        You are welcome 🙂

Harvey Specter
Posted at 23:46 August 7, 2019
MrAlester
Reply
Author

Great project! Could you please update it to allow to select the CC2530 as an End Device instead of Router? Please!

    Harvey Specter
    Posted at 04:10 August 8, 2019
    Owner
    Reply
    Author

    Could you please explain your request? When do you need EndDevice only, and you cannot replace it with a router?

      Harvey Specter
      Posted at 23:04 August 10, 2019
      MrAlester
      Reply
      Author

      My house (sadly) doesn´t have the Neutral wire on the wall switches.

      I managed to flash a non router firmware to a CC2530 and wire the wall switches to a relay that was connected to it. Everything worked perfect, I could turn the lights using the wall switch or a zigbee message.

      It worked great until the battery ran out of juice, it lasted one day. That’s when I realized that I needed to configure the CC2530 as a EndDevice. And since I’m not Z-Stack savy, I couldn’t make it work.

      My ideal wiring is:

      – CC2530 Router at the Lamp Bulb.
      – CC2530 EndDevice at the wall switch powered by batteries.
      – Wires permanently connected, that way CC2530 Router is always powered.

      That way I can use the wall switches that already are placed in the house (wife’s request). And the EndDevice won’t be permanently activated so the battery last for a long time (Xiaomi Switches have been working for over a year without being replaced).

      Thanks!!

        Harvey Specter
        Posted at 05:03 August 11, 2019
        Owner
        Reply
        Author

        EndDevice with a relay is a bad idea. The consumption of the relay is big and constant. This device will work with a battery for a short time too.

          Harvey Specter
          Posted at 03:32 August 12, 2019
          MrAlester
          Author

          The relay is for the router which goes in the lamp.

          The EndDevice is only for replacing the wall switches, which are “asleep” until someone presses them.

          I know it’s redundant, but it’s the only zigbee solution I’ve come across for a No-Neutral wire home.

Leave a Reply

Navigation